Architecture

Separate stacks, one set of rules.

Every product is a self-hosted Docker Compose stack: an nginx front door, a FastAPI service, PostgreSQL for every record and Redis for everything that may be lost. Only the proxy is published. Every AI call goes through one server-side gateway.

Shared principles

Decisions both products make the same way.

  • One origin

    The compiled React app and the API are served from the same origin behind nginx, so session cookies stay same-site and no cross-origin access is needed.

  • PostgreSQL holds the truth

    Every business record lives in PostgreSQL, and Alembic owns the schema: the application never creates tables behind its back. Redis holds sessions, rate-limit counters, caches and queues only.

  • Protected by construction

    Every router except sign-in is mounted behind a session check, so a new route cannot be added unauthenticated. Tests walk the whole route table to prove it.

  • Blocking work off the event loop

    Route handlers are synchronous and run in a thread pool; long jobs in cognita dev run in a separate Celery worker with progress streamed back.

  • Secrets as files

    Keys are mounted as Docker secrets, never baked into images. cognita dev refuses to start in production with a missing secret or an unsafe setting.

  • Evidence by design

    Exports carry hashes, uploads are typed by their content and stored under generated names, and downloads go through an authenticated route only.

cognita dev

Internal networks per role, one way in, one way out.

nginx is the only container with a published port: /api goes to the API, and /repository/, /v2/ (container images) and /service/rest/ to the artifact repository. Everything else sits on internal networks. Nothing reaches the internet directly: the worker, the repository, virus signature updates and sign-in each go out through one squid proxy on a network of their own, with an allowlist per service. A one-shot migrate service applies database changes, so the running API holds no owner password.

cognita dev deployment The browser reaches nginx on port 443. nginx forwards /api to the FastAPI api service and /repository/, /v2/ and /service/rest/ to the registry service, the artifact repository. A one-shot migrate service applies database changes before the api starts. The api, registry, worker, scheduler and registry-jobs run on internal networks with PostgreSQL 16, Redis 7, the files volume and the artifacts volume. The worker, the registry and sign-in reach outside hosts only through the squid egress proxy, which keeps an allowlist per service and can chain to a corporate proxy: model providers, identity providers, security feeds and public package registries. An LDAP relay reaches your directory over LDAPS. ClamAV, vLLM, the LDAP relay and the backup service are optional. Browser users, build tools proxy · nginx TLS 1.2+ · CSP nonce /api · /repository/ egress · squid allowlist per service parent: your proxy Allowlisted hosts models · IdPs · feeds package registries internal networks: app · data · directory api · FastAPI sessions · RBAC · audit gunicorn + uvicorn registry · FastAPI artifact repository firewall · tokens worker · Celery AI jobs · exports scans · evidence packs vLLM · optional on-prem model on GPU for Restricted data scheduler · beat chain check 02:00 UTC feeds · health · expiry registry-jobs cleanup · trash purge blob compaction ldap-relay optional · LDAPS to your directory backup · optional encrypted dumps restore drill in CI data network ClamAV · optional scans uploads and repository files PostgreSQL 16 every record WAL archived hourly Redis 7 sessions · rate limits job queue · no records files volume evidence · uploads SHA-256 per file artifacts volume package blobs by SHA-256 443 only /repository/ allowlists only
Every container runs as non-root with a read-only root filesystem, all capabilities dropped and no-new-privileges. The containers trust your organisation's CA bundle when you supply one, and squid can chain to your corporate proxy. Losing Redis logs everyone out but loses no data.

A request, step by step

  1. nginx terminates TLS, adds the security headers and a per-response CSP nonce, and forwards /api, unbuffered for progress streams.
  2. Middleware records metrics, adds a request ID, checks the CSRF header and origin, and applies rate limits.
  3. The protected router checks the session cookie against Redis; a Redis failure is a 503, never a pass.
  4. The endpoint checks its named permission, then whether the project is in the caller's scope.
  5. The service writes to PostgreSQL with the audit event in the same transaction. If the audit write fails, the change rolls back.

What runs in the background

  • AI generation, reviews and rewrites, with progress over server-sent events
  • Word, PDF and PowerPoint exports, rendered in the worker and stored with their hash
  • Upload scanning and retries every 30 minutes when ClamAV is enabled
  • Evidence pack builds with a verifiable manifest
  • Audit chain verification every night at 02:00 UTC
  • Provider status checks every 5 minutes, shown in the admin console
  • Artifact repository: CISA KEV refresh, health check of what the proxies cache, release expiry; cleanup to the trash, blob compaction and container image scans with Trivy in registry-jobs
cognita grc · cognita soc

A compact stack that degrades instead of failing.

In production, nginx serves the compiled app and proxies /api to FastAPI on the same origin. The API, PostgreSQL and Redis stay on the internal network. If Redis goes down, sessions survive and rate limiting falls back to in-process counting.

cognita grc deployment The browser reaches the nginx frontend, which serves the compiled app and proxies API calls to the FastAPI backend. The backend uses PostgreSQL 15, Redis 7 and an uploads volume on the internal network. AI requests pass through the AI service, which checks the kill switch, then call Google Gemini, Anthropic Claude or an on-premises Ollama model. Sign-in can go to your directory over LDAPS or to a SAML or OpenID Connect identity provider. An optional ClamAV container scans every upload. Browser Users on your network frontend · nginx compiled app proxies /api, same origin Model providers Gemini · Claude outside your network backend · FastAPI RBAC · audit · reports /health/live · /ready AI service kill switch checked first model allowlist On-prem model Ollama prompts stay on-prem internal network PostgreSQL 15 every record schema by Alembic Redis 7 revocation · rate limits cache · 2 s timeouts uploads volume generated names SHA-256 on upload /api → backend:8000 Your directory · IdP LDAPS · SAML · OIDC signatures checked clamav · optional scans every upload before it is stored every service non-root · only nginx is published optional built-in HTTPS on the frontend · Redis password required
cognita soc runs on this same stack as the Cybersecurity modules. Its SCA reviews run Google OSV-Scanner inside the backend image, which looks up package names and versions at osv.dev and reads the CISA KEV and FIRST EPSS feeds; Fortify, CyberArk and cognita probe hand over files. Nightly database snapshots are taken by a host task, outside the containers.
Security controls by layer

Each layer refuses on its own, so one miss is not a breach.

The controls below are built into both products and covered by tests that run on every merge. The security page has the detail, and how both products were tested and fixed.

LayerControls
EdgeOne published port; TLS 1.2+ and HSTS; content security policy (a per-response nonce in cognita dev), frame denial, nosniff and a strict referrer policy.
IdentityCookie-only sessions that a server-side store can revoke; TOTP multi-factor sign-in; lockout and indistinguishable failures; LDAP, SAML and OpenID Connect with signature, audience and replay checks; break-glass for administrators.
AuthorizationEvery route checks a named permission (cognita dev) or view and edit per module (cognita grc); a test walks every route and fails the build if one has no check.
RequestsA custom header and matching origin on state-changing calls, rate limits by address, user and route, and generic errors with a request ID instead of internals.
DataPostgreSQL holds every record; the audit event is written in the same transaction as the change (hash-chained in cognita dev); Redis holds no records.
FilesTyped by content, archive size and ratio caps, generated names, a SHA-256 per file, optional ClamAV scanning, and formula escaping in every spreadsheet export.
NetworkInternal networks for the API and the data; outbound traffic only to allowlisted hosts (squid with a list per service in cognita dev; the enabled AI provider, sign-in providers and the vulnerability feeds in cognita grc).
ContainersNon-root; in cognita dev also read-only root filesystems, all capabilities dropped, no-new-privileges and images pinned by digest.
SecretsDocker secret files; provider keys and identity-provider secrets encrypted at rest and never shown again; logs pass a redaction filter.
AIOne gateway, the platform-wide switch checked first, an allowlist of models, sanitised prompts, and provenance for every call.
OperationsLiveness and readiness endpoints, request IDs on every log line, encrypted backups with a restore drill or check.
AI gateway

Every model call takes the same path, and can be stopped at one point.

In cognita dev, provider SDKs may be imported only inside one module, and CI fails the build if anything else tries. The API process never calls a model; the worker does.

  1. Checked. The job endpoint verifies the model key against the allowlist, the caller's role, the project's data classification, the emergency stop and the budgets. A refusal is audited and no provider is called.
  2. Queued. The job goes to the Celery worker; the browser follows its progress over server-sent events and can cancel it.
  3. Called. The gateway calls Claude or Gemini through the egress proxy, or vLLM on the internal network, with reference files passed as delimited data and no tools.
  4. Validated. Output is checked against the task's schema and retried once before failing with a clear message.
  5. Recorded. Model, prompt version, input hashes, tokens, cost and latency are stored with the job and in the audit log.
  6. Proposed. The result lands as a new draft version labelled AI-generated, and stays labelled until a person edits it.

cognita grc applies the same idea in one service: every AI request checks the database-held switch first (cached for 60 seconds, failing closed), then calls Gemini, Claude or a local Ollama model and validates the JSON it gets back.

cognita api

A console that configures, a gateway that forwards, and keys neither can misuse.

cognita api is its own installation with two processes that trust each other as little as possible. The console stores configuration and shows the logs; the gateway carries the traffic. Each has its own database role, its own network and only the keys its job needs.

cognita api deployment nginx is the only published service, with one listener for the console and one for the gateway. The console holds the web interface's API, configuration and the audit log, with its own Redis for sessions. The gateway process handles consumer calls with its own Redis for counters and cache. Both use PostgreSQL through separate database roles: the gateway role reads configuration and writes the call log only. A jobs process handles retention, alerts and the SIEM export. The gateway's only way out is a squid egress proxy with an allow-list of upstream hosts, optionally through your corporate proxy, to the external services. nginx only published :443 console :8443 gateway TLS, client certs console FastAPI · React configuration, call log, audit log, alerts seals credentials gateway data plane · replicas identity, grants, plugins, classification and masking opens credentials Redis · sessions console only PostgreSQL a role per process call log by month hash-chained audit Redis · gateway counters, cache jobs retention, alerts, SIEM export egress proxy listed hosts only External APIs AI, search, data
The gateway has no route to the internet except the egress proxy, whose allow-list is a file kept apart from the gateway's own configuration.
  • Credentials sealed one wayThe console encrypts a vendor credential with the gateway's public key. Only the gateway process holds the private key, so the console that stores a credential cannot read it back.
  • Payloads sealed the other wayKept payloads are encrypted by the gateway with the console's key, and opening one in the console needs a fresh authenticator code.
  • A database role per processThe gateway role reads configuration and writes call rows; it cannot change configuration. The jobs role has only what retention, alerts and the export need.
  • Logged before forwardedThe call row is written first. If the database cannot take it, the call is refused rather than sent unrecorded.
  • Configuration by versionWorkers poll a version number and reload within seconds; a revoked key stops working without a restart.
  • Two people for an internal addressMarking a service internal, which exempts it from the egress rules for private ranges, needs a second person to confirm its address.
cognita lms

Two origins: the application, and the course content kept away from it.

cognita lms is its own installation. Its nginx front end publishes two ports: one for the application and one for course packages, so a SCORM or cmi5 package runs on a separate origin with no session and cannot reach the application's pages or cookies. It shares no database with cognita grc; the organisation chart moves between them as a file.

PieceWhat it does
frontend (nginx, unprivileged)The compiled React app on one port, course content on a second
backendFastAPI on Python 3.13: courses, assignments, records, the course builder and its marking, and PowerPoint conversion with LibreOffice
contentThe same image serving course packages to the content origin only
workerA pass every quarter of an hour: assignments brought up to date, e-mail reminders and the managers' weekly digest
DataPostgreSQL 17 for every record; Redis 7
OptionalClamAV upload scanning; an AI assistant that calls Gemini, off until an administrator switches it on and adds a key
Documents and files

Outputs people already use, made safely.

Exports

Word, PDF, PowerPoint, Excel

cognita dev renders Word with python-docx and converts it to PDF with LibreOffice, builds decks with python-pptx, and stamps every page with the version hash. cognita grc builds PDFs with ReportLab and jsPDF, Excel with openpyxl and Word with python-docx.

Uploads

Typed by content, not by name

File types are detected from their leading bytes, archives are read entry by entry with size, ratio and count limits, and files are stored under generated names outside any web-served path.

Spreadsheets

No formula injection

Every exported cell passes one escaping function, so text starting with =, +, - or @ can never run as a formula when someone opens the file.

cognita skills

Run on the analyst's machine, not on the platform.

cognita probe, cognita audit and cognita cap are Claude Code skills. Each is a set of instructions, a standard-library command-line tool that enforces its rules, and a locked-down container. They need nothing installed on the platforms and hand their results over as files.

Where cognita skills run On the analyst's machine, Claude Code follows a skill and calls its command-line tool, pt, au or cap. The tool checks each step against its rules and runs it in a locked-down container: the probe sandbox with an egress firewall, or the audit or cap capture container. The container reaches only the declared target: a lab built from source and air-gapped, or an approved test environment. The results are files, imported into cognita grc and cognita soc. analyst's machine Claude Code follows the skill proposes each step pt · au · cap scope, window, kind secrets · hashes · log container au · cap: read-only, no caps probe: firewall + gateway Files handed over workpaper · pentest package · audit package screenshots · Word and PDF evidence Declared target only a lab built from source, air-gapped or an approved test environment production: navigation only cognita grc · cognita soc import the files; people review and track them
Engagement records, evidence and logs stay in a folder on the analyst's machine until the files are handed over; what leaves it is what Claude Code itself sends to the model.
Deployment

One host, Docker Compose, your network.

Each product ships as a Compose file. Bring a Linux host with Docker, point DNS at it, add a certificate, and start the stack.

cognita devcognita grc
Servicesproxy, migrate (one-shot), api, registry, worker, scheduler, registry-jobs, egress, PostgreSQL 16, Redis 7frontend (nginx), backend, PostgreSQL 15, Redis 7
Optional profilesClamAV upload scanning, vLLM on a GPU host, LDAP relay for directory sign-in, backup service; a CA bundle overlay and a corporate parent proxyClamAV upload scanning, built-in HTTPS on the frontend; an Ollama host you run, reached by its address
Published ports443 and 80 on the proxy onlyThe nginx port only
First startmake up generates secrets and a certificate; make admin creates the first administratordocker compose -f docker-compose.prod.yml up -d --build, then create the first administrator
Production guard railsENV=production refuses missing secrets, a non-HTTPS origin or test switchesSecure cookies and HSTS switched on together once served over HTTPS
BackupsEncrypted database and file backups, hourly WAL archiving, restore drill in CINightly pg_dump snapshots with a verified manifest, an encrypted off-host copy and a restore check; export and import between environments
MigrationsAlembic in a one-shot migrate service, with grants for the application role in every migrationAlembic, applied once at start in production
High availability · reference design

Two application nodes, two database nodes, one floating IP.

A single host is enough for a department. When the platform becomes the system of record for several teams, this is the layout we recommend on VMware for up to a few hundred users: four virtual machines and an optional GPU host at the main site, one standby at the recovery site. Nothing here needs Kubernetes.

High-availability reference design One DNS name points at a floating IP held by keepalived on one of two application nodes. Both nodes run nginx, the API and background tasks; one holds the Redis primary and the other a replica. Two database nodes run PostgreSQL under Patroni: a primary and a synchronous standby. etcd runs on both application nodes and the first database node to form a three-node quorum. An optional GPU host serves the on-premises model. A NAS exports the files share to both application nodes. At the recovery site, one standby database node receives streaming replication and the application nodes are replicated by vSphere. Browser one DNS name MCP clients, when added Floating IP keepalived, VRRP moves in about a second Model providers through your egress proxy outside your network application tier · active-active app node 1 nginx · API · tasks Redis primary · etcd app node 2 nginx · API · tasks Redis replica · etcd GPU host · optional Ollama (vLLM for dev) Restricted data, embeddings data tier · primary and synchronous standby db node 1 · primary PostgreSQL · Patroni etcd (third vote) db node 2 · standby synchronous replication promoted in about 30 s NAS share uploads and evidence mounted by both app nodes recovery site app nodes vSphere Replication powered on at failover db standby streaming replication NAS replica beside it sync WAL streaming to the recovery site
vSphere HA and DRS are the floor: each pair is kept on different physical hosts, and a host failure restarts its virtual machines elsewhere within minutes. The three etcd votes live on app node 1, app node 2 and db node 1, so Patroni keeps a quorum with any one machine down.
If this failsWhat happens
One application node, or its upgradeThe floating IP moves to the other node in about a second. Rolling upgrades take one node out at a time, with no downtime.
The primary databasePatroni promotes the synchronous standby in about 30 seconds. No committed transaction is lost.
A physical hostvSphere HA restarts its virtual machines on another host within minutes; the pairs are on different hosts, so the service does not wait for it.
The GPU hostAI features degrade. Tasks that may only use the on-premises model fail closed; everything else keeps working.
The whole siteThe recovery site takes over: RPO within 15 minutes, RTO 4 hours.

Why four machines and not more

At this scale one application node and one database carry the load comfortably. The second application node exists for upgrades without downtime and a one-second failover. The second database node exists so that no committed write is lost. Further nodes add maintenance, not availability.

  • Application nodes: 4 vCPU and 16 GB each, running the same Compose stack as a single host
  • Database nodes: 4 vCPU and 32 GB each, PostgreSQL under Patroni with etcd for leader election
  • Redis primary and replica on the application nodes; losing Redis costs sessions, never records
  • Files on an existing NAS with snapshots, mounted by both application nodes
  • Outbound AI calls through the egress proxy you already run, allowlisted to the enabled provider hosts
  • Recovery site: one standby database receiving streaming replication, application nodes replicated by vSphere, a NAS replica

This is a reference design for your infrastructure team, not a product feature: Patroni, etcd and keepalived are installed and operated by you. The single-host layout above stays the default.

Technology

The same stack, pinned to exact versions.

Layercognita devcognita grc
LanguagePython 3.12, TypeScript 5.9Python 3.13, TypeScript 5.9
APIFastAPI 0.141, Pydantic 2.13, gunicorn + uvicornFastAPI 0.141, Pydantic 2.14, uvicorn
DataSQLAlchemy 2.0, Alembic 1.13, PostgreSQL 16, Redis 7SQLAlchemy 2.0, Alembic 1.13, PostgreSQL 15, Redis 7
Background workCelery 5.4 worker and beatFastAPI background tasks, host scheduler for backups
Security librariesargon2-cffi, PyJWT, slowapi, structlog, ldap3, signxmlbcrypt, PyJWT, cryptography, slowapi, defusedxml, ldap3, signxml
AIanthropic, google-genai, OpenAI-compatible client for vLLManthropic, google-genai, Ollama over its HTTP API
Documentspython-docx, python-pptx, openpyxl, LibreOffice, GraphvizReportLab, python-docx, openpyxl, pypdf, pdfplumber, jsPDF
FrontendReact 19, Vite 7, MUI 7, React Router 7, TanStack Query, TipTap, React FlowReact 19, Vite 7, MUI 7 and MUI X DataGrid, React Router 7, Mermaid
Testspytest against PostgreSQL, Vitest, Playwright, axepytest with SQLite and an in-process Redis; migrations checked on PostgreSQL 15 in CI; a route walk that fails any route without an access check
Architecture review

Walk your security architects through it.

We can run a technical session on the network layout, the AI gateway and the evidence model with your architecture and security teams.