Emre Şahin

Studia przypadków architektury

Operliva

SaaS dla firm: CRM, ERP i automatyzacja fabryk. Usługi .NET za bramą YARP, gRPC między usługami, hybrydowa wielodostępność współdzielona i izolowana, przepływy pracy LLM oraz dostęp do API oparty na uprawnieniach.

Rola
Architekt rozwiązań
Okres
2025 – 2026
Stack
.NET, YARP, gRPC, PostgreSQL, RabbitMQ, SignalR, LLM

Simplified and anonymised: no source code, customer data or confidential architecture details.

Overview & business problem

Operliva is a business platform for small and mid-sized companies. It combines a CRM core (leads, contacts, deals, pipelines, activities) with commerce and documents, team chat, and an AI outreach agent that finds prospects matching a company's ideal customer profile and drafts personalised first messages.

It started as an internal tool for a single company. The business goal was to turn it into a product other companies could use, without pausing feature work and without building a platform that a small team could not operate.

My role & requirements

I designed Operliva's architecture as Solutions Architect at Fortech. A team of backend and frontend engineers built the services and the two Vue panels; my part was the service boundaries, the tenancy and security model, and the guardrails that keep those decisions true as more people contribute.

The requirements I designed against:

  • Behave like a single-tenant system on day one, but be written so multi-tenancy is a configuration change, not a refactor.
  • Give larger tenants a path to their own database for load, contractual or data-deletion reasons.
  • Make authorization mistakes visible before they reach production.
  • Handle untrusted input (uploads, webhooks, AI output) defensively.
  • Keep the AI agent useful without letting it send things nobody intended.

Architecture & design decisions

The diagram on this page is simplified and is not the real production topology.

Five .NET 10 services sit behind one YARP gateway: identity, CRM, outreach (with a separate agent worker), commerce and chat. Each follows the same Domain, Application, Infrastructure and API layering. The two Vue 3 panels, one for users and one for administrators, only know the gateway.

Schema per service. Every service owns its PostgreSQL schema and never reads another's. Synchronous questions go over gRPC; state changes are published through MassTransit and RabbitMQ with a transactional outbox, so a write and its event happen together or not at all. Hangfire runs scheduled work, and chat uses SignalR with a Redis backplane.

Tenant-ready from the first line. I set one rule early: the system behaves single-tenant, but every tenant-owned table carries a tenant id and every query goes through a shared DbContext base with global filters. Turning on multi-tenancy then meant changing where the tenant comes from, not touching every query.

Hybrid pooled and silo tenancy. Most tenants share a pooled database; larger ones can get their own. The identity service keeps a registry of where each tenant lives, and other services resolve it over gRPC, cache it, and route each request to the right DbContext. Moving a tenant is a controlled sequence that ends in a registry update, not a deployment. If placement cannot be confirmed, the resolver fails closed.

Authorization as a reviewed artefact. A test generates a manifest of every endpoint's access rules per service and compares it with a committed file in the pull request pipeline. Any permission change appears as a diff a reviewer must look at, instead of hiding in an attribute.

A bounded AI agent. The outreach agent pulls the tenant's ideal customer profile, searches a prospect data provider, scores candidates, and uses an LLM to draft messages. It runs as its own worker, pinned to a single instance, and supports a manual approval mode where drafts wait for a person before anything is sent.

Trade-offs

Hybrid tenancy over all-pooled or all-silo. Pure pooling is cheapest but makes large tenants everyone's problem. Pure silo isolates well but multiplies databases and migrations from the start. Hybrid puts the operational cost only where it buys something, at the price of a promotion path that is the most delicate code in the system.

Several services over one modular monolith. Separate services gave clear ownership and independent deployment, but they cost a small team real effort in local development and cross-service debugging. I accepted that because modules such as chat and the agent have very different runtime profiles from the CRM core.

A single agent instance over horizontal scale. Duplicated runs would mean duplicated messages to real people. Lower throughput is the smaller risk.

Migrations as fleet operations. Migrations are pinned and checked in CI, and destructive changes use expand and contract over two releases. Slower, deliberately.

Security & scalability

Sessions use HttpOnly cookies. The gateway enforces origin checks, a double-submit CSRF token on state-changing requests, an allow-list of hosts and an MFA enrolment gate, so these rules live in one place rather than five. Tenant connection details are encrypted at rest in the registry.

Uploaded files are scanned with ClamAV before they are accepted, and uploads fail closed if the scanner is unavailable. Inbound webhooks from messaging channels are signature-verified and processed idempotently, so retries and replays do not create duplicates. AI output is treated as untrusted text, never as instructions.

For scale, services scale independently behind the gateway, the SignalR backplane lets chat run on several instances, and a tenant that outgrows the pool can be moved without a release.

Results & lessons learned

Operliva runs as a multi-tenant product with five services behind one gateway, tenancy switchable by configuration, and a defined path for large tenants to get their own database. Authorization changes are reviewed as data, and browser-facing security is handled once, at the gateway.

The biggest lesson: the cheapest time to make a system multi-tenant is before it has tenants.

What I'd do differently today

  • Start with a modular monolith for the CRM, commerce and identity core, and split out only chat and the agent, which genuinely behave differently at runtime.
  • Rehearse tenant promotion and rollback on production-like data from the first release, so the riskiest path is also the most practised one.
  • Drive tenant registry cache invalidation by events from the start, with time-based expiry only as a safety net.
  • Add per-tenant load and cost metrics early, so placement decisions are based on measurements rather than assumptions.