# badrinathantv/khronos-cloud architecture

> Architecture diagram of the GitHub repository badrinathantv/khronos-cloud, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/badrinathantv/khronos-cloud
- Repository: https://github.com/badrinathantv/khronos-cloud

## Overview

#### Purpose and entry points
Khronos Cloud is a multi-tenant workflow automation platform: users create tenants and workflows, publish versioned events, and execute matching workflow actions asynchronously. The main runnable stack is `docker-compose.yml`. Client entry points are the React SPA at `frontend/src/main.jsx` and API gateway at `backend/gateway/src/main.py`.

#### Client and API boundary
The SPA handles authentication, tenant context, workflow design, and execution monitoring. It sends JWT-bearing HTTP requests through a single gateway boundary rather than addressing backend services directly.
- `frontend/src/App.jsx`
- `frontend/src/services/api.js`
- `backend/gateway/src/api/routes/auth.py`
- `backend/gateway/src/api/routes/workflows.py`
- `backend/gateway/src/services/proxy.py`

#### Gateway orchestration
The FastAPI gateway is the external backend entry point. It validates identity and tenant access over gRPC, then reverse-proxies workflow and event requests to their owning services. This separates public HTTP routing from control-plane authorization.
- `backend/gateway/src/main.py`
- `backend/gateway/src/grpc_clients/auth_client.py`
- `backend/gateway/src/grpc_clients/tenant_client.py`
- `shared/protos/auth.proto`
- `shared/protos/tenant.proto`

#### Identity and tenancy control plane
Auth owns user accounts, JWT/security behavior, and token verification. Tenant owns workspace records and membership/access checks. Both expose REST APIs plus gRPC servers for gateway-side authorization and persist through their service database layers; migrations exist independently per service.
- `backend/auth/src/api/routes/auth.py`
- `backend/auth/src/grpc_server/server.py`
- `backend/auth/src/models/user.py`
- `backend/tenant/src/api/routes/tenants.py`
- `backend/tenant/src/grpc_server/server.py`
- `backend/tenant/src/models/tenant.py`

#### Workflow definition, execution, and search
The workflow service owns workflow and execution APIs, persistence, and the execution engine. Its consumer receives broker events, resolves applicable work, and the executor runs configured actions such as logging and HTTP calls. Execution logs are indexed through the OpenSearch integration for search-oriented APIs.
- `backend/workflow/src/api/routes/workflows.py`
- `backend/workflow/src/api/routes/executions.py`
- `backend/workflow/src/engine/consumer.py`
- `backend/workflow/src/engine/executor.py`
- `backend/workflow/src/engine/actions.py`
- `backend/workflow/src/core/opensearch.py`

#### Event ingestion and asynchronous pipeline
The event-bus service is the event publication boundary: it validates incoming event schemas, maps event types/versions, and publishes messages to Kafka. Kafka decouples external event submission from workflow execution; the workflow background consumer subscribes and triggers execution rather than executing in the request path.
- `backend/event-bus/src/api/routes/publish.py`
- `backend/event-bus/src/api/routes/validate.py`
- `backend/event-bus/src/registry/mapper.py`
- `backend/event-bus/src/core/producer.py`
- `backend/event-bus/src/core/kafka.py`

#### Runtime infrastructure and observability
Application services are containerized individually and orchestrated with Docker Compose. PostgreSQL is the transactional store used by auth, tenant, and workflow services; Kafka transports events; OpenSearch stores execution logs. Redis is provisioned by the stack, while Jaeger receives OpenTelemetry traces emitted from service telemetry modules.
- `docker-compose.yml`
- `backend/auth/Dockerfile`
- `backend/workflow/Dockerfile`
- `backend/gateway/src/core/telemetry.py`
- `backend/event-bus/src/core/telemetry.py`

Main entry points: [`backend/gateway/src/main.py`](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/main.py) (FastAPI gateway), [`backend/event-bus/src/api/routes/publish.py`](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/event-bus/src/api/routes/publish.py) (Event bus API), [`backend/gateway/src/grpc_clients/auth_client.py`](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/grpc_clients/auth_client.py) (gRPC auth clients), [`backend/gateway/src/services/proxy.py`](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/services/proxy.py) (Service proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_spa["React SPA<br/>frontend<br/>[App.jsx]"]
  node_client_api["Gateway API client<br/>HTTP client<br/>[api.js]"]
end

subgraph group_gateway["Gateway"]
  node_api_gateway["FastAPI gateway<br/>public API<br/>[main.py]"]
  node_grpc_authorization["gRPC auth clients<br/>authorization client<br/>[auth_client.py]"]
  node_service_proxy["Service proxy<br/>reverse proxy<br/>[proxy.py]"]
end

subgraph group_control["Identity &amp; tenancy"]
  node_auth_service["Auth service<br/>identity service<br/>[auth.py]"]
  node_auth_grpc["Auth gRPC server<br/>[server.py]"]
  node_tenant_service["Tenant service<br/>tenancy service<br/>[tenants.py]"]
  node_tenant_grpc["Tenant gRPC server<br/>[server.py]"]
end

subgraph group_workflow["Workflow execution"]
  node_workflow_api["Workflow API<br/>workflow service<br/>[workflows.py]"]
  node_workflow_consumer["Workflow consumer<br/>background consumer<br/>[consumer.py]"]
  node_workflow_executor["Action executor<br/>execution engine<br/>[executor.py]"]
end

subgraph group_events["Event pipeline"]
  node_event_bus["Event bus API<br/>event ingestion service<br/>[publish.py]"]
  node_event_mapper["Event mapper<br/>schema registry<br/>[mapper.py]"]
end

subgraph group_runtime["Runtime infrastructure"]
  node_kafka["Kafka<br/>event broker<br/>[docker-compose.yml]"]
  node_postgres[("PostgreSQL<br/>transactional database<br/>[docker-compose.yml]")]
  node_opensearch[("OpenSearch<br/>log index<br/>[docker-compose.yml]")]
  node_jaeger["Jaeger<br/>trace collector<br/>[docker-compose.yml]"]
  node_compose{{"Docker Compose<br/>stack orchestrator<br/>[docker-compose.yml]"}}
end

node_spa -->|"uses"| node_client_api
node_client_api -->|"JWT HTTP"| node_api_gateway
node_api_gateway -->|"authorizes"| node_grpc_authorization
node_grpc_authorization -->|"identity check"| node_auth_grpc
node_grpc_authorization -->|"tenant access check"| node_tenant_grpc
node_auth_grpc -->|"serves auth state"| node_auth_service
node_tenant_grpc -->|"serves tenant state"| node_tenant_service
node_api_gateway -->|"delegates"| node_service_proxy
node_service_proxy -->|"workflow requests"| node_workflow_api
node_service_proxy -->|"event requests"| node_event_bus
node_event_bus -->|"validates and maps"| node_event_mapper
node_event_bus -->|"publishes"| node_kafka
node_kafka -->|"subscribes"| node_workflow_consumer
node_workflow_consumer -->|"triggers"| node_workflow_executor
node_auth_service -->|"persists"| node_postgres
node_tenant_service -->|"persists"| node_postgres
node_workflow_api -->|"persists definitions and executions"| node_postgres
node_workflow_executor -->|"indexes execution logs"| node_opensearch
node_api_gateway -.->|"emits traces"| node_jaeger
node_event_bus -.->|"emits traces"| node_jaeger
node_compose -.->|"orchestrates"| node_api_gateway
node_compose -.->|"provisions"| node_kafka

click node_spa "https://github.com/badrinathantv/khronos-cloud/blob/main/frontend/src/App.jsx"
click node_client_api "https://github.com/badrinathantv/khronos-cloud/blob/main/frontend/src/services/api.js"
click node_api_gateway "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/main.py"
click node_grpc_authorization "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/grpc_clients/auth_client.py"
click node_service_proxy "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/services/proxy.py"
click node_auth_service "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/auth/src/api/routes/auth.py"
click node_auth_grpc "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/auth/src/grpc_server/server.py"
click node_tenant_service "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/tenant/src/api/routes/tenants.py"
click node_tenant_grpc "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/tenant/src/grpc_server/server.py"
click node_workflow_api "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/workflow/src/api/routes/workflows.py"
click node_workflow_consumer "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/workflow/src/engine/consumer.py"
click node_workflow_executor "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/workflow/src/engine/executor.py"
click node_event_bus "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/event-bus/src/api/routes/publish.py"
click node_event_mapper "https://github.com/badrinathantv/khronos-cloud/blob/main/backend/event-bus/src/registry/mapper.py"
click node_kafka "https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml"
click node_postgres "https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml"
click node_opensearch "https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml"
click node_jaeger "https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml"
click node_compose "https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_spa,node_client_api toneBlue
class node_api_gateway,node_grpc_authorization,node_service_proxy toneAmber
class node_auth_service,node_auth_grpc,node_tenant_service,node_tenant_grpc toneMint
class node_workflow_api,node_workflow_consumer,node_workflow_executor toneRose
class node_event_bus,node_event_mapper toneIndigo
class node_kafka,node_postgres,node_opensearch,node_jaeger,node_compose toneTeal
```

## Components

### Client

- [React SPA](https://github.com/badrinathantv/khronos-cloud/blob/main/frontend/src/App.jsx): frontend · Authentication, tenant context, workflow design, and monitoring UI. · `frontend/src/App.jsx`
- [Gateway API client](https://github.com/badrinathantv/khronos-cloud/blob/main/frontend/src/services/api.js): HTTP client · Single JWT-bearing backend access boundary. · `frontend/src/services/api.js`

### Gateway

- [FastAPI gateway](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/main.py): public API · Public HTTP routing and control-plane authorization boundary. · `backend/gateway/src/main.py`
- [gRPC auth clients](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/grpc_clients/auth_client.py): authorization client · Validates identity and tenant access before proxying. · `backend/gateway/src/grpc_clients/auth_client.py`
- [Service proxy](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/gateway/src/services/proxy.py): reverse proxy · Routes workflow and event requests to owning services. · `backend/gateway/src/services/proxy.py`

### Identity & tenancy

- [Auth service](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/auth/src/api/routes/auth.py): identity service · Owns accounts, JWTs, and token verification. · `backend/auth/src/api/routes/auth.py`
- [Auth gRPC server](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/auth/src/grpc_server/server.py): gRPC server · `backend/auth/src/grpc_server/server.py`
- [Tenant service](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/tenant/src/api/routes/tenants.py): tenancy service · Owns workspaces, memberships, and access checks. · `backend/tenant/src/api/routes/tenants.py`
- [Tenant gRPC server](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/tenant/src/grpc_server/server.py): gRPC server · `backend/tenant/src/grpc_server/server.py`

### Workflow execution

- [Workflow API](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/workflow/src/api/routes/workflows.py): workflow service · Owns workflow definitions and execution APIs. · `backend/workflow/src/api/routes/workflows.py`
- [Workflow consumer](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/workflow/src/engine/consumer.py): background consumer · Resolves applicable workflow work from broker events. · `backend/workflow/src/engine/consumer.py`
- [Action executor](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/workflow/src/engine/executor.py): execution engine · Runs configured logging and HTTP actions. · `backend/workflow/src/engine/executor.py`

### Event pipeline

- [Event bus API](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/event-bus/src/api/routes/publish.py): event ingestion service · Validates, maps, and publishes versioned events. · `backend/event-bus/src/api/routes/publish.py`
- [Event mapper](https://github.com/badrinathantv/khronos-cloud/blob/main/backend/event-bus/src/registry/mapper.py): schema registry · Maps event types and versions. · `backend/event-bus/src/registry/mapper.py`

### Runtime infrastructure

- [Kafka](https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml): event broker · Decouples publication from workflow execution. · `docker-compose.yml`
- [PostgreSQL](https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml): transactional database · Service persistence for auth, tenant, and workflow data. · `docker-compose.yml`
- [OpenSearch](https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml): log index · Searchable execution logs. · `docker-compose.yml`
- [Jaeger](https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml): trace collector · Receives OpenTelemetry traces. · `docker-compose.yml`
- [Docker Compose](https://github.com/badrinathantv/khronos-cloud/blob/main/docker-compose.yml): stack orchestrator · Runs the containerized application stack and infrastructure. · `docker-compose.yml`

## Connections

- React SPA → Gateway API client: uses
- Gateway API client → FastAPI gateway: JWT HTTP
- FastAPI gateway → gRPC auth clients: authorizes
- gRPC auth clients → Auth gRPC server: identity check
- gRPC auth clients → Tenant gRPC server: tenant access check
- Auth gRPC server → Auth service: serves auth state
- Tenant gRPC server → Tenant service: serves tenant state
- FastAPI gateway → Service proxy: delegates
- Service proxy → Workflow API: workflow requests
- Service proxy → Event bus API: event requests
- Event bus API → Event mapper: validates and maps
- Event bus API → Kafka: publishes
- Kafka → Workflow consumer: subscribes
- Workflow consumer → Action executor: triggers
- Auth service → PostgreSQL: persists
- Tenant service → PostgreSQL: persists
- Workflow API → PostgreSQL: persists definitions and executions
- Action executor → OpenSearch: indexes execution logs
- FastAPI gateway → Jaeger: emits traces
- Event bus API → Jaeger: emits traces
- Docker Compose → FastAPI gateway: orchestrates
- Docker Compose → Kafka: provisions
