Complete Architecture Guide¶
This page is the practical source of truth for how Studio is constructed. It describes the running Docker Compose architecture, the service boundaries, the request paths, the data stores, and the main background processing flows.
Architecture Summary¶
Studio is a Docker Compose based microservices platform for compliance, audit, evidence, endpoint, cloud posture, risk, reporting, and AI-assisted workflows.
The platform is organized into these layers:
| Layer | Components | Purpose |
|---|---|---|
| Edge | Kong, OPA, Ory Kratos | Public entry point, routing, authentication, authorization, rate controls |
| Web | Next.js frontend | Authenticated user interface and selected frontend API routes |
| Core API | Backend API | Business logic for users, projects, evidence, risks, reports, tasks, controls, and integrations |
| AI | AI service, document RAG service, vector store, graph retriever | Chat, policy generation, evidence analysis, retrieval, graph queries, and AI tool execution |
| Workers | Analysis worker, chunking worker, URL downloader worker, Prowler workers | Background processing, graph sync, AI analysis, document chunking, URL evidence ingestion, cloud scans |
| Data | PostgreSQL, MinIO, Redis, Neo4j, Chroma/vector storage, Fleet MySQL, Prowler database | Relational records, files, queues, graph relationships, embeddings, endpoint data, cloud scan data |
| Security Tools | FleetDM, Prowler, CASB integrations | Endpoint monitoring, osquery management, cloud security posture, SaaS posture |
| Observability | Prometheus, Grafana, Loki, Fluent Bit, Tempo, Phoenix, exporters | Metrics, logs, traces, dashboards, AI observability |
High-Level System Diagram¶
graph TD
User["User Browser"] --> Kong["Kong API Gateway"]
Kong --> Frontend["Next.js Frontend"]
Kong --> Backend["Backend API"]
Kong --> Viewer["Secure Evidence Viewer"]
Kong --> Kratos["Ory Kratos"]
Kong --> OPA["Open Policy Agent"]
Frontend --> Backend
Frontend --> Kratos
Backend --> Postgres["PostgreSQL + pgvector"]
Backend --> Redis["Redis / BullMQ"]
Backend --> MinIO["MinIO Evidence Storage"]
Backend --> Neo4j["Neo4j Graph DB"]
Backend --> GraphRetriever["Graph Retriever"]
Backend --> VectorStore["Vector Store"]
Backend --> FleetService["Fleet Service"]
AIService["AI Service"] --> Backend
AIService --> VectorStore
AIService --> DocumentRAG["Document RAG Service"]
AIService --> Phoenix["Phoenix AI Observability"]
AIService --> LLMs["Gemini / Moonshot / configured LLMs"]
DocumentRAG --> Postgres
VectorStore --> VectorData["Persistent Vector Data"]
GraphRetriever --> Neo4j
AnalysisWorker["Analysis Worker"] --> Redis
AnalysisWorker --> Postgres
AnalysisWorker --> Neo4j
ChunkingWorker["Chunking Worker"] --> Postgres
ChunkingWorker --> MinIO
URLWorker["URL Downloader Worker"] --> Postgres
URLWorker --> MinIO
FleetService --> Fleet["FleetDM"]
Fleet --> FleetDB["Fleet MySQL"]
Fleet --> Redis
ProwlerAPI["Prowler API"] --> Postgres
ProwlerWorker["Prowler Worker"] --> Postgres
ProwlerBeat["Prowler Beat"] --> ProwlerWorker
Backend --> FluentBit["Fluent Bit"]
Frontend --> FluentBit
FluentBit --> Loki["Loki"]
Prometheus["Prometheus"] --> Backend
Prometheus --> Kong
Prometheus --> PostgresExporter["Postgres Exporter"]
Prometheus --> RedisExporter["Redis Exporter"]
Grafana["Grafana"] --> Prometheus
Grafana --> Loki
Tempo["Tempo"] --> Grafana Request Flow¶
All normal browser traffic enters through Kong on ports 80 and 443.
sequenceDiagram
participant U as Browser
participant K as Kong
participant O as OPA
participant F as Frontend
participant B as Backend
participant DB as PostgreSQL
U->>K: HTTPS request
K->>O: Optional authorization decision
O-->>K: Allow or deny
K->>F: Route page request
F->>B: Internal API call or browser API call through /api
B->>DB: Read or write business data
DB-->>B: Result
B-->>F: JSON response
F-->>K: Rendered UI or API response
K-->>U: Response Public Edge Responsibilities¶
Kong is the public entry point. It handles:
- Routing to frontend, backend, viewer, auth, and service endpoints.
- TLS termination using certificates mounted from
certs/. - Custom OPA authorization plugin.
- JWT support.
- CORS.
- Prometheus metrics.
- Dynamic rate limiting through the custom
dynamic-ratelimitplugin.
OPA evaluates policy decisions from Rego policies stored in gateway/opa/policies.
Ory Kratos owns identity flows such as login, registration, account recovery, and session validation. Kratos stores identity data in the kratos PostgreSQL database.
Service Inventory¶
| Service | Directory or image | Port inside network | Main responsibility |
|---|---|---|---|
kong | kong:latest + gateway/ config | 8000, 8443, 8001 | Public gateway, routing, TLS, plugins |
kratos | oryd/kratos:v1.1.0 | 4433, 4434 | Identity and session management |
opa | gateway/opa | 8181 | Authorization policy decisions |
frontend | frontend/ | 3000 | Next.js app and user interface |
backend | backend/ | 4000 | Core API and business logic |
viewer | viewer/ | 4001 | Secure evidence file viewing |
ai-service | ai-service/ | 5000 | AI chat, agent workflows, MCP tools, LLM orchestration |
document-rag-service | document-rag-service/ | 5002 | Semantic document retrieval and hybrid search |
vector-store | database/vector-store/ | 8000 | Embedding storage and vector search |
graph-retriever | database/graph-retriever/ | 3001 | Neo4j query microservice |
analysis-worker | backend/ worker target | n/a | BullMQ processing, graph sync, AI analysis, deadlines |
chunking-worker | chunking-worker/ | n/a | Evidence document chunking for retrieval |
url-downloader-worker | url-downloader-worker/ | n/a | Downloads URL evidence into MinIO |
fleet-service | fleet/ | 5001 | Studio integration layer for FleetDM/osquery |
fleet | fleetdm/fleet | 8080 | FleetDM server |
fleet-db | mysql:8.0 | 3306 | FleetDM MySQL database |
prowler-api | prowlercloud/prowler-api | 8080 | Prowler cloud posture API |
prowler-worker | prowlercloud/prowler-api | n/a | Prowler scan execution |
prowler-worker-beat | prowlercloud/prowler-api | n/a | Scheduled Prowler jobs |
postgres | pgvector/pgvector:pg15 | 5432 | Main relational database plus Kratos and Prowler databases |
redis | redis:latest | 6379 | Queues, cache, Fleet dependency |
neo4j | neo4j:community | 7687, 7474 | Evidence and control relationship graph |
minio | minio/minio | 9000, 9001 | S3-compatible evidence object storage |
prometheus | prom/prometheus | 9090 | Metrics collection |
grafana | grafana/grafana | 3000 | Dashboards |
loki | grafana/loki | 3100 | Log storage |
fluent-bit | fluent/fluent-bit | 9880 | Log forwarding |
tempo | grafana/tempo | 4317, 4318 | Distributed tracing |
phoenix | arizephoenix/phoenix | 6006, 4317, 4318 | AI trace and evaluation observability |
Repository Structure¶
| Path | Responsibility |
|---|---|
frontend/ | Next.js application, pages, components, frontend API routes, PWA assets, Playwright tests |
backend/ | Express API, Prisma schema, controllers, services, routes, worker processors, tests, seeders |
ai-service/ | Central AI brain, LangGraph workflows, MCP server/tools, chat and analysis routes |
document-rag-service/ | Document retrieval service for semantic and keyword search |
database/vector-store/ | FastAPI vector store with persisted embeddings |
database/graph-retriever/ | Neo4j retrieval service |
gateway/ | Kong declarative config, custom plugins, Kratos config, OPA policies |
viewer/ | Isolated secure evidence viewer microservice |
fleet/ | Studio FleetDM integration service and osquery installer templates |
chunking-worker/ | Worker for document chunk extraction |
url-downloader-worker/ | Worker for URL evidence capture |
observability/ | Prometheus, Grafana, Loki, Fluent Bit, and Tempo configuration |
docs/ | MkDocs documentation site |
deploy/ | Production deployment compose and gateway configuration |
ansible/ | Infrastructure automation |
certs/ | Local TLS certificates mounted into gateway and Fleet services |
Backend Construction¶
The backend is a Node.js and Express service written in TypeScript. It is the main business API.
Important backend areas:
| Area | Path | Purpose |
|---|---|---|
| Routes | backend/src/routes/ | HTTP endpoints grouped by domain |
| Controllers | backend/src/controllers/ | Request handling and response shaping |
| Services | backend/src/services/ | Business logic and external service coordination |
| Middleware | backend/src/middleware/ | Authentication, Kratos sync, authorization, request protection |
| Prisma | backend/prisma/schema.prisma | Main relational schema |
| Workers | backend/src/worker/ | Queue processors and recurring background jobs |
| Seeding | backend/src/seeding/ | Demo data, frameworks, policies, compliance data |
| Tests | backend/src/tests/, backend/src/**/__tests__/ | Integration and unit coverage |
The backend exposes domain routes for:
- Authentication and token handling.
- Admin metrics, users, frameworks, controls, questionnaires, AI compliance settings, and limits.
- Customer dashboards, project requests, evidence upload, framework controls, and issue reporting.
- Auditor dashboards, evidence requests, observations, analysis, review, control status, meetings, and project activity.
- Manager dashboards, project approval, assignment, auditor performance, customer profiles, and team management.
- Compliance overview, projection, summary, dashboard, and project details.
- Evidence records, evidence vault, annotations, linking, refresh, AI analysis, and batch analysis.
- Findings, comments, resolution, and statistics.
- Endpoint assets, agent downloads, scans, pings, and framework scan processing.
- CASB integrations and sync.
- Learning policies, training, assignments, and review status.
- Chat contacts, conversations, messages, push subscriptions.
- Tasks, tags, notifications, questionnaires, threats, threat intelligence, profile, share links, uploads, health, and system checks.
Frontend Construction¶
The frontend is a Next.js app using the App Router, TypeScript, Tailwind CSS, Radix UI primitives, and feature components.
Main authenticated screens include:
| Screen | Route | Purpose |
|---|---|---|
| Dashboard | /dashboard | Role-aware landing view |
| Admin Dashboard | /dashboard/admin | Admin overview |
| Admin Frameworks | /dashboard/admin/frameworks | Framework and control management |
| Admin AI Compliance | /dashboard/admin/ai-compliance | AI document type and checklist configuration |
| Admin SQL Config | /dashboard/admin/sql-config | Control SQL mapping configuration |
| Manager Dashboard | /dashboard/manager | Manager overview |
| Manager Projects | /dashboard/manager/projects | Assignment and approval workflow |
| Auditor Projects | /dashboard/auditor/projects | Auditor work queue |
| Customer Projects | /dashboard/customer/projects | Customer project list and requests |
| Project Detail | /dashboard/project/{id} | Control, evidence, and review workspace |
| Evidence | /evidence | Evidence list and upload flow |
| Evidence Vault | /evidence/vault | Reusable customer evidence |
| Evidence Viewer | /evidence/{id}/view | Secure evidence review |
| AI Chat | /ai-chat | AI assistant conversation UI |
| Policy Generator | /policy-generator | Policy creation and refinement |
| Reports | /reports | Report generation and exports |
| Risk | /risk | Customer risk overview |
| Findings | /findings | Finding lifecycle |
| Endpoints | /endpoints | Asset and agent management |
| CASB | /casb | Cloud app integrations |
| Documents | /documents | Document workflows |
| Learning | /learning | Policy review and training |
| Threats | /threats | Threat management |
| Vulnerabilities | /vulnerabilities | Vulnerability management |
| Questionnaire | /questionnaire | Security questionnaires |
| Users | /users | User administration |
| Settings | /settings | User and system settings |
The frontend uses NEXT_PUBLIC_API_URL=/api so browser API traffic goes through Kong. Server-side internal calls use BACKEND_URL=http://studio-backend:4000.
AI Architecture¶
Studio's AI architecture is split into orchestration, retrieval, and storage services.
graph TD
ChatUI["AI Chat UI"] --> Kong
Kong --> AIService["AI Service"]
AIService --> LangGraph["LangGraph Workflows"]
AIService --> MCP["MCP Server and Tools"]
MCP --> Backend["Backend APIs"]
MCP --> FleetService["Fleet Service"]
AIService --> DocumentRAG["Document RAG"]
AIService --> VectorStore["Vector Store"]
AIService --> LLM["Configured LLM Provider"]
DocumentRAG --> Postgres
VectorStore --> Embeddings["Embedding Index"]
AIService --> Phoenix["Phoenix Tracing"] The AI service is responsible for:
- Chat orchestration.
- LangGraph workflows.
- MCP tool execution.
- Policy generation and refinement.
- Evidence and compliance analysis.
- Context retrieval from backend APIs.
- Long-term memory and project memory workflows.
- LLM provider routing through configured API keys and gateway settings.
- AI telemetry export to Phoenix and OpenTelemetry collectors.
The document RAG service handles semantic retrieval and hybrid search. The vector store persists embeddings. The graph retriever answers graph relationship queries from Neo4j.
Evidence and RAG Flow¶
sequenceDiagram
participant U as User
participant F as Frontend
participant B as Backend
participant M as MinIO
participant Q as Redis Queue
participant C as Chunking Worker
participant V as Vector Store
participant G as Neo4j
U->>F: Upload evidence
F->>B: Create evidence record
B->>M: Store object
B->>Q: Enqueue analysis/chunking job
C->>M: Read document
C->>B: Update chunking status
C->>V: Store embeddings
B->>G: Link evidence/control relationships
U->>F: Ask AI or review control
F->>B: Request context
B->>V: Similarity search when needed
B->>G: Relationship search when needed Evidence metadata lives in PostgreSQL. Evidence files live in MinIO. Evidence-to-control relationships are mirrored into Neo4j for graph search. Semantic chunks live in the vector store for retrieval augmented generation.
Data Architecture¶
| Store | Used by | Data stored |
|---|---|---|
PostgreSQL auditdb | Backend, workers, AI service, document RAG, fleet service | Users, roles, projects, controls, evidence metadata, findings, tasks, risk, reports, memory, notifications |
PostgreSQL kratos | Ory Kratos | Identities, sessions, auth flows |
PostgreSQL prowler | Prowler API/workers | Cloud posture scan state and results |
| MinIO | Backend, viewer, workers, fleet service | Evidence files, downloaded URL evidence, generated artifacts |
| Redis | Backend workers, FleetDM, Prowler | BullMQ queues, cache-like workloads, worker coordination |
| Neo4j | Backend, graph retriever, workers | Evidence, controls, projects, tags, and relationships |
| Vector store | AI service, backend, document RAG | Embeddings and semantic search indexes |
| Fleet MySQL | FleetDM | Hosts, osquery data, Fleet users, labels, policies |
Queue and Worker Architecture¶
Redis backs background jobs through BullMQ and related worker processes.
Worker responsibilities:
analysis-worker: runs backend processors for analysis, graph updates, Prowler polling, deadline checks, AI document processing, and scheduled compliance jobs.chunking-worker: extracts chunks from evidence files and prepares them for retrieval.url-downloader-worker: downloads external URL evidence and writes files into MinIO.prowler-worker: executes Prowler scan workloads.prowler-worker-beat: schedules recurring Prowler jobs.
Background workers keep user-facing API calls fast by moving expensive document, AI, graph, and scan operations out of the request path.
Security Architecture¶
Studio applies security at several layers.
| Layer | Mechanism |
|---|---|
| Gateway | Kong TLS, CORS, JWT, OPA plugin, dynamic rate limiting |
| Identity | Ory Kratos sessions and identity lifecycle |
| Authorization | OPA policies plus backend role checks |
| Backend | Authentication middleware, role middleware, ownership checks, request validation |
| Evidence | MinIO object storage, viewer isolation, no direct public object storage exposure |
| Secrets | .env injected into containers, mounted certificates for TLS |
| Network | Docker internal network, selected localhost-only service port mappings |
| Auditability | Audit log routes, application logs, metrics, traces |
Role Model¶
The application uses role-aware routes and dashboards:
admin: system configuration, users, frameworks, AI compliance, limits.manager: project approval, assignment, team oversight.auditor: evidence review, observations, analysis, control status.customer: evidence upload, project requests, compliance work.reviewer: assigned review workflows.
Authorization is enforced through a mix of Kong/OPA decisions, backend authentication middleware, backend role middleware, and service-level ownership checks.
Endpoint and Fleet Architecture¶
Studio integrates FleetDM for endpoint and osquery management.
graph TD
Endpoint["Endpoint / osquery"] --> Fleet["FleetDM Server"]
Fleet --> FleetDB["Fleet MySQL"]
Backend["Backend API"] --> FleetService["Studio Fleet Service"]
FleetService --> Fleet
FleetService --> Postgres["Studio PostgreSQL"]
FleetService --> MinIO["MinIO"]
Backend --> Findings["Findings and Risk"] The backend exposes endpoint routes for asset listing, manual assets, agent downloads, install scripts, pings, scans, and framework scans. The Fleet service isolates Fleet-specific integration logic and writes normalized results back to Studio's main data model.
Cloud Posture and CASB Architecture¶
Prowler provides cloud security posture scanning. CASB routes provide SaaS or cloud application integration management.
graph TD
Admin["Admin/User"] --> Frontend["CASB / Risk UI"]
Frontend --> Backend["Backend CASB and Risk Routes"]
Backend --> ProwlerAPI["Prowler API"]
ProwlerAPI --> ProwlerWorker["Prowler Worker"]
ProwlerWorker --> Cloud["Cloud Accounts"]
ProwlerWorker --> ProwlerDB["Prowler PostgreSQL DB"]
Backend --> Findings["Findings"]
Findings --> Risk["Risk Dashboard"] Cloud findings are normalized into findings and risk views so they can be linked to projects, controls, and remediation workflows.
Observability Architecture¶
Studio includes a full observability stack.
| Component | Purpose |
|---|---|
| Prometheus | Scrapes metrics from services and exporters |
| Grafana | Displays dashboards |
| Loki | Stores logs |
| Fluent Bit | Collects and forwards logs |
| Tempo | Stores traces |
| Phoenix | AI workflow traces and LLM observability |
| Postgres exporter | PostgreSQL metrics |
| Redis exporter | Redis metrics |
Application services expose or forward telemetry using environment variables such as FLUENT_BIT_URL, LOKI_URL, TEMPO_URL, OTEL_SERVICE_NAME, and PHOENIX_COLLECTOR_ENDPOINT.
Deployment Model¶
Local and Compose Deployment¶
Primary local command:
Root package scripts wrap common compose operations:
Exposed Ports¶
| Host port | Service | Notes |
|---|---|---|
80 | Kong HTTP proxy | Main HTTP entry point |
443 | Kong HTTPS proxy | Main HTTPS entry point |
5455 | PostgreSQL | Bound to 127.0.0.1 |
9000 | MinIO S3 API | Bound to 127.0.0.1 |
9001 | MinIO console | Bound to 127.0.0.1 |
8080 | FleetDM | Bound to 127.0.0.1 |
8888 | Prowler API | Bound to 127.0.0.1 |
8008 | Vector store | Bound to 127.0.0.1 |
3020 | Grafana | Bound to 127.0.0.1 |
6006 | Phoenix UI | Bound to 127.0.0.1 |
4317, 4318 | Phoenix OTLP | Bound to 127.0.0.1 |
Most internal services are intentionally not exposed directly. Access should go through Kong or internal Docker networking.
Environment Configuration¶
The platform is configured through the root .env file.
Important variables include:
| Variable | Used by | Purpose |
|---|---|---|
POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB | PostgreSQL, backend, workers | Main database connection |
JWT_SECRET | Gateway, backend, viewer, Kratos, AI service | Token signing and shared auth secret |
MINIO_ACCESS_KEY, MINIO_SECRET_KEY, MINIO_BUCKET | Backend, viewer, workers | Object storage access |
GOOGLE_API_KEY, GEMINI_API_KEY, MOONSHOT_API_KEY | AI service, gateway, backend | LLM provider access |
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET | Kratos | Social login |
FLEET_MYSQL_PASSWORD, FLEET_URL, FLEET_PUBLIC_URL | FleetDM and fleet service | Endpoint management |
PROWLER_POSTGRES_DB, PROWLER_API_VERSION | Prowler services | Cloud posture scanning |
NEXT_PUBLIC_VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, VAPID_SUBJECT | Backend and frontend | Push notifications |
GRAPH_SERVICE_URL, VECTOR_STORE_URL | Backend and fleet service | Retrieval service integration |
AI_GATEWAY_URL, USE_AI_GATEWAY | Backend and AI service | AI routing |
Main Functional Flows¶
Login Flow¶
sequenceDiagram
participant U as User
participant K as Kong
participant F as Frontend
participant R as Kratos
participant B as Backend
U->>K: Open login page
K->>F: Serve frontend
F->>R: Start Kratos login flow
R-->>F: Flow data
U->>F: Submit credentials
F->>R: Complete login
R-->>F: Session
F->>B: Load current user
B->>R: Validate session when needed
B-->>F: Local role/profile context Project and Evidence Flow¶
sequenceDiagram
participant C as Customer
participant B as Backend
participant M as Manager
participant A as Auditor
participant S as Storage
participant W as Worker
C->>B: Create project request
M->>B: Approve and assign project
A->>B: Review framework controls
C->>B: Upload evidence
B->>S: Store evidence file
B->>W: Queue analysis and graph work
A->>B: Add observation and review
B-->>C: Updated compliance status Report Flow¶
graph TD
Project["Project Data"] --> Report["Report Builder"]
Controls["Control Status"] --> Report
Evidence["Linked Evidence"] --> Report
Findings["Findings and Risk"] --> Report
AI["AI Summaries"] --> Report
Report --> Export["PDF / Export / Share"] Reports combine control status, evidence, findings, risk context, and AI-generated analysis. The user should review AI summaries against source evidence before exporting.
Reliability and Scaling Notes¶
The architecture is designed so high-cost work can scale separately:
- Scale
frontendhorizontally for UI traffic. - Scale
backendhorizontally for API traffic. - Scale
analysis-workerfor queue throughput. - Scale
chunking-workerfor document ingestion throughput. - Scale
ai-service,document-rag-service, andvector-storefor AI workloads. - Scale Prowler workers independently for cloud scanning.
- Keep PostgreSQL, MinIO, Redis, Neo4j, Fleet MySQL, and vector storage on persistent volumes.
For production deployments, place public access behind Kong, restrict database and observability ports, rotate all secrets, configure real TLS certificates, monitor queues, and back up all persistent volumes.
What To Read Next¶
- Data Flow for detailed data movement.
- Security Model for auth, authorization, and evidence isolation.
- Microservices for service boundary patterns.
- Deployment for environment and release guidance.
- Monitoring for operational dashboards.