# alok-codes21/civicsync architecture

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

- Interactive diagram: https://gitdiagram.com/alok-codes21/civicsync
- Repository: https://github.com/alok-codes21/civicsync

## Overview

CivicSync is an API-only civic complaint tracking and escalation backend. Citizens submit and track complaints, while authenticated users and officials can add timeline events or change status; deadline sweeps escalate unresolved cases. The API, authentication, complaint handling, and persistence are implemented together in one server file, with sample records and department mappings in a separate seed module. The excerpts omit several routes, so their documented capabilities are shown without assuming internal call relationships.

Main entry points: [`server/index.cjs`](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs) (REST API), [`server/seed.cjs`](https://github.com/alok-codes21/civicsync/blob/main/server/seed.cjs) (Sample data and rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_api_server["REST API<br/>[index.cjs]"]
  node_authentication["Authentication<br/>[index.cjs]"]
  node_login_limits["Login rate limits<br/>[index.cjs]"]
end

subgraph group_workflow["Complaint workflow"]
  node_complaint_intake["Complaint intake<br/>[index.cjs]"]
  node_assignment["Department assignment<br/>[index.cjs]"]
  node_status_updates["Status updates<br/>[index.cjs]"]
  node_timeline["Complaint timeline<br/>[index.cjs]"]
  node_escalation["Auto-escalation<br/>[index.cjs]"]
  node_tracking["Complaint tracking<br/>[index.cjs]"]
  node_public_stats["Public dashboard stats<br/>[index.cjs]"]
end

subgraph group_data["Data and persistence"]
  node_seed_data["Sample data and rules<br/>[seed.cjs]"]
  node_sqlite[("SQLite database<br/>[index.cjs]")]
end

node_citizen(("Citizen"))
node_official(("Official"))

node_citizen -->|"uses API"| node_api_server
node_official -->|"uses API"| node_api_server
node_api_server -->|"routes login"| node_authentication
node_api_server -->|"limits attempts"| node_login_limits
node_api_server -->|"accepts reports"| node_complaint_intake
node_complaint_intake -->|"auto-assigns"| node_assignment
node_complaint_intake -->|"writes complaint"| node_sqlite
node_complaint_intake -->|"writes events"| node_timeline
node_api_server -->|"routes changes"| node_status_updates
node_status_updates -->|"checks user"| node_authentication
node_status_updates -->|"updates status"| node_sqlite
node_status_updates -->|"writes event"| node_timeline
node_api_server -->|"serves lookup"| node_tracking
node_api_server -->|"serves counts"| node_public_stats
node_api_server -->|"sweeps on reads"| node_escalation
node_escalation -->|"updates complaints"| node_sqlite
node_escalation -->|"records escalation"| node_timeline
node_api_server -->|"imports rules"| node_seed_data
node_seed_data -->|"seeds records"| node_sqlite
node_tracking -.->|"reads complaints"| node_sqlite
node_public_stats -.->|"aggregates counts"| node_sqlite

click node_api_server "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_authentication "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_login_limits "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_complaint_intake "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_assignment "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_status_updates "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_timeline "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_escalation "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_tracking "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_public_stats "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"
click node_seed_data "https://github.com/alok-codes21/civicsync/blob/main/server/seed.cjs"
click node_sqlite "https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs"

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_server,node_authentication,node_login_limits toneBlue
class node_complaint_intake,node_assignment,node_status_updates,node_timeline,node_escalation,node_tracking,node_public_stats toneAmber
class node_seed_data,node_sqlite toneMint
class node_citizen,node_official toneIndigo
```

## Components

### API and access

- [REST API](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Authentication](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Login rate limits](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`

### Complaint workflow

- [Complaint intake](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Department assignment](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Status updates](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Complaint timeline](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Auto-escalation](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Complaint tracking](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`
- [Public dashboard stats](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`

### Data and persistence

- [Sample data and rules](https://github.com/alok-codes21/civicsync/blob/main/server/seed.cjs): `server/seed.cjs`
- [SQLite database](https://github.com/alok-codes21/civicsync/blob/main/server/index.cjs): `server/index.cjs`

### Other components

- **Citizen**
- **Official**

## Connections

- Citizen → REST API: uses API (evidence: `README.md`)
- Official → REST API: uses API (evidence: `README.md`)
- REST API → Authentication: routes login (evidence: `server/index.cjs`)
- REST API → Login rate limits: limits attempts (evidence: `server/index.cjs`)
- REST API → Complaint intake: accepts reports (evidence: `README.md`)
- Complaint intake → Department assignment: auto-assigns (evidence: `README.md`)
- Complaint intake → SQLite database: writes complaint (evidence: `server/index.cjs`)
- Complaint intake → Complaint timeline: writes events (evidence: `server/index.cjs`)
- REST API → Status updates: routes changes (evidence: `server/index.cjs`)
- Status updates → Authentication: checks user (evidence: `server/index.cjs`)
- Status updates → SQLite database: updates status (evidence: `server/index.cjs`)
- Status updates → Complaint timeline: writes event (evidence: `server/index.cjs`)
- REST API → Complaint tracking: serves lookup (evidence: `README.md`)
- REST API → Public dashboard stats: serves counts (evidence: `README.md`)
- REST API → Auto-escalation: sweeps on reads (evidence: `README.md`)
- Auto-escalation → SQLite database: updates complaints (evidence: `server/index.cjs`)
- Auto-escalation → Complaint timeline: records escalation (evidence: `server/index.cjs`)
- REST API → Sample data and rules: imports rules (evidence: `server/index.cjs`)
- Sample data and rules → SQLite database: seeds records (evidence: `server/index.cjs`)
- Complaint tracking → SQLite database: reads complaints (evidence: `server/index.cjs`)
- Public dashboard stats → SQLite database: aggregates counts (evidence: `server/index.cjs`)
