# diyamenon/chronicle-ai architecture

> Architecture diagram of the GitHub repository diyamenon/chronicle-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/diyamenon/chronicle-ai
- Repository: https://github.com/diyamenon/chronicle-ai

## Overview

1. **Chronicle is split into three runtime boundaries**: a Slack ingestion process, a Python FastAPI backend, and a browser-facing dashboard. The intent is clear in the repo: Slack captures organizational conversations, the backend persists and reasons over them, and the UI visualizes decisions, metrics, and replayable context.

2. **Slack is the live entry point.** The `slack/` package uses the Slack Bolt Python SDK (`slack/app.py`) with separate handlers for commands and events. `slack/handlers/events/message_event.py` receives message traffic, while `slack/handlers/commands/query_command.py` handles explicit user queries. This is the real-time acquisition layer.

3. **AI decision detection sits inside the Slack layer.** `slack/ai/prompts/decision_detector.py` shows that Chronicle’s first reasoning step is prompt-based classification/extraction from Slack text. That means the bot is not just relaying messages; it is identifying candidate decisions and related context at ingestion time.

4. **The backend is a focused API and service layer.** `backend/main.py` starts the FastAPI app, and `backend/api/routes/` contains route controllers for `metrics` and `decision_replay`. These routes are thin HTTP boundaries; the actual business logic lives in `backend/api/services/`.

5. **Domain logic is separated from transport.** `backend/api/services/metrics.py` and `backend/api/services/decision_replay.py` represent the core application logic for dashboard analytics and replay retrieval. This separation implies the backend is designed as a reusable reasoning engine rather than a route-heavy CRUD app.

6. **Persistence is lightweight and local-first.** The database layer uses SQLAlchemy models in `backend/database/models.py`, Pydantic schemas in `backend/database/schemas/`, and a session module in `backend/database/session.py`. The README says SQLite is the backing store, so the current data boundary is simple and self-contained.

7. **The data model centers on replayable organizational memory.** The schemas include `decision_replay.py` and `health.py`, which suggests two core payload types: decision evidence/history and operational status. That aligns with the product mission of reconstructing “why” a decision was made, not just storing the decision itself.

8. **The frontend is a visualization shell over backend data.** The root `src/` tree contains `App.tsx` plus screens like `DashboardView`, `AnalyticsView`, `DecisionReplayView`, `ExpertFinderView`, `KnowledgeGraphView`, and `SettingsView`. These are not ingestion components; they are consumer views for reviewing and exploring captured organizational knowledge.

9. **The UI likely mixes live API data with demo/mock sources.** `src/services/aiReasoningService.ts`, `src/services/slackAgent.ts`, and `src/services/demoGenerator.ts` indicate the frontend can either call backend-backed reasoning features or generate demo content. `src/data.ts` and the various view components suggest the dashboard is designed to render synthesized insights rather than raw Slack streams.

10. **There is a second, smaller frontend scaffold under `frontend/`.** It contains `frontend/app/layout.tsx` and `frontend/components/ui/card.tsx`, which looks like a Next.js-style or design-system starter. Meanwhile, the root-level `src/`, `index.html`, `vite.config.ts`, and `server.ts` point to a Vite/React app as the active browser runtime. For an architecture diagram, the safest reading is: root SPA is the main client, and `frontend/` is a secondary or in-progress shell.

11. **The repo is intentionally multi-process, not a single deployable unit.** Slack listener, FastAPI backend, and browser client are separate entrypoints with separate runtimes: Python 3.11+ for backend and Slack, Node/TypeScript for the UI. That separation matters because the system’s critical boundary is the event/API handoff between Slack and backend, not a shared in-process application stack.

12. **Docs reinforce the intended architecture.** `docs/architecture/sprint0_architecture.md` and the README describe Chronicle as an enterprise-style foundation for later additions like graph synthesis, ADR generation, and expert discovery. So the current repo is a foundation layer: ingestion, persistence, basic metrics/replay, and visualization, with more advanced reasoning features staged for future sprints.

Main entry points: [`src/App.tsx`](https://github.com/diyamenon/chronicle-ai/blob/main/src/App.tsx) (App shell), [`backend/main.py`](https://github.com/diyamenon/chronicle-ai/blob/main/backend/main.py) (API app), [`backend/api/services/decision_replay.py`](https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/services/decision_replay.py) (Replay service), [`backend/api/services/metrics.py`](https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/services/metrics.py) (Metrics service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_slack["Slack runtime"]
  node_slack_app["Slack app<br/>bolt entrypoint<br/>[app.py]"]
  node_slack_message_event["Message event<br/>event handler<br/>[message_event.py]"]
  node_slack_query_command["Query command<br/>command handler<br/>[query_command.py]"]
  node_slack_decision_detector["Decision detector<br/>prompt classifier"]
end

subgraph group_backend["Backend API"]
  node_backend_main["API app<br/>fastapi entrypoint<br/>[main.py]"]
  node_route_metrics["Metrics route<br/>http route<br/>[metrics.py]"]
  node_route_replay["Replay route<br/>http route<br/>[decision_replay.py]"]
  node_service_metrics["Metrics service<br/>application service<br/>[metrics.py]"]
  node_service_replay["Replay service<br/>application service<br/>[decision_replay.py]"]
  node_db_models[("Models<br/>[models.py]")]
  node_db_session["Session<br/>[session.py]"]
  node_schema_replay["Replay schema<br/>pydantic schema<br/>[decision_replay.py]"]
  node_schema_health["Health schema<br/>pydantic schema<br/>[health.py]"]
  node_backend_config["Config<br/>[config.py]"]
end

subgraph group_ui["Browser UI"]
  node_ui_main["UI entry<br/>react entrypoint<br/>[main.tsx]"]
  node_ui_app["App shell<br/>react shell<br/>[App.tsx]"]
  node_view_dashboard["Dashboard<br/>view<br/>[DashboardView.tsx]"]
  node_view_analytics["Analytics<br/>view<br/>[AnalyticsView.tsx]"]
  node_view_replay["Decision replay<br/>view"]
  node_view_graph["Knowledge graph<br/>view"]
  node_ui_reasoning["Reasoning service<br/>client service"]
  node_ui_demo["Demo generator<br/>client service<br/>[demoGenerator.ts]"]
  node_ui_slack_agent["Slack agent<br/>client service<br/>[slackAgent.ts]"]
end

node_slack_app -->|"registers"| node_slack_message_event
node_slack_app -->|"registers"| node_slack_query_command
node_slack_message_event -->|"classifies"| node_slack_decision_detector
node_slack_message_event -.->|"writes via API"| node_backend_main
node_slack_query_command -.->|"queries via API"| node_backend_main
node_backend_main -->|"mounts"| node_route_metrics
node_backend_main -->|"mounts"| node_route_replay
node_route_metrics -->|"delegates"| node_service_metrics
node_route_replay -->|"delegates"| node_service_replay
node_service_metrics -->|"reads"| node_db_models
node_service_metrics -->|"uses"| node_db_session
node_service_replay -->|"serializes"| node_schema_replay
node_service_replay -->|"reads"| node_db_models
node_service_replay -->|"uses"| node_db_session
node_backend_main -->|"loads"| node_backend_config
node_backend_main -->|"exposes"| node_schema_health
node_ui_main -->|"boots"| node_ui_app
node_ui_app -->|"renders"| node_view_dashboard
node_ui_app -->|"renders"| node_view_analytics
node_ui_app -->|"renders"| node_view_replay
node_ui_app -->|"renders"| node_view_graph
node_view_dashboard -.->|"fetches metrics"| node_service_metrics
node_view_analytics -.->|"fetches metrics"| node_service_metrics
node_view_replay -.->|"fetches replay"| node_service_replay
node_view_graph -.->|"uses"| node_ui_reasoning
node_view_dashboard -.->|"can seed"| node_ui_demo
node_ui_app -.->|"integrates"| node_ui_slack_agent

click node_slack_app "https://github.com/diyamenon/chronicle-ai/blob/main/slack/app.py"
click node_slack_message_event "https://github.com/diyamenon/chronicle-ai/blob/main/slack/handlers/events/message_event.py"
click node_slack_query_command "https://github.com/diyamenon/chronicle-ai/blob/main/slack/handlers/commands/query_command.py"
click node_slack_decision_detector "https://github.com/diyamenon/chronicle-ai/blob/main/slack/ai/prompts/decision_detector.py"
click node_backend_main "https://github.com/diyamenon/chronicle-ai/blob/main/backend/main.py"
click node_route_metrics "https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/routes/metrics.py"
click node_route_replay "https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/routes/decision_replay.py"
click node_service_metrics "https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/services/metrics.py"
click node_service_replay "https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/services/decision_replay.py"
click node_db_models "https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/models.py"
click node_db_session "https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/session.py"
click node_schema_replay "https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/schemas/decision_replay.py"
click node_schema_health "https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/schemas/health.py"
click node_backend_config "https://github.com/diyamenon/chronicle-ai/blob/main/backend/core/config.py"
click node_ui_main "https://github.com/diyamenon/chronicle-ai/blob/main/src/main.tsx"
click node_ui_app "https://github.com/diyamenon/chronicle-ai/blob/main/src/App.tsx"
click node_view_dashboard "https://github.com/diyamenon/chronicle-ai/blob/main/src/components/DashboardView.tsx"
click node_view_analytics "https://github.com/diyamenon/chronicle-ai/blob/main/src/components/AnalyticsView.tsx"
click node_view_replay "https://github.com/diyamenon/chronicle-ai/blob/main/src/components/DecisionReplayView.tsx"
click node_view_graph "https://github.com/diyamenon/chronicle-ai/blob/main/src/components/KnowledgeGraphView.tsx"
click node_ui_reasoning "https://github.com/diyamenon/chronicle-ai/blob/main/src/services/aiReasoningService.ts"
click node_ui_demo "https://github.com/diyamenon/chronicle-ai/blob/main/src/services/demoGenerator.ts"
click node_ui_slack_agent "https://github.com/diyamenon/chronicle-ai/blob/main/src/services/slackAgent.ts"

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_slack_app,node_slack_message_event,node_slack_query_command,node_slack_decision_detector toneBlue
class node_backend_main,node_route_metrics,node_route_replay,node_service_metrics,node_service_replay,node_db_models,node_db_session,node_schema_replay,node_schema_health,node_backend_config toneAmber
class node_ui_main,node_ui_app,node_view_dashboard,node_view_analytics,node_view_replay,node_view_graph,node_ui_reasoning,node_ui_demo,node_ui_slack_agent toneMint
```

## Components

### Slack runtime

Live ingestion and query entry point for organizational conversations.

- [Slack app](https://github.com/diyamenon/chronicle-ai/blob/main/slack/app.py): bolt entrypoint · Slack Bolt application that registers ingestion and command handlers. · `slack/app.py`
- [Message event](https://github.com/diyamenon/chronicle-ai/blob/main/slack/handlers/events/message_event.py): event handler · Receives Slack message traffic for ingestion and downstream reasoning. · `slack/handlers/events/message_event.py`
- [Query command](https://github.com/diyamenon/chronicle-ai/blob/main/slack/handlers/commands/query_command.py): command handler · Handles explicit user queries from Slack. · `slack/handlers/commands/query_command.py`
- [Decision detector](https://github.com/diyamenon/chronicle-ai/blob/main/slack/ai/prompts/decision_detector.py): prompt classifier · Prompt-based extraction/classification for candidate decisions in Slack text. · `slack/ai/prompts/decision_detector.py`

### Backend API

FastAPI boundary, application services, and persistence layer.

- [API app](https://github.com/diyamenon/chronicle-ai/blob/main/backend/main.py): fastapi entrypoint · Starts the FastAPI backend and mounts the HTTP surface. · `backend/main.py`
- [Metrics route](https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/routes/metrics.py): http route · HTTP boundary for dashboard metrics. · `backend/api/routes/metrics.py`
- [Replay route](https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/routes/decision_replay.py): http route · HTTP boundary for decision replay retrieval. · `backend/api/routes/decision_replay.py`
- [Metrics service](https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/services/metrics.py): application service · Computes analytics and dashboard aggregates. · `backend/api/services/metrics.py`
- [Replay service](https://github.com/diyamenon/chronicle-ai/blob/main/backend/api/services/decision_replay.py): application service · Builds replayable decision context and evidence views. · `backend/api/services/decision_replay.py`
- [Models](https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/models.py): sqlalchemy models · Database entities for organizational memory and supporting records. · `backend/database/models.py`
- [Session](https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/session.py): db session · Database session and connection management. · `backend/database/session.py`
- [Replay schema](https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/schemas/decision_replay.py): pydantic schema · Typed payload for decision replay data. · `backend/database/schemas/decision_replay.py`
- [Health schema](https://github.com/diyamenon/chronicle-ai/blob/main/backend/database/schemas/health.py): pydantic schema · Operational status and health payloads. · `backend/database/schemas/health.py`
- [Config](https://github.com/diyamenon/chronicle-ai/blob/main/backend/core/config.py): runtime config · Backend configuration and environment wiring. · `backend/core/config.py`

### Browser UI

Primary dashboard used to explore decisions, analytics, and replayed context.

- [UI entry](https://github.com/diyamenon/chronicle-ai/blob/main/src/main.tsx): react entrypoint · Browser application bootstrap for the dashboard shell. · `src/main.tsx`
- [App shell](https://github.com/diyamenon/chronicle-ai/blob/main/src/App.tsx): react shell · Top-level client composition and navigation shell. · `src/App.tsx`
- [Dashboard](https://github.com/diyamenon/chronicle-ai/blob/main/src/components/DashboardView.tsx): view · Primary overview for metrics and summaries. · `src/components/DashboardView.tsx`
- [Analytics](https://github.com/diyamenon/chronicle-ai/blob/main/src/components/AnalyticsView.tsx): view · Charts and higher-level analytics surface. · `src/components/AnalyticsView.tsx`
- [Decision replay](https://github.com/diyamenon/chronicle-ai/blob/main/src/components/DecisionReplayView.tsx): view · Interactive review of decision context and history. · `src/components/DecisionReplayView.tsx`
- [Knowledge graph](https://github.com/diyamenon/chronicle-ai/blob/main/src/components/KnowledgeGraphView.tsx): view · Exploration surface for synthesized relationships and context. · `src/components/KnowledgeGraphView.tsx`
- [Reasoning service](https://github.com/diyamenon/chronicle-ai/blob/main/src/services/aiReasoningService.ts): client service · Frontend integration for AI-backed reasoning features. · `src/services/aiReasoningService.ts`
- [Demo generator](https://github.com/diyamenon/chronicle-ai/blob/main/src/services/demoGenerator.ts): client service · Generates sample or mock content for the dashboard. · `src/services/demoGenerator.ts`
- [Slack agent](https://github.com/diyamenon/chronicle-ai/blob/main/src/services/slackAgent.ts): client service · Client-side Slack-oriented integration used by the UI. · `src/services/slackAgent.ts`

## Connections

- Slack app → Message event: registers · Slack app wires in the message ingestion handler.
- Slack app → Query command: registers · Slack app wires in the explicit query command handler.
- Message event → Decision detector: classifies · Incoming messages are analyzed for candidate decisions.
- Message event → API app: writes via API · Ingested conversation data is forwarded to the backend boundary.
- Query command → API app: queries via API · Interactive Slack queries are served through the backend.
- API app → Metrics route: mounts · Main app exposes the metrics route.
- API app → Replay route: mounts · Main app exposes the decision replay route.
- Metrics route → Metrics service: delegates · Route logic is kept thin and delegated to a service.
- Replay route → Replay service: delegates · Route logic is kept thin and delegated to a service.
- Metrics service → Models: reads · Metrics are derived from persisted records.
- Metrics service → Session: uses · Service accesses the database through a session boundary.
- Replay service → Replay schema: serializes · Replay service returns typed replay payloads.
- Replay service → Models: reads · Replay context is reconstructed from stored data.
- Replay service → Session: uses · Service accesses persistence through the session boundary.
- API app → Config: loads · Runtime configuration is loaded at startup.
- API app → Health schema: exposes · Backend health payloads support operational checks.
- UI entry → App shell: boots · Browser entrypoint mounts the main app shell.
- App shell → Dashboard: renders · Top-level shell composes the dashboard view.
- App shell → Analytics: renders · Top-level shell composes the analytics view.
- App shell → Decision replay: renders · Top-level shell composes the replay view.
- App shell → Knowledge graph: renders · Top-level shell composes the knowledge graph view.
- Dashboard → Metrics service: fetches metrics · Dashboard consumes analytics from the backend service layer.
- Analytics → Metrics service: fetches metrics · Analytics view is driven by backend metrics.
- Decision replay → Replay service: fetches replay · Replay view consumes backend replay data.
- Knowledge graph → Reasoning service: uses · Graph exploration is augmented by client-side reasoning features.
- Dashboard → Demo generator: can seed · Dashboard can be populated with demo content.
- App shell → Slack agent: integrates · Client app includes Slack-oriented interaction helpers.
