# clement-frank/blantyre_city_council architecture

> Architecture diagram of the GitHub repository clement-frank/blantyre_city_council, 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/clement-frank/blantyre_city_council
- Repository: https://github.com/clement-frank/blantyre_city_council

## Overview

Msika is a city-council market-fee platform. Its main workflow is staff or vendor payment activity entering through the web app or payment-provider callbacks, updating payment records and daily revenue, then appearing in operational views and reports; vendors can also receive SMS receipts and reminders. The graph preserves the README’s major operational modules. Some route-to-service wiring and UI data-fetching details were not shown, so uncertain links are omitted or marked dashed.

Main entry points: [`msika-app/app/dashboard/page.tsx`](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/dashboard/page.tsx) (Staff dashboard), [`msika-app/lib/wallet-webhook.ts`](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/wallet-webhook.ts) (Webhook processing), [`msika-app/lib/prisma.ts`](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/prisma.ts) (PostgreSQL data), [`msika-app/app/api/vendors/route.ts`](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/vendors/route.ts) (Vendor registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and administration"]
  node_dashboard_ui["Staff dashboard<br/>[page.tsx]"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_auth_logic["Session and tokens<br/>[session.ts]"]
  node_audit_api["Audit log view<br/>[route.ts]"]
  node_audit_logic["Audit recording<br/>[audit.ts]"]
end

subgraph group_operations["Market operations"]
  node_vendor_api["Vendor registry<br/>[route.ts]"]
  node_geofence["Stall geofencing<br/>[geofence.ts]"]
  node_map_api["Live stall map<br/>[route.ts]"]
  node_market_api["Markets and sections<br/>[route.ts]"]
  node_collectors_api["Collector management<br/>[route.ts]"]
end

subgraph group_payments["Payments and notifications"]
  node_payment_api["Payment recording<br/>[route.ts]"]
  node_pay_page["Vendor payment page<br/>[page.tsx]"]
  node_wallets["Wallet providers"]
  node_webhooks["Wallet callbacks<br/>[route.ts]"]
  node_webhook_processor["Webhook processing<br/>[wallet-webhook.ts]"]
  node_notifications["SMS receipts/reminders<br/>[notify.ts]"]
  node_sms["SMS delivery<br/>[sms.ts]"]
end

subgraph group_insight["Monitoring and reporting"]
  node_dashboard_api["Dashboard metrics<br/>[route.ts]"]
  node_pulse_api["Revenue pulse<br/>[route.ts]"]
  node_reports_api["Daily reports<br/>[route.ts]"]
end

node_staff(("Council staff"))
node_vendors(("Vendors"))
node_database[("PostgreSQL data<br/>[prisma.ts]")]

node_staff -->|"signs in"| node_auth_api
node_auth_api -.->|"uses sessions"| node_auth_logic
node_staff -->|"uses"| node_dashboard_ui
node_dashboard_ui -.->|"manages vendors"| node_vendor_api
node_dashboard_ui -->|"views stalls"| node_map_api
node_vendor_api -->|"checks locations"| node_geofence
node_vendor_api -->|"reads/writes"| node_database
node_dashboard_ui -->|"manages markets"| node_market_api
node_dashboard_ui -->|"manages staff"| node_collectors_api
node_vendors -->|"starts payment"| node_pay_page
node_staff -->|"records cash"| node_payment_api
node_pay_page -.->|"initiates payment"| node_payment_api
node_wallets -->|"sends callbacks"| node_webhooks
node_webhooks -.->|"dispatches"| node_webhook_processor
node_webhook_processor -->|"records payment"| node_database
node_webhook_processor -->|"queues receipt"| node_notifications
node_notifications -->|"sends message"| node_sms
node_webhook_processor -->|"records event"| node_audit_logic
node_payment_api -->|"stores payments"| node_database
node_dashboard_ui -->|"loads metrics"| node_dashboard_api
node_dashboard_ui -->|"views revenue"| node_pulse_api
node_dashboard_ui -->|"requests reports"| node_reports_api
node_dashboard_ui -->|"views audit trail"| node_audit_api
node_audit_api -.->|"reads logs"| node_database

click node_dashboard_ui "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/dashboard/page.tsx"
click node_auth_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/auth/login/route.ts"
click node_auth_logic "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/session.ts"
click node_vendor_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/vendors/route.ts"
click node_geofence "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/geofence.ts"
click node_map_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/map/route.ts"
click node_market_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/markets/route.ts"
click node_collectors_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/collectors/route.ts"
click node_payment_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/payments/route.ts"
click node_pay_page "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/pay/%5BvendorNumber%5D/page.tsx"
click node_webhooks "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/webhook/airtel/route.ts"
click node_webhook_processor "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/wallet-webhook.ts"
click node_notifications "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/notify.ts"
click node_sms "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/sms.ts"
click node_dashboard_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/dashboard/route.ts"
click node_pulse_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/pulse/route.ts"
click node_reports_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/reports/daily/route.ts"
click node_audit_api "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/audit-logs/route.ts"
click node_audit_logic "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/audit.ts"
click node_database "https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/prisma.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_dashboard_ui,node_auth_api,node_auth_logic,node_audit_api,node_audit_logic toneBlue
class node_vendor_api,node_geofence,node_map_api,node_market_api,node_collectors_api,node_database toneAmber
class node_payment_api,node_pay_page,node_wallets,node_webhooks,node_webhook_processor,node_notifications,node_sms toneMint
class node_dashboard_api,node_pulse_api,node_reports_api toneRose
class node_staff,node_vendors toneIndigo
```

## Components

### Access and administration

- [Staff dashboard](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/dashboard/page.tsx): `msika-app/app/dashboard/page.tsx`
- [Authentication API](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/auth/login/route.ts): `msika-app/app/api/auth/login/route.ts`
- [Session and tokens](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/session.ts): `msika-app/lib/session.ts`
- [Audit log view](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/audit-logs/route.ts): `msika-app/app/api/audit-logs/route.ts`
- [Audit recording](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/audit.ts): `msika-app/lib/audit.ts`

### Market operations

- [Vendor registry](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/vendors/route.ts): `msika-app/app/api/vendors/route.ts`
- [Stall geofencing](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/geofence.ts): `msika-app/lib/geofence.ts`
- [Live stall map](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/map/route.ts): `msika-app/app/api/map/route.ts`
- [Markets and sections](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/markets/route.ts): `msika-app/app/api/markets/route.ts`
- [Collector management](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/collectors/route.ts): `msika-app/app/api/collectors/route.ts`

### Payments and notifications

- [Payment recording](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/payments/route.ts): `msika-app/app/api/payments/route.ts`
- [Vendor payment page](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/pay/%5BvendorNumber%5D/page.tsx): `msika-app/app/pay/[vendorNumber]/page.tsx`
- **Wallet providers**
- [Wallet callbacks](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/webhook/airtel/route.ts): `msika-app/app/api/webhook/airtel/route.ts`
- [Webhook processing](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/wallet-webhook.ts): `msika-app/lib/wallet-webhook.ts`
- [SMS receipts/reminders](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/notify.ts): `msika-app/lib/notify.ts`
- [SMS delivery](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/sms.ts): `msika-app/lib/sms.ts`

### Monitoring and reporting

- [Dashboard metrics](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/dashboard/route.ts): `msika-app/app/api/dashboard/route.ts`
- [Revenue pulse](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/pulse/route.ts): `msika-app/app/api/pulse/route.ts`
- [Daily reports](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/app/api/reports/daily/route.ts): `msika-app/app/api/reports/daily/route.ts`

### Other components

- **Council staff**
- **Vendors**
- [PostgreSQL data](https://github.com/clement-frank/blantyre_city_council/blob/main/msika-app/lib/prisma.ts): `msika-app/lib/prisma.ts`

## Connections

- Council staff → Authentication API: signs in (evidence: `README.md`)
- Authentication API → Session and tokens: uses sessions
- Council staff → Staff dashboard: uses (evidence: `README.md`)
- Staff dashboard → Vendor registry: manages vendors
- Staff dashboard → Live stall map: views stalls (evidence: `README.md`)
- Vendor registry → Stall geofencing: checks locations (evidence: `msika-app/app/api/vendors/route.ts`)
- Vendor registry → PostgreSQL data: reads/writes (evidence: `msika-app/app/api/vendors/route.ts`)
- Staff dashboard → Markets and sections: manages markets (evidence: `README.md`)
- Staff dashboard → Collector management: manages staff (evidence: `README.md`)
- Vendors → Vendor payment page: starts payment (evidence: `README.md`)
- Council staff → Payment recording: records cash (evidence: `README.md`)
- Vendor payment page → Payment recording: initiates payment
- Wallet providers → Wallet callbacks: sends callbacks (evidence: `README.md`)
- Wallet callbacks → Webhook processing: dispatches
- Webhook processing → PostgreSQL data: records payment (evidence: `msika-app/lib/wallet-webhook.ts`)
- Webhook processing → SMS receipts/reminders: queues receipt (evidence: `msika-app/lib/wallet-webhook.ts`)
- SMS receipts/reminders → SMS delivery: sends message (evidence: `msika-app/lib/notify.ts`)
- Webhook processing → Audit recording: records event (evidence: `msika-app/lib/wallet-webhook.ts`)
- Payment recording → PostgreSQL data: stores payments (evidence: `README.md`)
- Staff dashboard → Dashboard metrics: loads metrics (evidence: `README.md`)
- Staff dashboard → Revenue pulse: views revenue (evidence: `README.md`)
- Staff dashboard → Daily reports: requests reports (evidence: `README.md`)
- Staff dashboard → Audit log view: views audit trail (evidence: `README.md`)
- Audit log view → PostgreSQL data: reads logs
