# yasout141516/shomap architecture

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

- Interactive diagram: https://gitdiagram.com/yasout141516/shomap
- Repository: https://github.com/yasout141516/shomap

## Overview

ShoMap is a community incident reporting and response platform for Bangladesh. Citizens submit reports and photos, the community verifies and tracks incidents, and authorities or moderators review and act on them; map, feed, alerts, watch zones, and SOS support discovery and follow-up. The web app uses shared API/query helpers to reach the Fastify server, whose routes delegate domain work and persist data in SQLite. The README documents these capabilities; unsampled implementations are represented at their exact feature paths, and links are omitted where call ownership is not evidenced.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/yasout141516/shomap/blob/main/apps/web/src/App.tsx) (App routes), [`apps/server/src/routes/public.ts`](https://github.com/yasout141516/shomap/blob/main/apps/server/src/routes/public.ts) (Public workflows), [`apps/web/src/lib/api.ts`](https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/api.ts) (HTTP client), [`apps/server/src/app.ts`](https://github.com/yasout141516/shomap/blob/main/apps/server/src/app.ts) (HTTP and socket app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_web_app["App routes<br/>[App.tsx]"]
  node_report_ui["Incident reporting<br/>[ReportModal.tsx]"]
  node_map_ui["Map and feed<br/>[MapPage.tsx]"]
  node_incident_ui["Incident detail<br/>[IncidentPanel.tsx]"]
  node_dashboard_ui["Community dashboard<br/>[DashboardPage.tsx]"]
  node_alerts_ui["Alerts and SOS<br/>[AlertsPage.tsx]"]
  node_zones_ui["Watch zones<br/>[WatchZonesPage.tsx]"]
  node_authority_ui["Authority console<br/>[AuthorityPage.tsx]"]
  node_admin_ui["Moderation console<br/>[AdminPage.tsx]"]
  node_session_ui["Session and login<br/>[session.ts]"]
  node_web_queries["API queries<br/>[queries.ts]"]
  node_web_actions["User actions<br/>[actions.ts]"]
  node_web_api["HTTP client<br/>[api.ts]"]
end

subgraph group_server["Server workflows"]
  node_server_app["HTTP and socket app<br/>[app.ts]"]
  node_public_routes["Public workflows<br/>[public.ts]"]
  node_staff_routes["Staff workflows<br/>[staff.ts]"]
  node_report_service["Report operations<br/>[reports.ts]"]
  node_query_service["Incident queries<br/>[queries.ts]"]
  node_repository["Incident repository<br/>[repo.ts]"]
  node_auth["Identity and roles<br/>[auth.ts]"]
  node_serializer["Privacy serialization<br/>[incident.ts]"]
  node_realtime["Live updates<br/>[realtime.ts]"]
  node_context["Write coordination<br/>[context.ts]"]
end

subgraph group_data["Data and contracts"]
  node_sqlite[("SQLite database<br/>[client.ts]")]
  node_schema["Database schema<br/>[schema.ts]"]
  node_shared["Shared API rules<br/>[dto.ts]"]
end

node_citizen(("Community members"))
node_authority_user(("Authority staff"))

node_citizen -->|"submits reports"| node_report_ui
node_citizen -->|"explores incidents"| node_map_ui
node_authority_user -->|"reviews queue"| node_authority_ui
node_web_app -->|"routes to"| node_map_ui
node_web_app -->|"routes to"| node_incident_ui
node_web_app -->|"routes to"| node_dashboard_ui
node_web_app -->|"routes to"| node_alerts_ui
node_web_app -->|"routes to"| node_zones_ui
node_web_app -->|"routes to"| node_authority_ui
node_web_app -->|"routes to"| node_admin_ui
node_web_app -.->|"renders"| node_report_ui
node_report_ui -->|"sends report"| node_web_api
node_authority_ui -->|"submits actions"| node_web_api
node_session_ui -->|"calls endpoints"| node_web_api
node_web_queries -->|"fetches data"| node_web_api
node_web_api -->|"requests endpoints"| node_public_routes
node_web_api -.->|"requests staff endpoints"| node_staff_routes
node_server_app -->|"registers routes"| node_public_routes
node_server_app -->|"registers routes"| node_staff_routes
node_server_app -->|"attaches sockets"| node_realtime
node_public_routes -->|"checks identity"| node_auth
node_public_routes -->|"submits reports"| node_report_service
node_public_routes -->|"lists incidents"| node_query_service
node_public_routes -->|"reads incident rows"| node_repository
node_public_routes -->|"reads and writes"| node_sqlite
node_public_routes -->|"serializes responses"| node_serializer
node_context -->|"flushes effects"| node_realtime
node_sqlite -->|"configures tables"| node_schema
node_repository -.->|"accesses records"| node_sqlite
node_realtime -->|"uses incident data"| node_repository
node_shared -.->|"types responses"| node_web_queries

click node_web_app "https://github.com/yasout141516/shomap/blob/main/apps/web/src/App.tsx"
click node_report_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/report/ReportModal.tsx"
click node_map_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/map/MapPage.tsx"
click node_incident_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/incident/IncidentPanel.tsx"
click node_dashboard_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/dashboard/DashboardPage.tsx"
click node_alerts_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/alerts/AlertsPage.tsx"
click node_zones_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/watch-zones/WatchZonesPage.tsx"
click node_authority_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/authority/AuthorityPage.tsx"
click node_admin_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/admin/AdminPage.tsx"
click node_session_ui "https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/session.ts"
click node_web_queries "https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/queries.ts"
click node_web_actions "https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/actions.ts"
click node_web_api "https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/api.ts"
click node_server_app "https://github.com/yasout141516/shomap/blob/main/apps/server/src/app.ts"
click node_public_routes "https://github.com/yasout141516/shomap/blob/main/apps/server/src/routes/public.ts"
click node_staff_routes "https://github.com/yasout141516/shomap/blob/main/apps/server/src/routes/staff.ts"
click node_report_service "https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/reports.ts"
click node_query_service "https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/queries.ts"
click node_repository "https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/repo.ts"
click node_auth "https://github.com/yasout141516/shomap/blob/main/apps/server/src/auth.ts"
click node_serializer "https://github.com/yasout141516/shomap/blob/main/apps/server/src/serializers/incident.ts"
click node_realtime "https://github.com/yasout141516/shomap/blob/main/apps/server/src/realtime.ts"
click node_context "https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/context.ts"
click node_sqlite "https://github.com/yasout141516/shomap/blob/main/apps/server/src/db/client.ts"
click node_schema "https://github.com/yasout141516/shomap/blob/main/apps/server/src/db/schema.ts"
click node_shared "https://github.com/yasout141516/shomap/blob/main/packages/shared/src/dto.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_web_app,node_report_ui,node_map_ui,node_incident_ui,node_dashboard_ui,node_alerts_ui,node_zones_ui,node_authority_ui,node_admin_ui,node_session_ui,node_web_queries,node_web_actions,node_web_api toneBlue
class node_server_app,node_public_routes,node_staff_routes,node_report_service,node_query_service,node_repository,node_auth,node_serializer,node_realtime,node_context toneAmber
class node_sqlite,node_schema,node_shared toneMint
class node_citizen,node_authority_user toneIndigo
```

## Components

### Web experience

- [App routes](https://github.com/yasout141516/shomap/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Incident reporting](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/report/ReportModal.tsx): `apps/web/src/features/report/ReportModal.tsx`
- [Map and feed](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/map/MapPage.tsx): `apps/web/src/features/map/MapPage.tsx`
- [Incident detail](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/incident/IncidentPanel.tsx): `apps/web/src/features/incident/IncidentPanel.tsx`
- [Community dashboard](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/dashboard/DashboardPage.tsx): `apps/web/src/features/dashboard/DashboardPage.tsx`
- [Alerts and SOS](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/alerts/AlertsPage.tsx): `apps/web/src/features/alerts/AlertsPage.tsx`
- [Watch zones](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/watch-zones/WatchZonesPage.tsx): `apps/web/src/features/watch-zones/WatchZonesPage.tsx`
- [Authority console](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/authority/AuthorityPage.tsx): `apps/web/src/features/authority/AuthorityPage.tsx`
- [Moderation console](https://github.com/yasout141516/shomap/blob/main/apps/web/src/features/admin/AdminPage.tsx): `apps/web/src/features/admin/AdminPage.tsx`
- [Session and login](https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/session.ts): `apps/web/src/lib/session.ts`
- [API queries](https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/queries.ts): `apps/web/src/lib/queries.ts`
- [User actions](https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/actions.ts): `apps/web/src/lib/actions.ts`
- [HTTP client](https://github.com/yasout141516/shomap/blob/main/apps/web/src/lib/api.ts): `apps/web/src/lib/api.ts`

### Server workflows

- [HTTP and socket app](https://github.com/yasout141516/shomap/blob/main/apps/server/src/app.ts): `apps/server/src/app.ts`
- [Public workflows](https://github.com/yasout141516/shomap/blob/main/apps/server/src/routes/public.ts): `apps/server/src/routes/public.ts`
- [Staff workflows](https://github.com/yasout141516/shomap/blob/main/apps/server/src/routes/staff.ts): `apps/server/src/routes/staff.ts`
- [Report operations](https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/reports.ts): `apps/server/src/services/reports.ts`
- [Incident queries](https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/queries.ts): `apps/server/src/services/queries.ts`
- [Incident repository](https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/repo.ts): `apps/server/src/services/repo.ts`
- [Identity and roles](https://github.com/yasout141516/shomap/blob/main/apps/server/src/auth.ts): `apps/server/src/auth.ts`
- [Privacy serialization](https://github.com/yasout141516/shomap/blob/main/apps/server/src/serializers/incident.ts): `apps/server/src/serializers/incident.ts`
- [Live updates](https://github.com/yasout141516/shomap/blob/main/apps/server/src/realtime.ts): `apps/server/src/realtime.ts`
- [Write coordination](https://github.com/yasout141516/shomap/blob/main/apps/server/src/services/context.ts): `apps/server/src/services/context.ts`

### Data and contracts

- [SQLite database](https://github.com/yasout141516/shomap/blob/main/apps/server/src/db/client.ts): `apps/server/src/db/client.ts`
- [Database schema](https://github.com/yasout141516/shomap/blob/main/apps/server/src/db/schema.ts): `apps/server/src/db/schema.ts`
- [Shared API rules](https://github.com/yasout141516/shomap/blob/main/packages/shared/src/dto.ts): `packages/shared/src/dto.ts`

### Other components

- **Community members**
- **Authority staff**

## Connections

- Community members → Incident reporting: submits reports (evidence: `README.md`)
- Community members → Map and feed: explores incidents (evidence: `README.md`)
- Authority staff → Authority console: reviews queue (evidence: `apps/web/src/features/authority/AuthorityPage.tsx`)
- App routes → Map and feed: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Incident detail: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Community dashboard: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Alerts and SOS: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Watch zones: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Authority console: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Moderation console: routes to (evidence: `apps/web/src/App.tsx`)
- App routes → Incident reporting: renders
- Incident reporting → HTTP client: sends report (evidence: `apps/web/src/features/report/ReportModal.tsx`)
- Authority console → HTTP client: submits actions (evidence: `apps/web/src/features/authority/AuthorityPage.tsx`)
- Session and login → HTTP client: calls endpoints (evidence: `apps/web/src/lib/session.ts`)
- API queries → HTTP client: fetches data (evidence: `apps/web/src/lib/queries.ts`)
- HTTP client → Public workflows: requests endpoints
- HTTP client → Staff workflows: requests staff endpoints
- HTTP and socket app → Public workflows: registers routes (evidence: `apps/server/src/app.ts`)
- HTTP and socket app → Staff workflows: registers routes (evidence: `apps/server/src/app.ts`)
- HTTP and socket app → Live updates: attaches sockets (evidence: `apps/server/src/app.ts`)
- Public workflows → Identity and roles: checks identity (evidence: `apps/server/src/routes/public.ts`)
- Public workflows → Report operations: submits reports (evidence: `apps/server/src/routes/public.ts`)
- Public workflows → Incident queries: lists incidents (evidence: `apps/server/src/routes/public.ts`)
- Public workflows → Incident repository: reads incident rows (evidence: `apps/server/src/routes/public.ts`)
- Public workflows → SQLite database: reads and writes (evidence: `apps/server/src/routes/public.ts`)
- Public workflows → Privacy serialization: serializes responses (evidence: `apps/server/src/routes/public.ts`)
- Write coordination → Live updates: flushes effects (evidence: `apps/server/src/services/context.ts`)
- SQLite database → Database schema: configures tables (evidence: `apps/server/src/db/client.ts`)
- Incident repository → SQLite database: accesses records
- Live updates → Incident repository: uses incident data (evidence: `apps/server/src/realtime.ts`)
- Shared API rules → API queries: types responses
