# kasunih/academic-promotion-workflow-automation-platform architecture

> Architecture diagram of the GitHub repository kasunih/academic-promotion-workflow-automation-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kasunih/academic-promotion-workflow-automation-platform
- Repository: https://github.com/kasunih/academic-promotion-workflow-automation-platform

## Overview

##### Project type and purpose
- This is a full-stack web application (Node.js + Express) that automates academic promotion workflows.
- The README title indicates its purpose: managing applicant submissions and approvals for academic promotion.

##### File structure
- Top-level files:
– app.js: main Express server setup
– index.html: likely a general landing page (server-served or redirect)
– emailMappings.js: holds email template or address mappings
– package.json / package-lock.json: project metadata and dependencies
- Directories:
– controllers/: business logic for approval and authentication
– routes/: Express routing modules (REST endpoints + Socket route)
– middleware/: authentication middleware
– models/: data models (User, Applicant)
– public/: static frontend assets (HTML pages for applicants, admins, sections, signup)
- No explicit “config” or “db” folder, but the presence of models suggests use of a database (e.g., MongoDB via Mongoose).

##### Key insights from the README
- Project title only, no additional architecture notes. We infer common web app patterns (MVC, REST, real-time notifications).

##### Main components (to include
a. Client (Web Browser)
– Static HTML/CSS/JS in public/ served by Express
– Separate pages for applicants, admins, approvals, etc.
b. Web Server (Node.js + Express)
– Entry point: app.js
– Routing layer: routes/*.js
– Middleware: authMiddleware (JWT/session checking)
– Controllers: authController, approvalController
– EmailMappings module for notification logic
– Socket route (routes/Socket.js) for real-time updates
c. Database
– Collections/tables for Users and Applicants (models/)
– Likely MongoDB via Mongoose (implied by .js models)
d. External Services
– Email service (SMTP or third-party API) driven by emailMappings.js
– Real-time channel (Socket.io or similar)

##### Interactions & data flow
1. User opens a public HTML page → Browser sends HTTP request to Express server.
2. Express picks up route (e.g., /auth, /application, /approval)
3. authMiddleware (if required) verifies token/session
4. Controller executes business logic (read/write via models)
5. Models interact with the database → save or fetch records
6. Controller may trigger email notifications using emailMappings
7. Socket module pushes real-time updates to subscribed clients
8. Server responds with JSON or HTML as appropriate

##### Architectural patterns & design principles
- MVC-inspired separation (routes → controllers → models)
- Middleware pipeline for cross-cutting concerns (authentication, logging)
- Single responsibility: each module handles one concern (auth, approval, email mapping)
- Real-time façade via Socket route for live notifications or status updates

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Presentation Layer" 
        style PresentationLayer fill:#e0f7e9,stroke:#0b6e4f,stroke-width:2px
        Browser["Web Browser"]:::presentation
        PublicSite["Static Assets (public/)"]:::presentation
        IndexPage["Landing Page (index.html)"]:::presentation
    end

    %% Server Layer
    subgraph "Application Layer (Server)" 
        style ServerLayer fill:#dae8fc,stroke:#6c8ebf,stroke-width:2px
        AppJS["app.js"]:::application
        subgraph "Routes"
            AuthRoute1["routes/auth.js"]:::application
            AuthRoute2["routes/authRoutes.js"]:::application
            AppRoute["routes/application.js"]:::application
            ApprovalRoute["routes/approvalRoutes.js"]:::application
            SocketRoute["routes/Socket.js"]:::application
        end
        AuthMiddleware["middleware/authMiddleware.js"]:::application
        subgraph "Controllers"
            AuthController["controllers/authController.js"]:::application
            ApprovalController["controllers/approvalController.js"]:::application
        end
        EmailMap["emailMappings.js"]:::application
        subgraph "Models"
            UserModel["models/User.js"]:::application
            ApplicantModel["models/applicant.js"]:::application
        end
        PackageJSON["package.json"]:::application
        PackageLock["package-lock.json"]:::application
        README["README.md"]:::application
    end

    %% Data Layer
    subgraph "Data Layer"
        style DataLayer fill:#fff2cc,stroke:#d79b00,stroke-width:2px
        Database["MongoDB (Data Store)"]:::data
    end

    %% External Services Layer
    subgraph "External Services"
        style ExternalLayer fill:#f2f2f2,stroke:#999999,stroke-width:2px
        EmailService["SMTP / Email Service"]:::external
        RealTime["Socket.io Channel"]:::external
    end

    %% Connections: Client to Server
    Browser -->|Request Static| PublicSite
    Browser -->|GET /index.html| IndexPage
    PublicSite -->|served by| AppJS
    IndexPage -->|served by| AppJS

    %% Server Request Flow
    AppJS -->|forwards to| AuthRoute1
    AppJS --> AuthRoute2
    AppJS --> AppRoute
    AppJS --> ApprovalRoute
    AppJS --> SocketRoute

    AuthRoute1 -->|uses| AuthMiddleware
    AuthRoute2 -->|uses| AuthMiddleware
    AppRoute -->|uses| AuthMiddleware
    ApprovalRoute -->|uses| AuthMiddleware

    AuthRoute1 --> AuthController
    AuthRoute2 --> AuthController
    AppRoute --> AuthController
    ApprovalRoute --> ApprovalController

    AuthController --> UserModel
    AuthController --> ApplicantModel
    ApprovalController --> ApplicantModel

    UserModel --> Database
    ApplicantModel --> Database

    AuthController --> EmailMap
    ApprovalController --> EmailMap
    EmailMap --> EmailService

    SocketRoute --> RealTime
    RealTime -->|push updates to| Browser

    %% Click Events
    click PublicSite "https://github.com/kasunih/academic-promotion-workflow-automation-platform/tree/main/public/"
    click IndexPage "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/index.html"
    click AppJS "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/app.js"
    click AuthRoute1 "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/routes/auth.js"
    click AuthRoute2 "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/routes/authRoutes.js"
    click AppRoute "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/routes/application.js"
    click ApprovalRoute "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/routes/approvalRoutes.js"
    click SocketRoute "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/routes/Socket.js"
    click AuthMiddleware "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/middleware/authMiddleware.js"
    click AuthController "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/controllers/authController.js"
    click ApprovalController "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/controllers/approvalController.js"
    click UserModel "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/models/User.js"
    click ApplicantModel "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/models/applicant.js"
    click EmailMap "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/emailMappings.js"
    click PackageJSON "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/package.json"
    click PackageLock "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/package-lock.json"
    click README "https://github.com/kasunih/academic-promotion-workflow-automation-platform/blob/main/README.md"

    %% Styles
    classDef presentation fill:#e0f7e9,stroke:#0b6e4f,stroke-width:1px
    classDef application fill:#dae8fc,stroke:#6c8ebf,stroke-width:1px
    classDef data fill:#fff2cc,stroke:#d79b00,stroke-width:1px
    classDef external fill:#f2f2f2,stroke:#999999,stroke-width:1px
```
