# kayinamuramoise/waterbilling architecture

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

- Interactive diagram: https://gitdiagram.com/kayinamuramoise/waterbilling
- Repository: https://github.com/kayinamuramoise/waterbilling

## Overview

KigaliWater is a web application for managing water customers, meter readings, and billing. A staff member logs in, then uses the protected dashboard to manage customers, record readings, and review or pay bills; recording usage generates a bill. The React client sends authenticated API requests to the Express server, which applies the domain operations and persists records in MySQL. The source excerpts show the main route and page calls, but not every server route implementation detail or database query relationship.

Main entry points: [`client/src/App.jsx`](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/App.jsx) (Protected app routing), [`client/src/api.js`](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/api.js) (HTTP client), [`client/src/pages/Meters.jsx`](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Meters.jsx) (Meter readings), [`server/server.js`](https://github.com/kayinamuramoise/waterbilling/blob/main/server/server.js) (API routes and billing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_routing["Protected app routing<br/>[App.jsx]"]
  node_layout["Navigation layout<br/>[Layout.jsx]"]
  node_login["Sign-in<br/>[Login.jsx]"]
  node_dashboard["Dashboard view<br/>[Dashboard.jsx]"]
  node_customers["Customer management<br/>[Customers.jsx]"]
  node_meters["Meter readings<br/>[Meters.jsx]"]
  node_bills["Bills and reports<br/>[Bills.jsx]"]
  node_api["HTTP client<br/>[api.js]"]
end

subgraph group_server["API and domain"]
  node_server["API routes and billing<br/>[server.js]"]
end

subgraph group_persistence["Data persistence"]
  node_dbinit["Database initialization<br/>[db.js]"]
  node_mysql[("MySQL records")]
end

node_staff(("Water staff"))

node_staff -->|"uses"| node_routing
node_routing -->|"renders"| node_layout
node_routing -->|"routes to"| node_login
node_routing -->|"routes to"| node_dashboard
node_routing -->|"routes to"| node_customers
node_routing -->|"routes to"| node_meters
node_routing -->|"routes to"| node_bills
node_staff -->|"signs in"| node_login
node_login -->|"posts credentials"| node_api
node_customers -->|"requests customer data"| node_api
node_meters -->|"requests readings"| node_api
node_meters -->|"loads choices"| node_customers
node_bills -->|"requests bills"| node_api
node_dashboard -->|"requests totals"| node_api
node_api -->|"sends API requests"| node_server
node_server -->|"initializes database"| node_dbinit
node_dbinit -->|"creates tables"| node_mysql
node_server -->|"queries records"| node_mysql

click node_routing "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/App.jsx"
click node_layout "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/components/Layout.jsx"
click node_login "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Login.jsx"
click node_dashboard "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Dashboard.jsx"
click node_customers "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Customers.jsx"
click node_meters "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Meters.jsx"
click node_bills "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Bills.jsx"
click node_api "https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/api.js"
click node_server "https://github.com/kayinamuramoise/waterbilling/blob/main/server/server.js"
click node_dbinit "https://github.com/kayinamuramoise/waterbilling/blob/main/server/db.js"

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_routing,node_layout,node_login,node_dashboard,node_customers,node_meters,node_bills,node_api toneBlue
class node_server toneAmber
class node_dbinit,node_mysql toneMint
class node_staff toneIndigo
```

## Components

### Web application

- [Protected app routing](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Navigation layout](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/components/Layout.jsx): `client/src/components/Layout.jsx`
- [Sign-in](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [Dashboard view](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Customer management](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Customers.jsx): `client/src/pages/Customers.jsx`
- [Meter readings](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Meters.jsx): `client/src/pages/Meters.jsx`
- [Bills and reports](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/pages/Bills.jsx): `client/src/pages/Bills.jsx`
- [HTTP client](https://github.com/kayinamuramoise/waterbilling/blob/main/client/src/api.js): `client/src/api.js`

### API and domain

- [API routes and billing](https://github.com/kayinamuramoise/waterbilling/blob/main/server/server.js): `server/server.js`

### Data persistence

- [Database initialization](https://github.com/kayinamuramoise/waterbilling/blob/main/server/db.js): `server/db.js`
- **MySQL records**

### Other components

- **Water staff**

## Connections

- Water staff → Protected app routing: uses (evidence: `client/src/App.jsx`)
- Protected app routing → Navigation layout: renders (evidence: `client/src/App.jsx`)
- Protected app routing → Sign-in: routes to (evidence: `client/src/App.jsx`)
- Protected app routing → Dashboard view: routes to (evidence: `client/src/App.jsx`)
- Protected app routing → Customer management: routes to (evidence: `client/src/App.jsx`)
- Protected app routing → Meter readings: routes to (evidence: `client/src/App.jsx`)
- Protected app routing → Bills and reports: routes to (evidence: `client/src/App.jsx`)
- Water staff → Sign-in: signs in (evidence: `client/src/pages/Login.jsx`)
- Sign-in → HTTP client: posts credentials (evidence: `client/src/pages/Login.jsx`)
- Customer management → HTTP client: requests customer data (evidence: `client/src/pages/Customers.jsx`)
- Meter readings → HTTP client: requests readings (evidence: `client/src/pages/Meters.jsx`)
- Meter readings → Customer management: loads choices (evidence: `client/src/pages/Meters.jsx`)
- Bills and reports → HTTP client: requests bills (evidence: `client/src/pages/Bills.jsx`)
- Dashboard view → HTTP client: requests totals (evidence: `client/src/pages/Dashboard.jsx`)
- HTTP client → API routes and billing: sends API requests (evidence: `client/src/api.js`)
- API routes and billing → Database initialization: initializes database (evidence: `server/server.js`)
- Database initialization → MySQL records: creates tables (evidence: `server/db.js`)
- API routes and billing → MySQL records: queries records (evidence: `server/server.js`)
