# asif-jutt/messmanagementsystem architecture

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

- Interactive diagram: https://gitdiagram.com/asif-jutt/messmanagementsystem
- Repository: https://github.com/asif-jutt/messmanagementsystem

## Overview

#### Purpose and runtime
This is a .NET 8 ASP.NET Core MVC mess-management system for administrators and members. It manages members, dishes/weekly menus, meal booking and daily records, deposits, rates, bills, and reports. The application entry point is `Program.cs`; project/runtime definition is `Mess_Management_System_Semester_Project.csproj`.

#### Delivery and presentation boundary
HTTP requests are handled by MVC controllers and rendered as Razor pages, with separate administrator and member experiences. Key entry controllers include `Controllers/HomeController.cs`, `Controllers/AdminController.cs`, and `Controllers/MemberController.cs`. Shared layouts define role-oriented shells: `Views/Shared/_AdminLayout.cshtml`, `Views/Shared/_MemberLayout.cshtml`, and `Views/Shared/_Layout.cshtml`.

#### Identity and access
Authentication is split between administrator/general user and member-facing flows, with protected endpoints and JWT support. Main boundary files are `Controllers/AuthController.cs`, `Controllers/MemberAuthController.cs`, `Controllers/ProtectedController.cs`, plus token abstraction/implementation in `Services/IJwtService.cs` and `Services/JwtService.cs`. User identity is represented by `Models/User.cs`, `Models/Admin.cs`, and `Models/Member.cs`.

#### Persistence model
`Models/MessDbContext.cs` is the database integration boundary, holding the relational model for operational records. Core persisted entities are members and meals (`Models/Member.cs`, `Models/Meal.cs`), financial records (`Models/Deposit.cs`, `Models/Bill.cs`, `Models/MonthlyBill.cs`), and menu/rate data (`Models/Dish.cs`, `Models/WeeklyMenu.cs`, `Models/MealRate.cs`). SQL setup and schema evolution are repository-managed scripts, notably `Scripts/CompleteDatabaseSetup.sql` and `Scripts/UpdateWeeklyMenusSchema.sql`.

#### Meal and menu operations
Administrators manage dishes and weekly menus; members can view menus and book meals, while staff can record daily consumption. Control paths are concentrated in `Controllers/DishesController.cs`, `Controllers/WeeklyMenusController.cs`, and `Controllers/MealManagementController.cs`. The weekly-menu domain is encapsulated further in `Services/WeeklyMenuService.cs` and represented for UI composition by `Models/WeeklyMenuViewModel.cs`.

#### Billing and payment flow
Operational data flows from meal records and meal rates into billing calculations, then to bills/monthly bills and member-visible payment history. `Services/IBillingService.cs` and `Services/BillingService.cs` form the explicit billing-calculation boundary. HTTP management/reporting endpoints are in `Controllers/BillsController.cs`, `Controllers/MonthlyBillsController.cs`, `Controllers/DepositsController.cs`, and `Controllers/MealRatesController.cs`.

#### Reporting and external surface
Reports draw on persisted meal and financial data, including the database-oriented aggregate model `Models/VwDailyMealTotal.cs`; reporting routes are in `Controllers/ReportsController.cs` and `Controllers/MonthlyBillsController.cs`. There is also a distinct API/chatbot surface through `Controllers/ApiController.cs` and `Controllers/ChatbotController.cs`, with corresponding member assistant UI at `Views/Member/Assistant.cshtml`. The repository contains a Web Deploy publish profile at `Properties/PublishProfiles/site48989-WebDeploy.pubxml`; the database provider and connection details are expected through `appsettings.json` / environment-specific settings.

Main entry points: [`Models/MessDbContext.cs`](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/MessDbContext.cs) (Mess Database Context), [`Services/BillingService.cs`](https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/BillingService.cs) (Billing Service), [`Services/JwtService.cs`](https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/JwtService.cs) (JWT Service), [`Models/User.cs`](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/User.cs) (User Identities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["MVC Presentation"]
  node_mvc["MVC Controllers<br/>HTTP controllers<br/>[HomeController.cs]"]
  node_layouts["Role Layouts<br/>Razor layouts<br/>[_Layout.cshtml]"]
  node_assistant_api["Assistant API<br/>API/chatbot controllers<br/>[ApiController.cs]"]
  node_assistant_ui["Member Assistant UI<br/>Razor page<br/>[Assistant.cshtml]"]
end

subgraph group_identity["Identity &amp; Access"]
  node_auth["User Authentication<br/>auth controller<br/>[AuthController.cs]"]
  node_member_auth["Member Authentication<br/>auth controller"]
  node_protected["Protected Endpoints<br/>access controller"]
  node_jwt["JWT Service<br/>token service<br/>[JwtService.cs]"]
  node_identities["User Identities<br/>entity models<br/>[User.cs]"]
end

subgraph group_operations["Mess Operations"]
  node_menu_controllers["Menu Management<br/>MVC controllers"]
  node_weekly_menu_service["Weekly Menu Service<br/>domain service"]
  node_menu_models["Menu &amp; Rate Models<br/>entity models<br/>[WeeklyMenu.cs]"]
  node_meal_records["Meal Records<br/>entity model<br/>[Meal.cs]"]
  node_billing_endpoints["Billing &amp; Deposit Routes<br/>MVC controllers<br/>[BillsController.cs]"]
  node_billing["Billing Service<br/>calculation service<br/>[BillingService.cs]"]
  node_financial_models["Financial Records<br/>entity models<br/>[Bill.cs]"]
  node_reports["Reports<br/>MVC controller"]
  node_daily_totals["Daily Meal Totals<br/>aggregate model"]
end

subgraph group_persistence["Persistence"]
  node_db[("Mess Database Context<br/>EF Core DbContext<br/>[MessDbContext.cs]")]
  node_schema["Database Schema Scripts<br/>SQL setup"]
end

node_program{{"Application Host<br/>.NET entry point<br/>[Program.cs]"}}

node_program -->|"hosts"| node_mvc
node_program -->|"configures auth"| node_auth
node_program -->|"configures"| node_db
node_mvc -->|"renders"| node_layouts
node_auth -->|"uses"| node_jwt
node_member_auth -->|"uses"| node_jwt
node_jwt -->|"claims for"| node_identities
node_protected -->|"validates"| node_jwt
node_auth -->|"authenticates"| node_identities
node_member_auth -->|"authenticates"| node_identities
node_menu_controllers -->|"delegates menu work"| node_weekly_menu_service
node_weekly_menu_service -->|"manages"| node_menu_models
node_menu_controllers -->|"books and records"| node_meal_records
node_billing_endpoints -->|"requests calculations"| node_billing
node_billing -->|"uses consumption"| node_meal_records
node_billing -->|"uses meal rates"| node_menu_models
node_billing -->|"creates bills"| node_financial_models
node_reports -->|"reads"| node_daily_totals
node_reports -->|"reports on"| node_financial_models
node_assistant_ui -->|"calls"| node_assistant_api
node_menu_models -->|"persisted in"| node_db
node_meal_records -->|"persisted in"| node_db
node_financial_models -->|"persisted in"| node_db
node_identities -->|"persisted in"| node_db
node_schema -.->|"provisions"| node_db

click node_program "https://github.com/asif-jutt/messmanagementsystem/blob/main/Program.cs"
click node_mvc "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/HomeController.cs"
click node_layouts "https://github.com/asif-jutt/messmanagementsystem/blob/main/Views/Shared/_Layout.cshtml"
click node_auth "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/AuthController.cs"
click node_member_auth "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/MemberAuthController.cs"
click node_protected "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/ProtectedController.cs"
click node_jwt "https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/JwtService.cs"
click node_identities "https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/User.cs"
click node_menu_controllers "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/WeeklyMenusController.cs"
click node_weekly_menu_service "https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/WeeklyMenuService.cs"
click node_menu_models "https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/WeeklyMenu.cs"
click node_meal_records "https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/Meal.cs"
click node_billing_endpoints "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/BillsController.cs"
click node_billing "https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/BillingService.cs"
click node_financial_models "https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/Bill.cs"
click node_reports "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/ReportsController.cs"
click node_daily_totals "https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/VwDailyMealTotal.cs"
click node_assistant_api "https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/ApiController.cs"
click node_assistant_ui "https://github.com/asif-jutt/messmanagementsystem/blob/main/Views/Member/Assistant.cshtml"
click node_db "https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/MessDbContext.cs"
click node_schema "https://github.com/asif-jutt/messmanagementsystem/blob/main/Scripts/CompleteDatabaseSetup.sql"

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_mvc,node_layouts,node_assistant_api,node_assistant_ui toneBlue
class node_auth,node_member_auth,node_protected,node_jwt,node_identities toneAmber
class node_menu_controllers,node_weekly_menu_service,node_menu_models,node_meal_records,node_billing_endpoints,node_billing,node_financial_models,node_reports,node_daily_totals toneMint
class node_db,node_schema toneRose
class node_program toneNeutral
```

## Components

### MVC Presentation

Administrator and member HTTP/UI boundary.

- [MVC Controllers](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/HomeController.cs): HTTP controllers · Home, administrator, and member entry routes. · `Controllers/HomeController.cs`
- [Role Layouts](https://github.com/asif-jutt/messmanagementsystem/blob/main/Views/Shared/_Layout.cshtml): Razor layouts · Shared, administrator, and member page shells. · `Views/Shared/_Layout.cshtml`
- [Assistant API](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/ApiController.cs): API/chatbot controllers · Distinct API and chatbot surface. · `Controllers/ApiController.cs`
- [Member Assistant UI](https://github.com/asif-jutt/messmanagementsystem/blob/main/Views/Member/Assistant.cshtml): Razor page · `Views/Member/Assistant.cshtml`

### Identity & Access

Separate user and member authentication flows.

- [User Authentication](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/AuthController.cs): auth controller · Administrator and general-user authentication. · `Controllers/AuthController.cs`
- [Member Authentication](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/MemberAuthController.cs): auth controller · `Controllers/MemberAuthController.cs`
- [Protected Endpoints](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/ProtectedController.cs): access controller · `Controllers/ProtectedController.cs`
- [JWT Service](https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/JwtService.cs): token service · Issues and validates JWT access tokens. · `Services/JwtService.cs`
- [User Identities](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/User.cs): entity models · User, admin, and member identities. · `Models/User.cs`

### Mess Operations

Menu, meal, finance, and reporting workflows.

- [Menu Management](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/WeeklyMenusController.cs): MVC controllers · Dish, weekly-menu, and meal-management routes. · `Controllers/WeeklyMenusController.cs`
- [Weekly Menu Service](https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/WeeklyMenuService.cs): domain service · Encapsulates weekly-menu operations and UI composition. · `Services/WeeklyMenuService.cs`
- [Menu & Rate Models](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/WeeklyMenu.cs): entity models · Dishes, weekly menus, meal rates, and menu view model. · `Models/WeeklyMenu.cs`
- [Meal Records](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/Meal.cs): entity model · Member meal booking and daily consumption records. · `Models/Meal.cs`
- [Billing & Deposit Routes](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/BillsController.cs): MVC controllers · Bills, monthly bills, deposits, and meal-rate management. · `Controllers/BillsController.cs`
- [Billing Service](https://github.com/asif-jutt/messmanagementsystem/blob/main/Services/BillingService.cs): calculation service · Calculates bills from meal records and rates. · `Services/BillingService.cs`
- [Financial Records](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/Bill.cs): entity models · Deposits, bills, and monthly bills. · `Models/Bill.cs`
- [Reports](https://github.com/asif-jutt/messmanagementsystem/blob/main/Controllers/ReportsController.cs): MVC controller · Reporting over meal and financial aggregates. · `Controllers/ReportsController.cs`
- [Daily Meal Totals](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/VwDailyMealTotal.cs): aggregate model · Database-oriented daily meal aggregate. · `Models/VwDailyMealTotal.cs`

### Persistence

Relational operational data and schema setup.

- [Mess Database Context](https://github.com/asif-jutt/messmanagementsystem/blob/main/Models/MessDbContext.cs): EF Core DbContext · Relational integration boundary for operational records. · `Models/MessDbContext.cs`
- [Database Schema Scripts](https://github.com/asif-jutt/messmanagementsystem/blob/main/Scripts/CompleteDatabaseSetup.sql): SQL setup · Database setup and weekly-menu schema evolution. · `Scripts/CompleteDatabaseSetup.sql`

### Other components

- [Application Host](https://github.com/asif-jutt/messmanagementsystem/blob/main/Program.cs): .NET entry point · `Program.cs`

## Connections

- Application Host → MVC Controllers: hosts
- Application Host → User Authentication: configures auth
- Application Host → Mess Database Context: configures
- MVC Controllers → Role Layouts: renders
- User Authentication → JWT Service: uses
- Member Authentication → JWT Service: uses
- JWT Service → User Identities: claims for
- Protected Endpoints → JWT Service: validates
- User Authentication → User Identities: authenticates
- Member Authentication → User Identities: authenticates
- Menu Management → Weekly Menu Service: delegates menu work
- Weekly Menu Service → Menu & Rate Models: manages
- Menu Management → Meal Records: books and records
- Billing & Deposit Routes → Billing Service: requests calculations
- Billing Service → Meal Records: uses consumption
- Billing Service → Menu & Rate Models: uses meal rates
- Billing Service → Financial Records: creates bills
- Reports → Daily Meal Totals: reads
- Reports → Financial Records: reports on
- Member Assistant UI → Assistant API: calls
- Menu & Rate Models → Mess Database Context: persisted in
- Meal Records → Mess Database Context: persisted in
- Financial Records → Mess Database Context: persisted in
- User Identities → Mess Database Context: persisted in
- Database Schema Scripts → Mess Database Context: provisions
