# ketankochhar/canteenwebapp architecture

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

- Interactive diagram: https://gitdiagram.com/ketankochhar/canteenwebapp
- Repository: https://github.com/ketankochhar/canteenwebapp

## Overview

This is an Express/EJS college canteen system. Customers authenticate, browse the menu, build a session cart, complete a UPI/QR payment flow that creates an order, and view order history. Owners manage menu items and order status through a protected dashboard. The sampled routes show database access and template rendering; README capabilities such as image uploads and revenue statistics are retained where documented. Dashed links mark UI interaction not verified in the excerpts.

Main entry points: [`server.js`](https://github.com/ketankochhar/canteenwebapp/blob/main/server.js) (Express app), [`config/database.js`](https://github.com/ketankochhar/canteenwebapp/blob/main/config/database.js) (SQLite data), [`routes/payment.js`](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/payment.js) (Payment and order creation), [`routes/cart.js`](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/cart.js) (Cart management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry"]
  node_server["Express app<br/>[server.js]"]
  node_auth_middleware["Access control<br/>[auth.js]"]
end

subgraph group_customer["Customer ordering"]
  node_auth_routes["Authentication<br/>[auth.js]"]
  node_menu_routes["Menu browsing<br/>[menu.js]"]
  node_menu_view["Menu page<br/>[menu.ejs]"]
  node_cart_routes["Cart management<br/>[cart.js]"]
  node_cart_client["Cart browser logic<br/>[cart.js]"]
  node_cart_view["Cart page<br/>[cart.ejs]"]
  node_payment_routes["Payment and order creation<br/>[payment.js]"]
  node_payment_view["Payment page<br/>[payment.ejs]"]
  node_customer_orders["Order history<br/>[orders.js]"]
  node_orders_views["Customer order pages<br/>[orders-list.ejs]"]
end

subgraph group_owner["Owner operations"]
  node_owner_routes["Owner dashboard and management<br/>[owner.js]"]
  node_owner_views["Owner pages"]
end

subgraph group_data["Persistence and payment"]
  node_payment_config["UPI settings<br/>[payment-config.js]"]
  node_database[("SQLite data<br/>[database.js]")]
end

node_customer_actor(("Customer"))
node_owner_actor(("Canteen owner"))

node_customer_actor -->|"sends requests"| node_server
node_owner_actor -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_menu_routes
node_server -->|"mounts routes"| node_cart_routes
node_server -->|"mounts routes"| node_payment_routes
node_server -->|"mounts routes"| node_customer_orders
node_server -->|"mounts routes"| node_owner_routes
node_auth_routes -->|"reads and writes"| node_database
node_auth_routes -->|"renders auth"| node_menu_view
node_menu_routes -->|"reads menu"| node_database
node_menu_routes -->|"renders menu"| node_menu_view
node_cart_routes -->|"checks session"| node_auth_middleware
node_cart_routes -->|"reads menu"| node_database
node_cart_routes -->|"renders cart"| node_cart_view
node_cart_client -.->|"uses cart endpoints"| node_cart_routes
node_payment_routes -->|"checks session"| node_auth_middleware
node_payment_routes -->|"reads and creates orders"| node_database
node_payment_routes -->|"uses UPI settings"| node_payment_config
node_payment_routes -->|"renders payment"| node_payment_view
node_customer_orders -->|"checks session"| node_auth_middleware
node_customer_orders -->|"reads order history"| node_database
node_customer_orders -->|"renders order pages"| node_orders_views
node_owner_routes -->|"checks owner access"| node_auth_middleware
node_owner_routes -->|"reads and updates"| node_database
node_owner_routes -->|"renders owner pages"| node_owner_views

click node_server "https://github.com/ketankochhar/canteenwebapp/blob/main/server.js"
click node_auth_routes "https://github.com/ketankochhar/canteenwebapp/blob/main/routes/auth.js"
click node_auth_middleware "https://github.com/ketankochhar/canteenwebapp/blob/main/middleware/auth.js"
click node_menu_routes "https://github.com/ketankochhar/canteenwebapp/blob/main/routes/menu.js"
click node_menu_view "https://github.com/ketankochhar/canteenwebapp/blob/main/views/menu.ejs"
click node_cart_routes "https://github.com/ketankochhar/canteenwebapp/blob/main/routes/cart.js"
click node_cart_client "https://github.com/ketankochhar/canteenwebapp/blob/main/public/js/cart.js"
click node_cart_view "https://github.com/ketankochhar/canteenwebapp/blob/main/views/cart.ejs"
click node_payment_routes "https://github.com/ketankochhar/canteenwebapp/blob/main/routes/payment.js"
click node_payment_config "https://github.com/ketankochhar/canteenwebapp/blob/main/config/payment-config.js"
click node_payment_view "https://github.com/ketankochhar/canteenwebapp/blob/main/views/payment.ejs"
click node_customer_orders "https://github.com/ketankochhar/canteenwebapp/blob/main/routes/orders.js"
click node_orders_views "https://github.com/ketankochhar/canteenwebapp/blob/main/views/orders-list.ejs"
click node_owner_routes "https://github.com/ketankochhar/canteenwebapp/blob/main/routes/owner.js"
click node_owner_views "https://github.com/ketankochhar/canteenwebapp/tree/main/views/owner"
click node_database "https://github.com/ketankochhar/canteenwebapp/blob/main/config/database.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_auth_middleware toneBlue
class node_auth_routes,node_menu_routes,node_menu_view,node_cart_routes,node_cart_client,node_cart_view,node_payment_routes,node_payment_view,node_customer_orders,node_orders_views toneAmber
class node_owner_routes,node_owner_views toneMint
class node_payment_config,node_database toneRose
class node_customer_actor,node_owner_actor toneIndigo
```

## Components

### Web entry

- [Express app](https://github.com/ketankochhar/canteenwebapp/blob/main/server.js): `server.js`
- [Access control](https://github.com/ketankochhar/canteenwebapp/blob/main/middleware/auth.js): `middleware/auth.js`

### Customer ordering

- [Authentication](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/auth.js): `routes/auth.js`
- [Menu browsing](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/menu.js): `routes/menu.js`
- [Menu page](https://github.com/ketankochhar/canteenwebapp/blob/main/views/menu.ejs): `views/menu.ejs`
- [Cart management](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/cart.js): `routes/cart.js`
- [Cart browser logic](https://github.com/ketankochhar/canteenwebapp/blob/main/public/js/cart.js): `public/js/cart.js`
- [Cart page](https://github.com/ketankochhar/canteenwebapp/blob/main/views/cart.ejs): `views/cart.ejs`
- [Payment and order creation](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/payment.js): `routes/payment.js`
- [Payment page](https://github.com/ketankochhar/canteenwebapp/blob/main/views/payment.ejs): `views/payment.ejs`
- [Order history](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/orders.js): `routes/orders.js`
- [Customer order pages](https://github.com/ketankochhar/canteenwebapp/blob/main/views/orders-list.ejs): `views/orders-list.ejs`

### Owner operations

- [Owner dashboard and management](https://github.com/ketankochhar/canteenwebapp/blob/main/routes/owner.js): `routes/owner.js`
- [Owner pages](https://github.com/ketankochhar/canteenwebapp/tree/main/views/owner): `views/owner`

### Persistence and payment

- [UPI settings](https://github.com/ketankochhar/canteenwebapp/blob/main/config/payment-config.js): `config/payment-config.js`
- [SQLite data](https://github.com/ketankochhar/canteenwebapp/blob/main/config/database.js): `config/database.js`

### Other components

- **Customer**
- **Canteen owner**

## Connections

- Customer → Express app: sends requests (evidence: `server.js`)
- Canteen owner → Express app: sends requests (evidence: `server.js`)
- Express app → Authentication: mounts routes (evidence: `server.js`)
- Express app → Menu browsing: mounts routes (evidence: `server.js`)
- Express app → Cart management: mounts routes (evidence: `server.js`)
- Express app → Payment and order creation: mounts routes (evidence: `server.js`)
- Express app → Order history: mounts routes (evidence: `server.js`)
- Express app → Owner dashboard and management: mounts routes (evidence: `server.js`)
- Authentication → SQLite data: reads and writes (evidence: `routes/auth.js`)
- Authentication → Menu page: renders auth (evidence: `routes/auth.js`)
- Menu browsing → SQLite data: reads menu (evidence: `routes/menu.js`)
- Menu browsing → Menu page: renders menu (evidence: `routes/menu.js`)
- Cart management → Access control: checks session (evidence: `routes/cart.js`)
- Cart management → SQLite data: reads menu (evidence: `routes/cart.js`)
- Cart management → Cart page: renders cart (evidence: `routes/cart.js`)
- Cart browser logic → Cart management: uses cart endpoints
- Payment and order creation → Access control: checks session (evidence: `routes/payment.js`)
- Payment and order creation → SQLite data: reads and creates orders (evidence: `routes/payment.js`)
- Payment and order creation → UPI settings: uses UPI settings (evidence: `routes/payment.js`)
- Payment and order creation → Payment page: renders payment (evidence: `routes/payment.js`)
- Order history → Access control: checks session (evidence: `routes/orders.js`)
- Order history → SQLite data: reads order history (evidence: `routes/orders.js`)
- Order history → Customer order pages: renders order pages (evidence: `routes/orders.js`)
- Owner dashboard and management → Access control: checks owner access (evidence: `routes/owner.js`)
- Owner dashboard and management → SQLite data: reads and updates (evidence: `routes/owner.js`)
- Owner dashboard and management → Owner pages: renders owner pages (evidence: `routes/owner.js`)
