# j0hn3mmanuel666-code/smartcivi architecture

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

- Interactive diagram: https://gitdiagram.com/j0hn3mmanuel666-code/smartcivi
- Repository: https://github.com/j0hn3mmanuel666-code/smartcivi

## Overview

smartCivi is a civil-record request and appointment web application with user accounts and administrative workflows. A visitor submits a record request, then can review its status, access payment and receipt features, and manage appointments; staff administer requests, users, records, and reports. Express routes dispatch to controllers, which use Sequelize models for persistent data and render Xian templates. The README is empty, so broader capabilities are inferred from route names and view files; unsampled implementations are represented at their enclosing paths, and links are limited to documented or excerpted relationships.

Main entry points: [`controllers/homeController.js`](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/controllers/homeController.js) (Service and admin workflows), [`models/db.js`](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/db.js) (MySQL connection), [`routes/index.js`](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/routes/index.js) (HTTP routes), [`index.js`](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/index.js) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web entry and routing"]
  node_server["Express server<br/>[index.js]"]
  node_routes["HTTP routes<br/>[index.js]"]
  node_templates["Xian views"]
end

subgraph group_identity["Accounts and access"]
  node_auth["Authentication<br/>[authController.js]"]
  node_access["Admin access guard<br/>[auth.js]"]
end

subgraph group_civic["Civic services"]
  node_home["Service and admin workflows<br/>[homeController.js]"]
  node_service_views["Request and appointment pages"]
  node_admin_views["Administration and reports"]
  node_payment_views["Payments and receipts"]
  node_record_views["Records and documents"]
end

subgraph group_persistence["Persistence"]
  node_user_model["Account model<br/>[userModel.js]"]
  node_request_model["Civil request model<br/>[Request.js]"]
  node_user_table["User model<br/>[User.js]"]
  node_appointment_model["Appointment model<br/>[Appointment.js]"]
  node_attachment_model["Attachment model<br/>[Attachment.js]"]
  node_database[("MySQL connection<br/>[db.js]")]
end

node_visitor(("Visitor / staff"))

node_visitor -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"dispatches auth"| node_auth
node_routes -->|"dispatches services"| node_home
node_routes -->|"guards admin"| node_access
node_auth -->|"queries accounts"| node_user_model
node_home -->|"reads and updates"| node_request_model
node_home -->|"queries users"| node_user_table
node_server -->|"renders templates"| node_templates
node_auth -->|"renders auth pages"| node_templates
node_home -.->|"renders service pages"| node_service_views
node_home -.->|"renders admin pages"| node_admin_views
node_home -.->|"renders payment pages"| node_payment_views
node_home -.->|"renders record pages"| node_record_views
node_user_model -->|"uses connection"| node_database
node_request_model -->|"uses connection"| node_database
node_user_table -->|"uses connection"| node_database
node_appointment_model -->|"uses connection"| node_database
node_attachment_model -->|"uses connection"| node_database

click node_server "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/index.js"
click node_routes "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/routes/index.js"
click node_templates "https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views"
click node_auth "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/controllers/authController.js"
click node_access "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/middleware/auth.js"
click node_user_model "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/userModel.js"
click node_home "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/controllers/homeController.js"
click node_request_model "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/Request.js"
click node_user_table "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/User.js"
click node_appointment_model "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/Appointment.js"
click node_attachment_model "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/Attachment.js"
click node_database "https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/db.js"
click node_service_views "https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views"
click node_admin_views "https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views"
click node_payment_views "https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views"
click node_record_views "https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views"

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_server,node_routes,node_templates toneBlue
class node_auth,node_access toneAmber
class node_home,node_service_views,node_admin_views,node_payment_views,node_record_views toneMint
class node_user_model,node_request_model,node_user_table,node_appointment_model,node_attachment_model,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Web entry and routing

- [Express server](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/index.js): `index.js`
- [HTTP routes](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/routes/index.js): `routes/index.js`
- [Xian views](https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views): `views`

### Accounts and access

- [Authentication](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/controllers/authController.js): `controllers/authController.js`
- [Admin access guard](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/middleware/auth.js): `middleware/auth.js`

### Civic services

- [Service and admin workflows](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/controllers/homeController.js): `controllers/homeController.js`
- [Request and appointment pages](https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views): `views`
- [Administration and reports](https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views): `views`
- [Payments and receipts](https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views): `views`
- [Records and documents](https://github.com/j0hn3mmanuel666-code/smartcivi/tree/main/views): `views`

### Persistence

- [Account model](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/userModel.js): `models/userModel.js`
- [Civil request model](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/Request.js): `models/Request.js`
- [User model](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/User.js): `models/User.js`
- [Appointment model](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/Appointment.js): `models/Appointment.js`
- [Attachment model](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/Attachment.js): `models/Attachment.js`
- [MySQL connection](https://github.com/j0hn3mmanuel666-code/smartcivi/blob/main/models/db.js): `models/db.js`

### Other components

- **Visitor / staff**

## Connections

- Visitor / staff → Express server: sends requests (evidence: `index.js`)
- Express server → HTTP routes: mounts routes (evidence: `index.js`)
- HTTP routes → Authentication: dispatches auth (evidence: `routes/index.js`)
- HTTP routes → Service and admin workflows: dispatches services (evidence: `routes/index.js`)
- HTTP routes → Admin access guard: guards admin (evidence: `routes/index.js`)
- Authentication → Account model: queries accounts (evidence: `controllers/authController.js`)
- Service and admin workflows → Civil request model: reads and updates (evidence: `controllers/homeController.js`)
- Service and admin workflows → User model: queries users (evidence: `controllers/homeController.js`)
- Express server → Xian views: renders templates (evidence: `index.js`)
- Authentication → Xian views: renders auth pages (evidence: `controllers/authController.js`)
- Service and admin workflows → Request and appointment pages: renders service pages
- Service and admin workflows → Administration and reports: renders admin pages
- Service and admin workflows → Payments and receipts: renders payment pages
- Service and admin workflows → Records and documents: renders record pages
- Account model → MySQL connection: uses connection (evidence: `models/userModel.js`)
- Civil request model → MySQL connection: uses connection (evidence: `models/Request.js`)
- User model → MySQL connection: uses connection (evidence: `models/User.js`)
- Appointment model → MySQL connection: uses connection (evidence: `models/Appointment.js`)
- Attachment model → MySQL connection: uses connection (evidence: `models/Attachment.js`)
