# uditrpanchal/timeoff-management-application architecture

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

- Interactive diagram: https://gitdiagram.com/uditrpanchal/timeoff-management-application
- Repository: https://github.com/uditrpanchal/timeoff-management-application

## Overview

##### Main Components
- Application Backend – Represent the Node.js server (app.js) that contains routes (found under lib/route), business logic (in lib/model and lib/util), and middleware (in lib/middleware). This is the core of your system.
- Views & Frontend Assets – Include the Handlebars views (in the views directory) and static resources (in public and scss directories). This layer handles the web interface for users.
- CLI & Utility Scripts – Optionally represent the set of command-line scripts in the “bin” directory (e.g., scripts for calculating allowances, fetching statistics). They support maintenance and administrative tasks.
- Database and Data Layer – Although the actual database isn’t defined explicitly in the file tree, there are numerous database-related files in lib/model/db and migrations. Indicate a database layer that the application connects to.
- Infrastructure as Code – Show Terraform modules (in the terraform directory) that provision AWS resources such as VPC, EKS cluster, subnets, NAT gateways, etc.
- CI/CD Pipeline – Include GitLab CI/CD (.gitlab-ci.yml) and associated build agents. Show how code is built, containerized (Dockerfile and build-agent directories), and then deployed automatically to the AWS EKS cluster.

##### Relationships and Interactions
- Deployment Flow: Indicate the CI/CD process going from code repository → GitLab CI/CD (build and test stage) → container image build (using the Dockerfile and build-agent scripts) → deployment via Kubernetes configuration (applying overlays for dev or prod).
- Infrastructure Provisioning: Show that Terraform is used to provision AWS resources (VPC, subnets, EKS nodes, load balancers) and that Kubernetes manages the deployment of the application container.
- Management Tools: You might also include ancillary scripts (in bin) for operations, maintenance, and integration tasks.

##### Design Principles and Patterns
- Separation of Concerns: The project clearly separates the application code (lib, views, public) from infrastructure as code (terraform, kubernetes) and CI/CD configuration (.gitlab-ci.yml).
- Automated Workflows: Emphasize the autonomous deployment pipeline (CI/CD) and automated scaling and load balancing across multiple Availability Zones.

##### Technologies and Frameworks
- Node.js/Express for the server,
- Handlebars for templating,
- Docker for containerization,
- Kubernetes (with Kustomize) for orchestration,
- Terraform for infrastructure provisioning,
- GitLab CI/CD for automated build and deployment,
- AWS (EKS, Route53, ACM, ELB) for hosting the production environment.

##### Additional Elements
- Use of overlays in Kubernetes by perhaps annotating the “dev” and “prod” environments.
- Incorporate a note about how external load balancers and DNS are configured to route traffic to the application.

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Client Layer
    subgraph "Client Layer"
        Browser["User Browser"]:::client
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Views["Views (Handlebars)"]:::frontend
        Public["Public Assets"]:::frontend
        SCSS["SCSS Styles"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        AppEntry["app.js (Entry Point)"]:::backend
        Business["lib (Business Logic & Middleware)"]:::backend
    end

    %% CLI & Utility Layer
    subgraph "CLI & Utility Scripts"
        CLI["bin (CLI Scripts)"]:::cli
    end

    %% Data Layer
    subgraph "Data Layer"
        DBModels["DB Models (lib/model/db)"]:::database
        Migrations["Migrations"]:::database
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GitLab["GitLab CI/CD (.gitlab-ci.yml)"]:::cicd
        BuildAgent["Build Agents (build-agent)"]:::cicd
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Terraform["Terraform (IaC)"]:::infra
        Kubernetes["Kubernetes (Orchestration)"]:::infra
    end

    %% AWS Infrastructure
    subgraph "AWS Infrastructure"
        AWS["AWS EKS & Resources"]:::aws
    end

    %% Client to Presentation Flow
    Browser -->|"sendsRequest"| Views
    Browser -->|"sendsRequest"| Public
    Browser -->|"sendsRequest"| SCSS

    %% Presentation to Application Flow
    Views -->|"renders"| AppEntry
    Public -->|"serves"| AppEntry
    SCSS -->|"styles"| AppEntry

    %% Application Internal Flow
    AppEntry -->|"invokes"| Business
    Business -->|"rw"| DBModels

    %% CLI Tools Interaction
    CLI -->|"maintenance"| AppEntry

    %% Data Layer Connection
    Migrations -->|"updates"| DBModels

    %% CI/CD Pipeline Flow
    GitLab -->|"triggers"| BuildAgent
    GitLab -->|"deploys"| Kubernetes

    %% Infrastructure Provisioning Flow
    Terraform -->|"provisions"| AWS
    Terraform -->|"setsUp"| Kubernetes
    Kubernetes -->|"runsOn"| AWS

    %% Click Events
    click AppEntry "https://github.com/uditrpanchal/timeoff-management-application/blob/master/app.js"
    click Business "https://github.com/uditrpanchal/timeoff-management-application/tree/master/lib/"
    click Views "https://github.com/uditrpanchal/timeoff-management-application/tree/master/views"
    click Public "https://github.com/uditrpanchal/timeoff-management-application/tree/master/public"
    click SCSS "https://github.com/uditrpanchal/timeoff-management-application/tree/master/scss"
    click CLI "https://github.com/uditrpanchal/timeoff-management-application/tree/master/bin"
    click DBModels "https://github.com/uditrpanchal/timeoff-management-application/tree/master/lib/model/db"
    click Migrations "https://github.com/uditrpanchal/timeoff-management-application/tree/master/migrations"
    click GitLab "https://github.com/uditrpanchal/timeoff-management-application/blob/master/.gitlab-ci.yml"
    click BuildAgent "https://github.com/uditrpanchal/timeoff-management-application/tree/master/build-agent"
    click Terraform "https://github.com/uditrpanchal/timeoff-management-application/tree/master/terraform"
    click Kubernetes "https://github.com/uditrpanchal/timeoff-management-application/tree/master/kubernetes"

    %% Styles
    classDef client fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef cli fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef database fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef cicd fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef infra fill:#d6d8d9,stroke:#333,stroke-width:2px;
    classDef aws fill:#cce5ff,stroke:#333,stroke-width:2px;
```
