# xoaicatchu/todolist-backend architecture

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

- Interactive diagram: https://gitdiagram.com/xoaicatchu/todolist-backend
- Repository: https://github.com/xoaicatchu/todolist-backend

## Overview

TodoSync is an offline-first synchronization backend: clients push todo events, the service applies them, and clients pull updated state; SignalR notifies clients to sync. The README describes the current in-memory event store with JSON snapshot recovery. The tree also contains a database-backed V2 implementation with tenant-aware services, repositories, and event processing. The excerpts show the current API and parts of the V2 service and persistence layer; connections within unsampled V2 components are included only where the source index names them.

Main entry points: [`TodoSync.Api/Data/TodoSyncDbContext.cs`](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/TodoSyncDbContext.cs) (EF database context), [`TodoSync.Api/Program_V2.cs`](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Program_V2.cs) (V2 API bootstrap), [`TodoSync.Api/Program.cs`](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Program.cs) (Sync API routes), [`TodoSync.Api/Services/EventStoreService.cs`](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/EventStoreService.cs) (Event store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and realtime"]
  node_program["Sync API routes<br/>[Program.cs]"]
  node_hub["SignalR hub<br/>[SyncHub.cs]"]
end

subgraph group_memory["In-memory sync"]
  node_eventstore["Event store"]
  node_snapshot["JSON snapshot"]
end

subgraph group_v2["Database sync"]
  node_v2program["V2 API bootstrap<br/>[Program_V2.cs]"]
  node_syncservice["Todo sync service<br/>[TodoSyncService.cs]"]
  node_consumer["Sync event consumer"]
  node_todo_repo["Todo repository<br/>[TodoRepository.cs]"]
  node_change_repo["Change repository"]
  node_processed_repo["Processed-event repository"]
  node_dbcontext["EF database context"]
  node_database[("Sync database")]
  node_todo_entity["Todo records<br/>[TodoEntity.cs]"]
  node_change_entity["Change records"]
  node_processed_entity["Processed events"]
end

subgraph group_contracts["Sync contracts"]
  node_eventmodel["Todo events<br/>[TodoEvent.cs]"]
  node_todmodel["Todo items<br/>[TodoItem.cs]"]
  node_syncdtos["Sync request/response<br/>[SyncDtos.cs]"]
end

node_clients(("Todo clients"))

node_clients -->|"push / pull"| node_program
node_program -->|"applies and queries"| node_eventstore
node_program -->|"broadcasts changes"| node_hub
node_hub -->|"notifies"| node_clients
node_eventstore -->|"loads / saves"| node_snapshot
node_eventstore -->|"applies events"| node_eventmodel
node_eventstore -->|"stores todo state"| node_todmodel
node_program -->|"accepts / returns"| node_syncdtos
node_clients -.->|"sync requests"| node_v2program
node_v2program -->|"routes to"| node_syncservice
node_v2program -->|"registers"| node_consumer
node_v2program -->|"configures"| node_dbcontext
node_v2program -->|"registers"| node_todo_repo
node_v2program -->|"registers"| node_change_repo
node_v2program -->|"registers"| node_processed_repo
node_syncservice -->|"reads / writes"| node_todo_repo
node_syncservice -->|"records / queries changes"| node_change_repo
node_syncservice -.->|"deduplicates events"| node_processed_repo
node_todo_repo -->|"queries todos"| node_dbcontext
node_change_repo -->|"queries changes"| node_dbcontext
node_processed_repo -->|"tracks processed events"| node_dbcontext
node_dbcontext -->|"maps"| node_todo_entity
node_dbcontext -->|"maps"| node_change_entity
node_dbcontext -->|"maps"| node_processed_entity
node_dbcontext -.->|"persists records"| node_database
node_consumer -->|"uses realtime hub"| node_hub

click node_program "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Program.cs"
click node_hub "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Hubs/SyncHub.cs"
click node_eventstore "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/EventStoreService.cs"
click node_snapshot "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/EventStoreService.cs"
click node_eventmodel "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Models/TodoEvent.cs"
click node_todmodel "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Models/TodoItem.cs"
click node_syncdtos "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Models/SyncDtos.cs"
click node_v2program "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Program_V2.cs"
click node_syncservice "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/TodoSyncService.cs"
click node_consumer "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/SyncEventConsumer.cs"
click node_todo_repo "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Repositories/TodoRepository.cs"
click node_change_repo "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Repositories/SyncChangeRepository.cs"
click node_processed_repo "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Repositories/ProcessedEventRepository.cs"
click node_dbcontext "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/TodoSyncDbContext.cs"
click node_todo_entity "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Entities/TodoEntity.cs"
click node_change_entity "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Entities/SyncChangeEntity.cs"
click node_processed_entity "https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Entities/ProcessedEventEntity.cs"

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_program,node_hub,node_clients toneBlue
class node_eventstore,node_snapshot toneAmber
class node_v2program,node_syncservice,node_consumer,node_todo_repo,node_change_repo,node_processed_repo,node_dbcontext,node_database,node_todo_entity,node_change_entity,node_processed_entity toneMint
class node_eventmodel,node_todmodel,node_syncdtos toneRose
```

## Components

### API and realtime

- [Sync API routes](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Program.cs): `TodoSync.Api/Program.cs`
- [SignalR hub](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Hubs/SyncHub.cs): `TodoSync.Api/Hubs/SyncHub.cs`

### In-memory sync

- [Event store](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/EventStoreService.cs): `TodoSync.Api/Services/EventStoreService.cs`
- [JSON snapshot](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/EventStoreService.cs): `TodoSync.Api/Services/EventStoreService.cs`

### Database sync

- [V2 API bootstrap](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Program_V2.cs): `TodoSync.Api/Program_V2.cs`
- [Todo sync service](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/TodoSyncService.cs): `TodoSync.Api/Services/TodoSyncService.cs`
- [Sync event consumer](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Services/SyncEventConsumer.cs): `TodoSync.Api/Services/SyncEventConsumer.cs`
- [Todo repository](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Repositories/TodoRepository.cs): `TodoSync.Api/Data/Repositories/TodoRepository.cs`
- [Change repository](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Repositories/SyncChangeRepository.cs): `TodoSync.Api/Data/Repositories/SyncChangeRepository.cs`
- [Processed-event repository](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Repositories/ProcessedEventRepository.cs): `TodoSync.Api/Data/Repositories/ProcessedEventRepository.cs`
- [EF database context](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/TodoSyncDbContext.cs): `TodoSync.Api/Data/TodoSyncDbContext.cs`
- **Sync database**
- [Todo records](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Entities/TodoEntity.cs): `TodoSync.Api/Data/Entities/TodoEntity.cs`
- [Change records](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Entities/SyncChangeEntity.cs): `TodoSync.Api/Data/Entities/SyncChangeEntity.cs`
- [Processed events](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Data/Entities/ProcessedEventEntity.cs): `TodoSync.Api/Data/Entities/ProcessedEventEntity.cs`

### Sync contracts

- [Todo events](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Models/TodoEvent.cs): `TodoSync.Api/Models/TodoEvent.cs`
- [Todo items](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Models/TodoItem.cs): `TodoSync.Api/Models/TodoItem.cs`
- [Sync request/response](https://github.com/xoaicatchu/todolist-backend/blob/main/TodoSync.Api/Models/SyncDtos.cs): `TodoSync.Api/Models/SyncDtos.cs`

### Other components

- **Todo clients**

## Connections

- Todo clients → Sync API routes: push / pull (evidence: `README.md`)
- Sync API routes → Event store: applies and queries (evidence: `TodoSync.Api/Program.cs`)
- Sync API routes → SignalR hub: broadcasts changes (evidence: `TodoSync.Api/Program.cs`)
- SignalR hub → Todo clients: notifies (evidence: `README.md`)
- Event store → JSON snapshot: loads / saves (evidence: `TodoSync.Api/Services/EventStoreService.cs`)
- Event store → Todo events: applies events (evidence: `TodoSync.Api/Services/EventStoreService.cs`)
- Event store → Todo items: stores todo state (evidence: `TodoSync.Api/Services/EventStoreService.cs`)
- Sync API routes → Sync request/response: accepts / returns (evidence: `TodoSync.Api/Program.cs`)
- Todo clients → V2 API bootstrap: sync requests
- V2 API bootstrap → Todo sync service: routes to (evidence: `TodoSync.Api/Program_V2.cs`)
- V2 API bootstrap → Sync event consumer: registers (evidence: `TodoSync.Api/Program_V2.cs`)
- V2 API bootstrap → EF database context: configures (evidence: `TodoSync.Api/Program_V2.cs`)
- V2 API bootstrap → Todo repository: registers (evidence: `TodoSync.Api/Program_V2.cs`)
- V2 API bootstrap → Change repository: registers (evidence: `TodoSync.Api/Program_V2.cs`)
- V2 API bootstrap → Processed-event repository: registers (evidence: `TodoSync.Api/Program_V2.cs`)
- Todo sync service → Todo repository: reads / writes (evidence: `TodoSync.Api/Services/TodoSyncService.cs`)
- Todo sync service → Change repository: records / queries changes (evidence: `TodoSync.Api/Services/TodoSyncService.cs`)
- Todo sync service → Processed-event repository: deduplicates events
- Todo repository → EF database context: queries todos (evidence: `TodoSync.Api/Data/Repositories/TodoRepository.cs`)
- Change repository → EF database context: queries changes (evidence: `TodoSync.Api/Data/Repositories/SyncChangeRepository.cs`)
- Processed-event repository → EF database context: tracks processed events (evidence: `TodoSync.Api/Data/Repositories/ProcessedEventRepository.cs`)
- EF database context → Todo records: maps (evidence: `TodoSync.Api/Data/TodoSyncDbContext.cs`)
- EF database context → Change records: maps (evidence: `TodoSync.Api/Data/TodoSyncDbContext.cs`)
- EF database context → Processed events: maps (evidence: `TodoSync.Api/Data/TodoSyncDbContext.cs`)
- EF database context → Sync database: persists records
- Sync event consumer → SignalR hub: uses realtime hub (evidence: `TodoSync.Api/Services/SyncEventConsumer.cs`)
