# nithish34/central-os-brain architecture

> Architecture diagram of the GitHub repository nithish34/central-os-brain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nithish34/central-os-brain
- Repository: https://github.com/nithish34/central-os-brain

## Overview

Company Brain OS detects drift between official documents and live company activity, routes conflicts through human review, then records approved remediation actions. The main loop spans connector ingestion, canonical events and pipeline processing, data-backed conflict detection, review, and execution; grounded chat and operational views are supporting capabilities. The graph combines README-documented flow with relationships visible in sampled source. Several worker, endpoint, and service implementations were not sampled, so their detailed call wiring is omitted.

Main entry points: [`fast_api_server/app/services/layer0_execution/action_executor.py`](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer0_execution/action_executor.py) (Action execution), [`frontend/src/App.tsx`](https://github.com/nithish34/central-os-brain/blob/main/frontend/src/App.tsx) (Dashboard SPA), [`fast_api_server/app/events/ingestion.py`](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/events/ingestion.py) (Canonical ingestion), [`fast_api_server/app/core/database.py`](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/core/database.py) (Product data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion"]
  node_connector_management["Connectors"]
  node_webhook_ingestion["Webhook ingestion<br/>[router.py]"]
  node_event_ingestion["Canonical ingestion<br/>[ingestion.py]"]
  node_event_pipeline["Event pipeline<br/>[event_bus.py]"]
  node_background_workers["Background workers"]
end

subgraph group_intelligence["Intelligence &amp; Review"]
  node_conflict_detection["Conflict detection"]
  node_grounded_chat["Grounded chat<br/>[nlp_chat_engine.py]"]
  node_rag_retrieval["RAG retrieval<br/>[rag_engine.py]"]
  node_human_review["Conflict review<br/>[conflicts.py]"]
end

subgraph group_execution["Execution"]
  node_policy_checks["Policy checks<br/>[policy_engine.py]"]
  node_action_execution["Action execution<br/>[action_executor.py]"]
  node_github_remediation["GitHub remediation<br/>[github_service.py]"]
  node_workflow_records[("Workflow records<br/>[workflow.py]")]
  node_audit_records[("Audit records<br/>[audit.py]")]
end

subgraph group_platform["Platform"]
  node_api_application["FastAPI application<br/>[main.py]"]
  node_auth_security["Auth &amp; tenancy<br/>[service.py]"]
  node_relational_data[("Product data<br/>[database.py]")]
end

subgraph group_frontend["Dashboard"]
  node_spa["Dashboard SPA<br/>[App.tsx]"]
  node_api_client["Typed API client<br/>[api.ts]"]
  node_pipeline_view["Pipeline view<br/>[PipelineView.tsx]"]
  node_explore_view["Knowledge explorer<br/>[ExploreView.tsx]"]
end

node_company_sources(("Company sources"))
node_user(("Dashboard user"))

node_company_sources -->|"provide activity"| node_connector_management
node_company_sources -->|"send webhooks"| node_webhook_ingestion
node_connector_management -->|"normalize events"| node_event_ingestion
node_webhook_ingestion -.->|"normalize events"| node_event_ingestion
node_event_ingestion -->|"persist events"| node_relational_data
node_event_ingestion -->|"publish outbox"| node_event_pipeline
node_event_pipeline -->|"dispatch events"| node_background_workers
node_background_workers -.->|"process knowledge"| node_conflict_detection
node_conflict_detection -->|"read and write"| node_relational_data
node_relational_data -->|"supply documents"| node_rag_retrieval
node_relational_data -->|"supply context"| node_grounded_chat
node_rag_retrieval -->|"ground answers"| node_grounded_chat
node_user -->|"use dashboard"| node_spa
node_spa -->|"request data"| node_api_client
node_api_client -->|"call API"| node_api_application
node_api_application -.->|"authorize requests"| node_auth_security
node_api_application -->|"route review"| node_human_review
node_human_review -->|"review conflicts"| node_conflict_detection
node_human_review -->|"check approval"| node_policy_checks
node_policy_checks -->|"authorize actions"| node_action_execution
node_action_execution -->|"create pull requests"| node_github_remediation
node_action_execution -->|"record workflows"| node_workflow_records
node_action_execution -->|"write audit trail"| node_audit_records
node_spa -->|"render pipeline"| node_pipeline_view
node_spa -->|"render knowledge"| node_explore_view
node_pipeline_view -->|"fetch pipeline"| node_api_client

click node_connector_management "https://github.com/nithish34/central-os-brain/tree/main/fast_api_server/app/integrations"
click node_webhook_ingestion "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/ingestion/router.py"
click node_event_ingestion "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/events/ingestion.py"
click node_event_pipeline "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer3_pipeline/event_bus.py"
click node_background_workers "https://github.com/nithish34/central-os-brain/tree/main/fast_api_server/app/workers"
click node_conflict_detection "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer2_intelligence/conflict_detector.py"
click node_grounded_chat "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer2_intelligence/nlp_chat_engine.py"
click node_rag_retrieval "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer2_intelligence/rag_engine.py"
click node_human_review "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/api/v1/endpoints/conflicts.py"
click node_policy_checks "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer0_execution/policy_engine.py"
click node_action_execution "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer0_execution/action_executor.py"
click node_github_remediation "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/github_service.py"
click node_workflow_records "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/models/workflow.py"
click node_audit_records "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/models/audit.py"
click node_api_application "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/main.py"
click node_auth_security "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/auth/service.py"
click node_relational_data "https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/core/database.py"
click node_spa "https://github.com/nithish34/central-os-brain/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/nithish34/central-os-brain/blob/main/frontend/src/services/api.ts"
click node_pipeline_view "https://github.com/nithish34/central-os-brain/blob/main/frontend/src/components/views/PipelineView.tsx"
click node_explore_view "https://github.com/nithish34/central-os-brain/blob/main/frontend/src/components/views/ExploreView.tsx"

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_connector_management,node_webhook_ingestion,node_event_ingestion,node_event_pipeline,node_background_workers,node_user toneBlue
class node_conflict_detection,node_grounded_chat,node_rag_retrieval,node_human_review toneAmber
class node_policy_checks,node_action_execution,node_github_remediation,node_workflow_records,node_audit_records toneMint
class node_api_application,node_auth_security,node_relational_data toneRose
class node_spa,node_api_client,node_pipeline_view,node_explore_view,node_company_sources toneIndigo
```

## Components

### Ingestion

- [Connectors](https://github.com/nithish34/central-os-brain/tree/main/fast_api_server/app/integrations): `fast_api_server/app/integrations`
- [Webhook ingestion](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/ingestion/router.py): `fast_api_server/app/ingestion/router.py`
- [Canonical ingestion](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/events/ingestion.py): `fast_api_server/app/events/ingestion.py`
- [Event pipeline](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer3_pipeline/event_bus.py): `fast_api_server/app/services/layer3_pipeline/event_bus.py`
- [Background workers](https://github.com/nithish34/central-os-brain/tree/main/fast_api_server/app/workers): `fast_api_server/app/workers`

### Intelligence & Review

- [Conflict detection](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer2_intelligence/conflict_detector.py): `fast_api_server/app/services/layer2_intelligence/conflict_detector.py`
- [Grounded chat](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer2_intelligence/nlp_chat_engine.py): `fast_api_server/app/services/layer2_intelligence/nlp_chat_engine.py`
- [RAG retrieval](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer2_intelligence/rag_engine.py): `fast_api_server/app/services/layer2_intelligence/rag_engine.py`
- [Conflict review](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/api/v1/endpoints/conflicts.py): `fast_api_server/app/api/v1/endpoints/conflicts.py`

### Execution

- [Policy checks](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer0_execution/policy_engine.py): `fast_api_server/app/services/layer0_execution/policy_engine.py`
- [Action execution](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/layer0_execution/action_executor.py): `fast_api_server/app/services/layer0_execution/action_executor.py`
- [GitHub remediation](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/services/github_service.py): `fast_api_server/app/services/github_service.py`
- [Workflow records](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/models/workflow.py): `fast_api_server/app/models/workflow.py`
- [Audit records](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/models/audit.py): `fast_api_server/app/models/audit.py`

### Platform

- [FastAPI application](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/main.py): `fast_api_server/app/main.py`
- [Auth & tenancy](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/auth/service.py): `fast_api_server/app/auth/service.py`
- [Product data](https://github.com/nithish34/central-os-brain/blob/main/fast_api_server/app/core/database.py): `fast_api_server/app/core/database.py`

### Dashboard

- [Dashboard SPA](https://github.com/nithish34/central-os-brain/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Typed API client](https://github.com/nithish34/central-os-brain/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Pipeline view](https://github.com/nithish34/central-os-brain/blob/main/frontend/src/components/views/PipelineView.tsx): `frontend/src/components/views/PipelineView.tsx`
- [Knowledge explorer](https://github.com/nithish34/central-os-brain/blob/main/frontend/src/components/views/ExploreView.tsx): `frontend/src/components/views/ExploreView.tsx`

### Other components

- **Company sources**
- **Dashboard user**

## Connections

- Company sources → Connectors: provide activity (evidence: `README.md`)
- Company sources → Webhook ingestion: send webhooks (evidence: `README.md`)
- Connectors → Canonical ingestion: normalize events (evidence: `fast_api_server/app/integrations/router.py`)
- Webhook ingestion → Canonical ingestion: normalize events
- Canonical ingestion → Product data: persist events (evidence: `fast_api_server/app/events/ingestion.py`)
- Canonical ingestion → Event pipeline: publish outbox (evidence: `README.md`)
- Event pipeline → Background workers: dispatch events (evidence: `README.md`)
- Background workers → Conflict detection: process knowledge
- Conflict detection → Product data: read and write (evidence: `README.md`)
- Product data → RAG retrieval: supply documents (evidence: `fast_api_server/app/services/layer2_intelligence/rag_engine.py`)
- Product data → Grounded chat: supply context (evidence: `fast_api_server/app/services/layer2_intelligence/nlp_chat_engine.py`)
- RAG retrieval → Grounded chat: ground answers (evidence: `fast_api_server/app/services/layer2_intelligence/nlp_chat_engine.py`)
- Dashboard user → Dashboard SPA: use dashboard (evidence: `README.md`)
- Dashboard SPA → Typed API client: request data (evidence: `frontend/src/App.tsx`)
- Typed API client → FastAPI application: call API (evidence: `README.md`)
- FastAPI application → Auth & tenancy: authorize requests
- FastAPI application → Conflict review: route review (evidence: `fast_api_server/app/main.py`)
- Conflict review → Conflict detection: review conflicts (evidence: `README.md`)
- Conflict review → Policy checks: check approval (evidence: `README.md`)
- Policy checks → Action execution: authorize actions (evidence: `README.md`)
- Action execution → GitHub remediation: create pull requests (evidence: `README.md`)
- Action execution → Workflow records: record workflows (evidence: `README.md`)
- Action execution → Audit records: write audit trail (evidence: `README.md`)
- Dashboard SPA → Pipeline view: render pipeline (evidence: `frontend/src/App.tsx`)
- Dashboard SPA → Knowledge explorer: render knowledge (evidence: `frontend/src/App.tsx`)
- Pipeline view → Typed API client: fetch pipeline (evidence: `frontend/src/components/views/PipelineView.tsx`)
