# marksu20/pos-kiosk-capstone architecture

> Architecture diagram of the GitHub repository marksu20/pos-kiosk-capstone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marksu20/pos-kiosk-capstone
- Repository: https://github.com/marksu20/pos-kiosk-capstone

## Overview

##### Project type and purpose
- This is a full-stack Node.js/Express “POS-Kiosk” web application.
- It provides three main user interfaces: an Admin dashboard, a POS terminal interface for staff, and a self-service Kiosk for customers.
- It manages products, categories, stock levels, discounts, orders, receipts and user accounts, and integrates with a payment confirmation script.

##### File structure
- Top level
- app.js – Express app entry point
- /public – static assets (CSS, JS, images, uploads)
- /views – EJS templates grouped by layout (admin, kiosk, pos, main) and partials
- /server – backend logic
- /server/config – database connection (MongoDB), authentication settings
- /server/models – Mongoose schemas (User, Product, Order, Receipt, etc.)
- /server/controllers – MVC controllers for admin, kiosk, pos, main
- /server/routes – Express routers mounting each controller on its path
- /server/middleware – authentication, role checks, file-upload (Multer)
- /scripts – payment-confirmation integration

##### README
- README is minimal, but project name “pos-kiosk-capstone finale” confirms purpose: final capstone project implementing POS + Kiosk.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client UIs"
        direction TB
        AdminUI["Admin Dashboard UI"]:::client
        POSTerminalUI["POS Terminal UI"]:::client
        KioskUI["Kiosk Self-Service UI"]:::client
        MainUI["Main/Public UI"]:::client
    end

    %% Server Layer
    subgraph "Express Server" 
        direction TB

        subgraph "Middleware" 
            direction TB
            AuthMiddleware["Auth Middleware"]:::middleware
            RoleMiddleware["Role Check Middleware"]:::middleware
            MulterMiddleware["File Upload Middleware"]:::middleware
        end

        subgraph "Routes"
            direction TB
            AdminRoute["/admin (Admin Router)"]:::route
            POSRoute["/pos (POS Router)"]:::route
            KioskRoute["/kiosk (Kiosk Router)"]:::route
            AuthRoute["/auth (Auth Router)"]:::route
            IndexRoute["/ (Main Router)"]:::route
        end

        subgraph "Controllers"
            direction TB
            AdminController["Admin Controller"]:::controller
            POSController["POS Controller"]:::controller
            KioskController["Kiosk Controller"]:::controller
            MainController["Main Controller"]:::controller
        end

        subgraph "Models"
            direction TB
            UserModel["User Model"]:::model
            ProductModel["Product Model"]:::model
            CategoryModel["Category Model"]:::model
            StockModel["Stock Model"]:::model
            DiscountModel["Discount Model"]:::model
            OrderModel["Order Model"]:::model
            ReceiptModel["Receipt Model"]:::model
        end
    end

    %% Persistence & External
    MongoDB[(MongoDB)]:::db
    FileStorage["File Storage (/public/uploads)"]:::storage
    PaymentGateway["Payment Gateway"]:::external
    ConfirmPayment["Payment Confirmation Script"]:::service

    %% Static Assets
    StaticAssets["Static Assets (/public)"]:::storage

    %% Connections
    AdminUI -->|"HTTP GET/POST"| AdminRoute
    POSTerminalUI -->|"HTTP GET/POST"| POSRoute
    KioskUI -->|"HTTP GET/POST"| KioskRoute
    MainUI -->|"HTTP GET/POST"| IndexRoute

    AdminRoute --> AuthMiddleware
    POSRoute --> AuthMiddleware
    KioskRoute --> AuthMiddleware
    AuthRoute --> AuthMiddleware
    IndexRoute --> AuthMiddleware

    AuthMiddleware --> RoleMiddleware
    RoleMiddleware --> MulterMiddleware
    MulterMiddleware --> AdminController
    MulterMiddleware --> POSController
    MulterMiddleware --> KioskController
    MulterMiddleware --> MainController

    AdminController --> UserModel
    AdminController --> ProductModel
    AdminController --> CategoryModel
    AdminController --> StockModel
    AdminController --> DiscountModel
    AdminController --> OrderModel
    AdminController --> ReceiptModel

    POSController --> OrderModel
    POSController --> ReceiptModel
    POSController --> ConfirmPayment
    KioskController --> ProductModel
    KioskController --> OrderModel
    MainController --> UserModel

    ConfirmPayment -->|API Call| PaymentGateway
    PaymentGateway -->|Callback| ConfirmPayment
    ConfirmPayment -->|Update Order/Receipt| MongoDB

    UserModel --> MongoDB
    ProductModel --> MongoDB
    CategoryModel --> MongoDB
    StockModel --> MongoDB
    DiscountModel --> MongoDB
    OrderModel --> MongoDB
    ReceiptModel --> MongoDB

    MulterMiddleware -->|Store files| FileStorage
    StaticAssets --> AdminUI
    StaticAssets --> POSTerminalUI
    StaticAssets --> KioskUI
    StaticAssets --> MainUI

    %% Click Events
    click AdminUI "https://github.com/marksu20/pos-kiosk-capstone/tree/main/views/admin"
    click POSTerminalUI "https://github.com/marksu20/pos-kiosk-capstone/tree/main/views/pos"
    click KioskUI "https://github.com/marksu20/pos-kiosk-capstone/tree/main/views/kiosk"
    click MainUI "https://github.com/marksu20/pos-kiosk-capstone/blob/main/views/index.ejs"
    click AuthMiddleware "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/middleware/checkAuth.js"
    click RoleMiddleware "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/middleware/checkRole.js"
    click MulterMiddleware "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/middleware/multer.js"
    click AdminRoute "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/routes/admin.js"
    click POSRoute "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/routes/pos.js"
    click KioskRoute "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/routes/kiosk.js"
    click AuthRoute "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/routes/auth.js"
    click IndexRoute "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/routes/index.js"
    click AdminController "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/controllers/adminController.js"
    click POSController "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/controllers/posController.js"
    click KioskController "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/controllers/kioskController.js"
    click MainController "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/controllers/mainController.js"
    click UserModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/User.js"
    click ProductModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/Product.js"
    click CategoryModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/Category.js"
    click StockModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/Stock.js"
    click DiscountModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/Discount.js"
    click OrderModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/Order.js"
    click ReceiptModel "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/models/Receipt.js"
    click MongoDB "https://github.com/marksu20/pos-kiosk-capstone/blob/main/server/config/db.js"
    click StaticAssets "https://github.com/marksu20/pos-kiosk-capstone/tree/main/public"
    click FileStorage "https://github.com/marksu20/pos-kiosk-capstone/tree/main/public/uploads"
    click ConfirmPayment "https://github.com/marksu20/pos-kiosk-capstone/blob/main/scripts/confirmPayment.js"

    %% Styles
    classDef client fill:#b2f2bb,stroke:#2f8f4e,color:#000
    classDef middleware fill:#d0ebff,stroke:#339af0,color:#000
    classDef route fill:#e7f5ff,stroke:#74c0fc,color:#000
    classDef controller fill:#ffe8cc,stroke:#ffa94d,color:#000
    classDef model fill:#fff3bf,stroke:#fcc419,color:#000
    classDef db fill:#ffd8a8,stroke:#d9480f,color:#000
    classDef storage fill:#e6fcf5,stroke:#12b886,color:#000
    classDef service fill:#f8f0fc,stroke:#845ef7,color:#000
    classDef external fill:#ffe3e3,stroke:#fa5252,color:#000
```
