# ratul-420/web2-seminar-homework architecture

> Architecture diagram of the GitHub repository ratul-420/web2-seminar-homework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ratul-420/web2-seminar-homework
- Repository: https://github.com/ratul-420/web2-seminar-homework

## Overview

This is an Express/Mongoose waste-services web application. Residents can register or log in, submit contact messages, and view waste-service data and a request-quantity graph; administrators manage collection-calendar entries. The graph preserves the distinct account, messaging, data-view, reporting, and calendar workflows, plus the data-import entry point. Route handlers own the shown model operations and rendering. The README provides no capability details, and the import script is indexed but not excerpted, so its model links rely on the source index; other unsampled behavior is not inferred.

Main entry points: [`views`](https://github.com/ratul-420/web2-seminar-homework/tree/main/views) (EJS views), [`app.js`](https://github.com/ratul-420/web2-seminar-homework/blob/main/app.js) (Express app), [`routes/mainRouter.js`](https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/mainRouter.js) (Main routes), [`routes/database.js`](https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/database.js) (Database view route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web entry and views"]
  node_server["Express app<br/>[app.js]"]
  node_views["EJS views"]
  node_main_routes["Main routes<br/>[mainRouter.js]"]
end

subgraph group_accounts["Accounts and messaging"]
  node_account_controller["Account controller<br/>[mainController.js]"]
  node_user_model["User model<br/>[User.js]"]
  node_contact_controller["Contact controller"]
  node_message_controller["Messages controller"]
  node_message_model["Message model<br/>[Message.js]"]
end

subgraph group_waste["Waste data and reporting"]
  node_service_model["Waste service model<br/>[WasteService.js]"]
  node_database_route["Database view route<br/>[database.js]"]
  node_request_model["Resident request model<br/>[ResidentRequest.js]"]
  node_graph_route["Graph route<br/>[graph.js]"]
  node_import_script["Waste data importer"]
end

subgraph group_calendar["Calendar administration"]
  node_admin_calendar["Calendar routes<br/>[adminCalendar.js]"]
  node_calendar_model["Calendar model"]
end

node_visitor(("Resident or admin"))
node_mongo[("MongoDB")]

node_visitor -->|"requests pages"| node_server
node_server -->|"mounts routes"| node_main_routes
node_server -->|"mounts route"| node_database_route
node_server -->|"mounts route"| node_graph_route
node_server -->|"connects"| node_mongo
node_main_routes -->|"dispatches"| node_account_controller
node_main_routes -->|"dispatches"| node_contact_controller
node_main_routes -->|"dispatches"| node_message_controller
node_main_routes -->|"mounts calendar"| node_admin_calendar
node_account_controller -->|"reads and creates"| node_user_model
node_account_controller -->|"renders pages"| node_views
node_contact_controller -->|"creates message"| node_message_model
node_contact_controller -->|"renders contact"| node_views
node_message_controller -->|"reads messages"| node_message_model
node_message_controller -->|"renders messages"| node_views
node_admin_calendar -->|"reads and writes"| node_calendar_model
node_admin_calendar -->|"checks service"| node_service_model
node_admin_calendar -->|"renders calendar"| node_views
node_database_route -->|"reads services"| node_service_model
node_database_route -->|"reads calendar"| node_calendar_model
node_database_route -->|"reads requests"| node_request_model
node_database_route -->|"renders database"| node_views
node_graph_route -->|"reads services"| node_service_model
node_graph_route -->|"aggregates demand"| node_request_model
node_graph_route -->|"renders graph"| node_views
node_import_script -->|"imports data"| node_service_model
node_import_script -->|"imports data"| node_calendar_model
node_import_script -->|"imports data"| node_request_model

click node_server "https://github.com/ratul-420/web2-seminar-homework/blob/main/app.js"
click node_views "https://github.com/ratul-420/web2-seminar-homework/tree/main/views"
click node_main_routes "https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/mainRouter.js"
click node_account_controller "https://github.com/ratul-420/web2-seminar-homework/blob/main/controllers/mainController.js"
click node_user_model "https://github.com/ratul-420/web2-seminar-homework/blob/main/models/User.js"
click node_contact_controller "https://github.com/ratul-420/web2-seminar-homework/blob/main/controllers/contactController.js"
click node_message_controller "https://github.com/ratul-420/web2-seminar-homework/blob/main/controllers/messagesController.js"
click node_message_model "https://github.com/ratul-420/web2-seminar-homework/blob/main/models/Message.js"
click node_admin_calendar "https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/adminCalendar.js"
click node_calendar_model "https://github.com/ratul-420/web2-seminar-homework/blob/main/models/CollectionCalendar.js"
click node_service_model "https://github.com/ratul-420/web2-seminar-homework/blob/main/models/WasteService.js"
click node_database_route "https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/database.js"
click node_request_model "https://github.com/ratul-420/web2-seminar-homework/blob/main/models/ResidentRequest.js"
click node_graph_route "https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/graph.js"
click node_import_script "https://github.com/ratul-420/web2-seminar-homework/blob/main/scripts/import-waste-transport.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_server,node_views,node_main_routes toneBlue
class node_account_controller,node_user_model,node_contact_controller,node_message_controller,node_message_model,node_mongo toneAmber
class node_service_model,node_database_route,node_request_model,node_graph_route,node_import_script toneMint
class node_admin_calendar,node_calendar_model toneRose
class node_visitor toneIndigo
```

## Components

### Web entry and views

- [Express app](https://github.com/ratul-420/web2-seminar-homework/blob/main/app.js): `app.js`
- [EJS views](https://github.com/ratul-420/web2-seminar-homework/tree/main/views): `views`
- [Main routes](https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/mainRouter.js): `routes/mainRouter.js`

### Accounts and messaging

- [Account controller](https://github.com/ratul-420/web2-seminar-homework/blob/main/controllers/mainController.js): `controllers/mainController.js`
- [User model](https://github.com/ratul-420/web2-seminar-homework/blob/main/models/User.js): `models/User.js`
- [Contact controller](https://github.com/ratul-420/web2-seminar-homework/blob/main/controllers/contactController.js): `controllers/contactController.js`
- [Messages controller](https://github.com/ratul-420/web2-seminar-homework/blob/main/controllers/messagesController.js): `controllers/messagesController.js`
- [Message model](https://github.com/ratul-420/web2-seminar-homework/blob/main/models/Message.js): `models/Message.js`

### Waste data and reporting

- [Waste service model](https://github.com/ratul-420/web2-seminar-homework/blob/main/models/WasteService.js): `models/WasteService.js`
- [Database view route](https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/database.js): `routes/database.js`
- [Resident request model](https://github.com/ratul-420/web2-seminar-homework/blob/main/models/ResidentRequest.js): `models/ResidentRequest.js`
- [Graph route](https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/graph.js): `routes/graph.js`
- [Waste data importer](https://github.com/ratul-420/web2-seminar-homework/blob/main/scripts/import-waste-transport.js): `scripts/import-waste-transport.js`

### Calendar administration

- [Calendar routes](https://github.com/ratul-420/web2-seminar-homework/blob/main/routes/adminCalendar.js): `routes/adminCalendar.js`
- [Calendar model](https://github.com/ratul-420/web2-seminar-homework/blob/main/models/CollectionCalendar.js): `models/CollectionCalendar.js`

### Other components

- **Resident or admin**
- **MongoDB**

## Connections

- Resident or admin → Express app: requests pages (evidence: `app.js`)
- Express app → Main routes: mounts routes (evidence: `app.js`)
- Express app → Database view route: mounts route (evidence: `app.js`)
- Express app → Graph route: mounts route (evidence: `app.js`)
- Express app → MongoDB: connects (evidence: `app.js`)
- Main routes → Account controller: dispatches (evidence: `routes/mainRouter.js`)
- Main routes → Contact controller: dispatches (evidence: `routes/mainRouter.js`)
- Main routes → Messages controller: dispatches (evidence: `routes/mainRouter.js`)
- Main routes → Calendar routes: mounts calendar (evidence: `routes/mainRouter.js`)
- Account controller → User model: reads and creates (evidence: `controllers/mainController.js`)
- Account controller → EJS views: renders pages (evidence: `controllers/mainController.js`)
- Contact controller → Message model: creates message (evidence: `controllers/contactController.js`)
- Contact controller → EJS views: renders contact (evidence: `controllers/contactController.js`)
- Messages controller → Message model: reads messages (evidence: `controllers/messagesController.js`)
- Messages controller → EJS views: renders messages (evidence: `controllers/messagesController.js`)
- Calendar routes → Calendar model: reads and writes (evidence: `routes/adminCalendar.js`)
- Calendar routes → Waste service model: checks service (evidence: `routes/adminCalendar.js`)
- Calendar routes → EJS views: renders calendar (evidence: `routes/adminCalendar.js`)
- Database view route → Waste service model: reads services (evidence: `routes/database.js`)
- Database view route → Calendar model: reads calendar (evidence: `routes/database.js`)
- Database view route → Resident request model: reads requests (evidence: `routes/database.js`)
- Database view route → EJS views: renders database (evidence: `routes/database.js`)
- Graph route → Waste service model: reads services (evidence: `routes/graph.js`)
- Graph route → Resident request model: aggregates demand (evidence: `routes/graph.js`)
- Graph route → EJS views: renders graph (evidence: `routes/graph.js`)
- Waste data importer → Waste service model: imports data (evidence: `scripts/import-waste-transport.js`)
- Waste data importer → Calendar model: imports data (evidence: `scripts/import-waste-transport.js`)
- Waste data importer → Resident request model: imports data (evidence: `scripts/import-waste-transport.js`)
