Technical overview · Architecture

Architecture.

Hexagonal architecture isolates the domain from frameworks; one binary runs from a developer's workstation to production; and an ownership model underpins access control. The three decisions that shape the platform — and why.

Layered architecture of the multi-agent platform From top to bottom: React interface, network layer with API Gateway and ALB, REST and SSE APIs, Spring AI orchestration, tools, MCP and RAG capabilities, then AWS infrastructure and OpenAI. INTERFACE React SPA · Chat UI · Admin EDGE API Gateway · ALB · TLS termination API REST · OpenAPI 3 · SSE streaming ORCHESTRATION Spring AI · Agents · Delegation · Memory TOOLS AWS S3 MCP brave · filesystem RAG S3 → vectors INFRASTRUCTURE & DEPENDENCIES AWS CLOUD API Gateway · ALB · EC2 · S3 IAC Terraform LLM OpenAI
Layered view — Spring AI orchestration at the centre, isolated from infrastructure and external dependencies.
01 · Hexagonal architecture

An isolated domain with pluggable adapters.

The platform uses hexagonal architecture (ports and adapters). The domain knows nothing about Spring, JPA or OpenAI: it defines business rules and expected contracts, and nothing more. Infrastructure connects through explicit ports. This initial investment shapes almost everything else: testability, LLM portability, development/cloud parity and gradual evolution without a rewrite.

Domain

Entities, value objects, invariants and business exceptions. Pure Java, with no framework dependencies.

Application

Use cases, transactions and technical ports (LLM, JWT, clock). Depends on the domain, not infrastructure.

Infrastructure

REST, JPA, Spring AI, PostgreSQL and SSE adapters. Implements the ports and isolates frameworks.

What this enables

Hexagonal architecture shapes nearly every other platform decision: LLM abstraction (a new provider requires only a new adapter), development/cloud parity (the domain depends on no AWS service), testability (use cases can be tested without Spring or a database) and gradual evolution (add an ownership type, tool or MCP server without changing the application core).

CI guardrail

The domain ← application ← infrastructure rule is enforced rather than merely documented: ArchUnit tests fail CI if it is violated. Architecture becomes a verifiable property, not a recommendation.

02 · Deployment

One fat JAR, three configurations.

The same binary runs on a development workstation and a production EC2 instance. Only the configuration file and a few environment variables change — an intentional simplification for the current target.

  • Runtime. Spring Boot fat JAR managed by a system service manager, with a health probe reserved for orchestration.
  • Database. Local PostgreSQL in development, RDS in production. Versioned schema applied at startup; the ORM remains in validation mode.
  • Frontend. Static React + Vite bundle served by nginx, CloudFront or S3. No server-side rendering.
  • External services. OpenAI for LLM and embeddings, MCP servers for capabilities (brave-search, filesystem). Calls are isolated behind ports.
Parity through discipline

Development/cloud parity comes from discipline, not a tool: no AWS SDK call enters the domain. Cloud-specific concerns remain in adapters. The same code runs locally with a local database and without AWS.

03 · Access control

Ownership as the backbone.

Every resource — agent, conversation or RAG document — has one owner: an authenticated user or a system API key. The two workspaces are separate, and every request passes a strict ownership-equivalence check at the service boundary.

  • Polymorphic owner. Modelled in the domain as a sealed type: UserOwner(userId) or SystemOwner(clientId). The database uses two mutually exclusive columns, enforced by a CHECK constraint.
  • Separate workspaces. Users never see system resources, and system principals never see user resources. The administrator role does not bypass this boundary; it only manages accounts and keys.
  • Future extension. Adding a new variant (for example, a team) means extending the sealed type; existing call sites remain unchanged.
404, not 403

Access to a resource you do not own returns 404 Not Found, not 403 Forbidden. This avoids disclosing identifiers owned by someone else — a defence-in-depth measure against enumeration.

Machine-to-user bridge

An administrator can link an API key to a user. The user then gains read-only visibility into resources created by that key, without transferring ownership or sharing credentials. Write actions still require strict owner equality.