# nguyenlinhit-cpu/diennuocroot architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenlinhit-cpu/diennuocroot
- Repository: https://github.com/nguyenlinhit-cpu/diennuocroot

## Overview

Điện Nước Root connects customers and repair workers through customer/worker Flutter apps, a Flutter web admin, and a Rust API. The main workflow is service and worker discovery, booking, job coordination, and payment; the product also supports account access, worker verification, messaging, complaints, support, and operations dashboards. The graph follows documented app/API responsibilities and sampled backend routes and handlers. Several UI and backend subsystems are represented from the tree and README rather than inspected source, so their internal wiring is shown only where documented.

Main entry points: [`backend/src/routes.rs`](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/routes.rs) (HTTP and WS routes), [`app/lib/ui/screens`](https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/app/lib/ui/screens) (Customer and worker app), [`backend/src/chat/handlers.rs`](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/chat/handlers.rs) (Booking chat), [`backend/src/booking/handlers.rs`](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/booking/handlers.rs) (Booking lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User applications"]
  node_mobile_ui["Customer and worker app"]
  node_mobile_api["Mobile API services<br/>[api_client.dart]"]
  node_admin_ui["Admin portal"]
  node_admin_api["Admin API client<br/>[api.dart]"]
  node_worker_ui["Worker screens"]
end

subgraph group_api["API and domain"]
  node_api_routes["HTTP and WS routes<br/>[routes.rs]"]
  node_auth["Accounts and auth<br/>[handlers.rs]"]
  node_catalog["Services and areas<br/>[handlers.rs]"]
  node_workers["Worker discovery<br/>[handlers.rs]"]
  node_bookings["Booking lifecycle<br/>[handlers.rs]"]
  node_chat["Booking chat<br/>[handlers.rs]"]
  node_payments["Payment and invoice<br/>[handlers.rs]"]
  node_uploads["File uploads<br/>[upload.rs]"]
end

subgraph group_ops["Operations"]
  node_admin_ops["Admin operations<br/>[handlers.rs]"]
  node_complaints["Complaints and support<br/>[handlers.rs]"]
end

subgraph group_infra["Runtime state"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
  node_map_service["OpenStreetMap"]
  node_payment_gateways["ZaloPay and Momo"]
  node_push_service["Firebase messaging"]
end

node_customer(("Customer"))
node_worker(("Repair worker"))
node_admin_actor(("Administrator"))

node_customer -->|"uses"| node_mobile_ui
node_worker -->|"uses"| node_mobile_ui
node_admin_actor -->|"uses"| node_admin_ui
node_mobile_ui -->|"requests"| node_mobile_api
node_mobile_api -->|"calls API"| node_api_routes
node_admin_ui -->|"requests"| node_admin_api
node_admin_api -->|"calls API"| node_api_routes
node_api_routes -->|"dispatches auth"| node_auth
node_api_routes -->|"dispatches catalog"| node_catalog
node_api_routes -->|"dispatches discovery"| node_workers
node_api_routes -->|"dispatches bookings"| node_bookings
node_api_routes -->|"dispatches chat"| node_chat
node_api_routes -->|"dispatches payments"| node_payments
node_api_routes -->|"dispatches uploads"| node_uploads
node_api_routes -->|"dispatches admin"| node_admin_ops
node_api_routes -->|"dispatches support"| node_complaints
node_mobile_ui -.->|"displays maps"| node_map_service
node_worker_ui -->|"requests"| node_mobile_api
node_auth -->|"reads/writes accounts"| node_postgres
node_catalog -->|"reads catalog"| node_postgres
node_workers -->|"reads/writes workers"| node_postgres
node_bookings -->|"reads/writes bookings"| node_postgres
node_bookings -->|"publishes status"| node_chat
node_chat -->|"stores messages"| node_postgres
node_chat -.->|"uses cache"| node_redis
node_payments -->|"reads/writes payments"| node_postgres
node_payments -.->|"initiates payment"| node_payment_gateways
node_uploads -.->|"stores metadata"| node_postgres
node_admin_ops -->|"reads/writes operations"| node_postgres
node_complaints -->|"reads/writes cases"| node_postgres
node_worker_ui -.->|"receives alerts"| node_push_service

click node_mobile_ui "https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/app/lib/ui/screens"
click node_mobile_api "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/app/lib/core/api_client.dart"
click node_admin_ui "https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/admin/lib/screens"
click node_admin_api "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/admin/lib/api.dart"
click node_api_routes "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/routes.rs"
click node_auth "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/auth/handlers.rs"
click node_catalog "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/catalog/handlers.rs"
click node_workers "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/workers/handlers.rs"
click node_bookings "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/booking/handlers.rs"
click node_chat "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/chat/handlers.rs"
click node_payments "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/payments/handlers.rs"
click node_uploads "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/upload.rs"
click node_admin_ops "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/admin/handlers.rs"
click node_worker_ui "https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/app/lib/ui/screens/worker"
click node_complaints "https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/admin/handlers.rs"

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_mobile_ui,node_mobile_api,node_admin_ui,node_admin_api,node_worker_ui toneBlue
class node_api_routes,node_auth,node_catalog,node_workers,node_bookings,node_chat,node_payments,node_uploads toneAmber
class node_admin_ops,node_complaints toneMint
class node_postgres,node_redis,node_map_service,node_payment_gateways,node_push_service,node_worker toneRose
class node_customer,node_admin_actor toneIndigo
```

## Components

### User applications

- [Customer and worker app](https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/app/lib/ui/screens): `app/lib/ui/screens`
- [Mobile API services](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/app/lib/core/api_client.dart): `app/lib/core/api_client.dart`
- [Admin portal](https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/admin/lib/screens): `admin/lib/screens`
- [Admin API client](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/admin/lib/api.dart): `admin/lib/api.dart`
- [Worker screens](https://github.com/nguyenlinhit-cpu/diennuocroot/tree/main/app/lib/ui/screens/worker): `app/lib/ui/screens/worker`

### API and domain

- [HTTP and WS routes](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/routes.rs): `backend/src/routes.rs`
- [Accounts and auth](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/auth/handlers.rs): `backend/src/auth/handlers.rs`
- [Services and areas](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/catalog/handlers.rs): `backend/src/catalog/handlers.rs`
- [Worker discovery](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/workers/handlers.rs): `backend/src/workers/handlers.rs`
- [Booking lifecycle](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/booking/handlers.rs): `backend/src/booking/handlers.rs`
- [Booking chat](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/chat/handlers.rs): `backend/src/chat/handlers.rs`
- [Payment and invoice](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/payments/handlers.rs): `backend/src/payments/handlers.rs`
- [File uploads](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/upload.rs): `backend/src/upload.rs`

### Operations

- [Admin operations](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/admin/handlers.rs): `backend/src/admin/handlers.rs`
- [Complaints and support](https://github.com/nguyenlinhit-cpu/diennuocroot/blob/main/backend/src/admin/handlers.rs): `backend/src/admin/handlers.rs`

### Runtime state

- **PostgreSQL**
- **Redis**
- **OpenStreetMap**
- **ZaloPay and Momo**
- **Firebase messaging**

### Other components

- **Customer**
- **Repair worker**
- **Administrator**

## Connections

- Customer → Customer and worker app: uses
- Repair worker → Customer and worker app: uses
- Administrator → Admin portal: uses
- Customer and worker app → Mobile API services: requests
- Mobile API services → HTTP and WS routes: calls API
- Admin portal → Admin API client: requests
- Admin API client → HTTP and WS routes: calls API
- HTTP and WS routes → Accounts and auth: dispatches auth
- HTTP and WS routes → Services and areas: dispatches catalog
- HTTP and WS routes → Worker discovery: dispatches discovery
- HTTP and WS routes → Booking lifecycle: dispatches bookings
- HTTP and WS routes → Booking chat: dispatches chat
- HTTP and WS routes → Payment and invoice: dispatches payments
- HTTP and WS routes → File uploads: dispatches uploads
- HTTP and WS routes → Admin operations: dispatches admin
- HTTP and WS routes → Complaints and support: dispatches support
- Customer and worker app → OpenStreetMap: displays maps
- Worker screens → Mobile API services: requests
- Accounts and auth → PostgreSQL: reads/writes accounts
- Services and areas → PostgreSQL: reads catalog
- Worker discovery → PostgreSQL: reads/writes workers
- Booking lifecycle → PostgreSQL: reads/writes bookings
- Booking lifecycle → Booking chat: publishes status
- Booking chat → PostgreSQL: stores messages
- Booking chat → Redis: uses cache
- Payment and invoice → PostgreSQL: reads/writes payments
- Payment and invoice → ZaloPay and Momo: initiates payment
- File uploads → PostgreSQL: stores metadata
- Admin operations → PostgreSQL: reads/writes operations
- Complaints and support → PostgreSQL: reads/writes cases
- Worker screens → Firebase messaging: receives alerts
