# thealiceiris/incident_replay_system architecture

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

- Interactive diagram: https://gitdiagram.com/thealiceiris/incident_replay_system
- Repository: https://github.com/thealiceiris/incident_replay_system

## Overview

Incident Replay System is a FastAPI service for collecting incident events and reconstructing ordered timelines, including trace-wide replay. Service clients submit incidents and events; the API validates and handles them through the ingestion router, which writes synchronously to PostgreSQL and supports deduplication. Responders retrieve incident or trace timelines through the replay router, ordered by event time. A feature flag optionally enables strict incident-status validation. The README also documents Terraform-based cloud infrastructure and canary delivery, which are deployment concerns rather than runtime product components; source excerpts do not establish their runtime connections.ёж

Main entry points: [`src/backend/ingestion/router.py`](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/ingestion/router.py) (Ingestion routes), [`src/backend/replay/router.py`](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/replay/router.py) (Replay routes), [`src/backend/main.py`](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/main.py) (FastAPI app), [`src/backend/database.py`](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/database.py) (Database sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API service"]
  node_api_app["FastAPI app<br/>[main.py]"]
end

subgraph group_ingest["Ingestion"]
  node_ingestion["Ingestion routes<br/>[router.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_replay["Timeline replay"]
  node_replay["Replay routes<br/>[router.py]"]
end

subgraph group_state["Persistence and flags"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_data_models["Incident and event models<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
  node_feature_flags["Flag client and statuses<br/>[flags.py]"]
end

node_service_clients(("Service clients"))
node_responders(("SRE responders"))
node_flagd["flagd provider"]

node_service_clients -->|"submit events"| node_api_app
node_responders -->|"request timelines"| node_api_app
node_api_app -->|"routes requests"| node_ingestion
node_api_app -->|"routes requests"| node_replay
node_ingestion -->|"validates and returns"| node_schemas
node_replay -->|"returns timelines"| node_schemas
node_ingestion -->|"uses sessions"| node_db_session
node_ingestion -->|"queries and writes"| node_data_models
node_ingestion -->|"checks status flag"| node_feature_flags
node_replay -->|"uses sessions"| node_db_session
node_replay -->|"queries events"| node_data_models
node_db_session -->|"opens sessions"| node_postgres
node_data_models -->|"stored as tables"| node_postgres
node_feature_flags -->|"configures provider"| node_flagd

click node_api_app "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/main.py"
click node_ingestion "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/ingestion/router.py"
click node_schemas "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/schemas.py"
click node_replay "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/replay/router.py"
click node_db_session "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/database.py"
click node_data_models "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/models.py"
click node_feature_flags "https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/flags.py"

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_api_app,node_service_clients toneBlue
class node_ingestion,node_schemas toneAmber
class node_replay toneMint
class node_db_session,node_data_models,node_postgres,node_feature_flags toneRose
class node_responders,node_flagd toneIndigo
```

## Components

### API service

- [FastAPI app](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/main.py): `src/backend/main.py`

### Ingestion

- [Ingestion routes](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/ingestion/router.py): `src/backend/ingestion/router.py`
- [Request and response schemas](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/schemas.py): `src/backend/schemas.py`

### Timeline replay

- [Replay routes](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/replay/router.py): `src/backend/replay/router.py`

### Persistence and flags

- [Database sessions](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/database.py): `src/backend/database.py`
- [Incident and event models](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/models.py): `src/backend/models.py`
- **PostgreSQL**
- [Flag client and statuses](https://github.com/thealiceiris/incident_replay_system/blob/main/src/backend/flags.py): `src/backend/flags.py`

### Other components

- **Service clients**
- **SRE responders**
- **flagd provider**

## Connections

- Service clients → FastAPI app: submit events (evidence: `README.md`)
- SRE responders → FastAPI app: request timelines (evidence: `README.md`)
- FastAPI app → Ingestion routes: routes requests (evidence: `src/backend/main.py`)
- FastAPI app → Replay routes: routes requests (evidence: `src/backend/main.py`)
- Ingestion routes → Request and response schemas: validates and returns (evidence: `src/backend/ingestion/router.py`)
- Replay routes → Request and response schemas: returns timelines (evidence: `src/backend/replay/router.py`)
- Ingestion routes → Database sessions: uses sessions (evidence: `src/backend/ingestion/router.py`)
- Ingestion routes → Incident and event models: queries and writes (evidence: `src/backend/ingestion/router.py`)
- Ingestion routes → Flag client and statuses: checks status flag (evidence: `src/backend/ingestion/router.py`)
- Replay routes → Database sessions: uses sessions (evidence: `src/backend/replay/router.py`)
- Replay routes → Incident and event models: queries events (evidence: `src/backend/replay/router.py`)
- Database sessions → PostgreSQL: opens sessions (evidence: `README.md`)
- Incident and event models → PostgreSQL: stored as tables (evidence: `README.md`)
- Flag client and statuses → flagd provider: configures provider (evidence: `src/backend/flags.py`)
