# kimaniroy0/property-management-analytics architecture

> Architecture diagram of the GitHub repository kimaniroy0/property-management-analytics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kimaniroy0/property-management-analytics
- Repository: https://github.com/kimaniroy0/property-management-analytics

## Overview

Estate Analytics is a property-management portal for tracking properties, units, tenants, rent, expenses, reports, and M-Pesa collections. Users authenticate, enter an authenticated dashboard, manage operational records, and review month-based performance; M-Pesa payments are recorded after Safaricom confirms them. The graph follows the documented browser/API/database and payment flows. Some component-to-context and route-to-server relationships are supported by the source index; unsampled implementation details are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/App.tsx) (App and routing), [`src/context/PropertyContext.tsx`](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/context/PropertyContext.tsx) (Dashboard state), [`api/mpesa/stkpush.ts`](https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/stkpush.ts) (STK Push route), [`api/dashboard.ts`](https://github.com/kimaniroy0/property-management-analytics/blob/main/api/dashboard.ts) (Dashboard API route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_app["App and routing<br/>[App.tsx]"]
  node_auth_views["Sign-in and sign-up"]
end

subgraph group_operations["Property operations"]
  node_context["Dashboard state"]
  node_dashboard["Performance dashboard<br/>[DashboardView.tsx]"]
  node_properties["Property management<br/>[PropertiesView.tsx]"]
  node_units["Unit management<br/>[UnitsView.tsx]"]
  node_tenants["Tenant management<br/>[TenantsView.tsx]"]
  node_payments["Payment records<br/>[PaymentsView.tsx]"]
  node_expenses["Expense tracking<br/>[ExpensesView.tsx]"]
  node_reports["Financial reports<br/>[ReportsView.tsx]"]
  node_dashboard_api_client["Dashboard API client<br/>[dashboardApi.ts]"]
end

subgraph group_security["Identity and API"]
  node_auth_client["Neon Auth client<br/>[auth.ts]"]
  node_dashboard_route["Dashboard API route<br/>[dashboard.ts]"]
  node_payments_route["Property and payment routes"]
  node_auth_db["JWT and user DB<br/>[authenticatedDb.ts]"]
  node_protection["Request protection"]
  node_db_client["Database connection<br/>[db.ts]"]
end

subgraph group_collections["Rent collection"]
  node_mpesa_views["M-Pesa collection UI<br/>[MpesaView.tsx]"]
  node_mpesa_modal["STK Push modal<br/>[MpesaModal.tsx]"]
  node_mpesa_client["M-Pesa API client<br/>[mpesaApi.ts]"]
  node_stk_route["STK Push route<br/>[stkpush.ts]"]
  node_status_route["Payment status route<br/>[status.ts]"]
  node_callback_route["Payment callback route<br/>[callback.ts]"]
  node_mpesa_service["STK request processing<br/>[mpesa.ts]"]
  node_daraja["Daraja integration<br/>[daraja.ts]"]
end

node_user(("Property manager"))
node_postgres[("PostgreSQL")]
node_safaricom{{"Safaricom Daraja"}}

node_user -->|"uses"| node_app
node_app -->|"shows auth"| node_auth_views
node_auth_views -->|"authenticates with"| node_auth_client
node_app -->|"provides state"| node_context
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_properties
node_app -->|"routes to"| node_units
node_app -->|"routes to"| node_tenants
node_app -->|"routes to"| node_payments
node_app -->|"routes to"| node_mpesa_views
node_app -->|"routes to"| node_expenses
node_app -->|"routes to"| node_reports
node_dashboard -->|"reads KPIs"| node_context
node_properties -->|"manages records"| node_context
node_units -->|"manages records"| node_context
node_tenants -->|"manages records"| node_context
node_payments -->|"manages records"| node_context
node_expenses -->|"manages records"| node_context
node_reports -->|"reads records"| node_context
node_context -->|"gets token"| node_auth_client
node_context -->|"loads data"| node_dashboard_api_client
node_dashboard_api_client -->|"requests dashboard"| node_dashboard_route
node_dashboard_route -->|"verifies user"| node_auth_db
node_dashboard_route -->|"checks requests"| node_protection
node_dashboard_route -->|"reads and writes"| node_postgres
node_auth_db -->|"uses pool"| node_db_client
node_db_client -->|"connects"| node_postgres
node_payments_route -->|"verifies user"| node_auth_db
node_payments_route -->|"checks requests"| node_protection
node_mpesa_views -->|"requests status"| node_mpesa_client
node_mpesa_modal -->|"starts payment"| node_mpesa_client
node_mpesa_client -->|"initiates push"| node_stk_route
node_mpesa_client -->|"checks status"| node_status_route
node_stk_route -->|"verifies user"| node_auth_db
node_stk_route -->|"checks requests"| node_protection
node_stk_route -->|"sends push"| node_daraja
node_status_route -->|"reconciles status"| node_daraja
node_stk_route -->|"stores request"| node_mpesa_service
node_callback_route -->|"completes payment"| node_mpesa_service
node_mpesa_service -->|"records payment"| node_postgres
node_daraja -->|"calls API"| node_safaricom
node_safaricom -->|"confirms payment"| node_callback_route

click node_app "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/App.tsx"
click node_auth_views "https://github.com/kimaniroy0/property-management-analytics/tree/main/src/components/auth"
click node_auth_client "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/auth.ts"
click node_context "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/context/PropertyContext.tsx"
click node_dashboard "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/dashboard/DashboardView.tsx"
click node_properties "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/properties/PropertiesView.tsx"
click node_units "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/units/UnitsView.tsx"
click node_tenants "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/tenants/TenantsView.tsx"
click node_payments "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/payments/PaymentsView.tsx"
click node_expenses "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/expenses/ExpensesView.tsx"
click node_reports "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/reports/ReportsView.tsx"
click node_dashboard_api_client "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/dashboardApi.ts"
click node_dashboard_route "https://github.com/kimaniroy0/property-management-analytics/blob/main/api/dashboard.ts"
click node_payments_route "https://github.com/kimaniroy0/property-management-analytics/tree/main/api"
click node_auth_db "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/authenticatedDb.ts"
click node_protection "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/requestProtection.ts"
click node_db_client "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/db.ts"
click node_mpesa_views "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/mpesa/MpesaView.tsx"
click node_mpesa_modal "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/modals/MpesaModal.tsx"
click node_mpesa_client "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/mpesaApi.ts"
click node_stk_route "https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/stkpush.ts"
click node_status_route "https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/status.ts"
click node_callback_route "https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/callback.ts"
click node_mpesa_service "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/mpesa.ts"
click node_daraja "https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/daraja.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_app,node_auth_views toneBlue
class node_context,node_dashboard,node_properties,node_units,node_tenants,node_payments,node_expenses,node_reports,node_dashboard_api_client,node_postgres toneAmber
class node_auth_client,node_dashboard_route,node_payments_route,node_auth_db,node_protection,node_db_client toneMint
class node_mpesa_views,node_mpesa_modal,node_mpesa_client,node_stk_route,node_status_route,node_callback_route,node_mpesa_service,node_daraja toneRose
class node_user,node_safaricom toneIndigo
```

## Components

### Web experience

- [App and routing](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in and sign-up](https://github.com/kimaniroy0/property-management-analytics/tree/main/src/components/auth): `src/components/auth`

### Property operations

- [Dashboard state](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/context/PropertyContext.tsx): `src/context/PropertyContext.tsx`
- [Performance dashboard](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/dashboard/DashboardView.tsx): `src/components/dashboard/DashboardView.tsx`
- [Property management](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/properties/PropertiesView.tsx): `src/components/properties/PropertiesView.tsx`
- [Unit management](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/units/UnitsView.tsx): `src/components/units/UnitsView.tsx`
- [Tenant management](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/tenants/TenantsView.tsx): `src/components/tenants/TenantsView.tsx`
- [Payment records](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/payments/PaymentsView.tsx): `src/components/payments/PaymentsView.tsx`
- [Expense tracking](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/expenses/ExpensesView.tsx): `src/components/expenses/ExpensesView.tsx`
- [Financial reports](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/reports/ReportsView.tsx): `src/components/reports/ReportsView.tsx`
- [Dashboard API client](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/dashboardApi.ts): `src/lib/dashboardApi.ts`

### Identity and API

- [Neon Auth client](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Dashboard API route](https://github.com/kimaniroy0/property-management-analytics/blob/main/api/dashboard.ts): `api/dashboard.ts`
- [Property and payment routes](https://github.com/kimaniroy0/property-management-analytics/tree/main/api): `api`
- [JWT and user DB](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/authenticatedDb.ts): `src/server/authenticatedDb.ts`
- [Request protection](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/requestProtection.ts): `src/server/requestProtection.ts`
- [Database connection](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Rent collection

- [M-Pesa collection UI](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/mpesa/MpesaView.tsx): `src/components/mpesa/MpesaView.tsx`
- [STK Push modal](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/components/modals/MpesaModal.tsx): `src/components/modals/MpesaModal.tsx`
- [M-Pesa API client](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/lib/mpesaApi.ts): `src/lib/mpesaApi.ts`
- [STK Push route](https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/stkpush.ts): `api/mpesa/stkpush.ts`
- [Payment status route](https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/status.ts): `api/mpesa/status.ts`
- [Payment callback route](https://github.com/kimaniroy0/property-management-analytics/blob/main/api/mpesa/callback.ts): `api/mpesa/callback.ts`
- [STK request processing](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/mpesa.ts): `src/server/mpesa.ts`
- [Daraja integration](https://github.com/kimaniroy0/property-management-analytics/blob/main/src/server/daraja.ts): `src/server/daraja.ts`

### Other components

- **Property manager**
- **PostgreSQL**
- **Safaricom Daraja**

## Connections

- Property manager → App and routing: uses (evidence: `src/App.tsx`)
- App and routing → Sign-in and sign-up: shows auth (evidence: `src/App.tsx`)
- Sign-in and sign-up → Neon Auth client: authenticates with (evidence: `src/components/auth/SignInView.tsx`)
- App and routing → Dashboard state: provides state (evidence: `src/App.tsx`)
- App and routing → Performance dashboard: routes to (evidence: `src/App.tsx`)
- App and routing → Property management: routes to (evidence: `src/App.tsx`)
- App and routing → Unit management: routes to (evidence: `src/App.tsx`)
- App and routing → Tenant management: routes to (evidence: `src/App.tsx`)
- App and routing → Payment records: routes to (evidence: `src/App.tsx`)
- App and routing → M-Pesa collection UI: routes to (evidence: `src/App.tsx`)
- App and routing → Expense tracking: routes to (evidence: `src/App.tsx`)
- App and routing → Financial reports: routes to (evidence: `src/App.tsx`)
- Performance dashboard → Dashboard state: reads KPIs (evidence: `src/components/dashboard/DashboardView.tsx`)
- Property management → Dashboard state: manages records (evidence: `src/components/properties/PropertiesView.tsx`)
- Unit management → Dashboard state: manages records (evidence: `src/components/units/UnitsView.tsx`)
- Tenant management → Dashboard state: manages records (evidence: `src/components/tenants/TenantsView.tsx`)
- Payment records → Dashboard state: manages records (evidence: `src/components/payments/PaymentsView.tsx`)
- Expense tracking → Dashboard state: manages records (evidence: `src/components/expenses/ExpensesView.tsx`)
- Financial reports → Dashboard state: reads records (evidence: `src/components/reports/ReportsView.tsx`)
- Dashboard state → Neon Auth client: gets token (evidence: `src/context/PropertyContext.tsx`)
- Dashboard state → Dashboard API client: loads data (evidence: `src/context/PropertyContext.tsx`)
- Dashboard API client → Dashboard API route: requests dashboard (evidence: `README.md`)
- Dashboard API route → JWT and user DB: verifies user (evidence: `api/dashboard.ts`)
- Dashboard API route → Request protection: checks requests (evidence: `api/dashboard.ts`)
- Dashboard API route → PostgreSQL: reads and writes (evidence: `README.md`)
- JWT and user DB → Database connection: uses pool (evidence: `src/server/authenticatedDb.ts`)
- Database connection → PostgreSQL: connects (evidence: `README.md`)
- Property and payment routes → JWT and user DB: verifies user (evidence: `api/payments.ts`)
- Property and payment routes → Request protection: checks requests (evidence: `api/payments.ts`)
- M-Pesa collection UI → M-Pesa API client: requests status (evidence: `src/components/mpesa/MpesaView.tsx`)
- STK Push modal → M-Pesa API client: starts payment (evidence: `src/components/modals/MpesaModal.tsx`)
- M-Pesa API client → STK Push route: initiates push (evidence: `README.md`)
- M-Pesa API client → Payment status route: checks status (evidence: `README.md`)
- STK Push route → JWT and user DB: verifies user (evidence: `api/mpesa/stkpush.ts`)
- STK Push route → Request protection: checks requests (evidence: `api/mpesa/stkpush.ts`)
- STK Push route → Daraja integration: sends push (evidence: `api/mpesa/stkpush.ts`)
- Payment status route → Daraja integration: reconciles status (evidence: `api/mpesa/status.ts`)
- STK Push route → STK request processing: stores request (evidence: `api/mpesa/stkpush.ts`)
- Payment callback route → STK request processing: completes payment (evidence: `api/mpesa/callback.ts`)
- STK request processing → PostgreSQL: records payment (evidence: `README.md`)
- Daraja integration → Safaricom Daraja: calls API (evidence: `README.md`)
- Safaricom Daraja → Payment callback route: confirms payment (evidence: `README.md`)
