# nitheeshp-irl/microservice-frontend architecture

> Architecture diagram of the GitHub repository nitheeshp-irl/microservice-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nitheeshp-irl/microservice-frontend
- Repository: https://github.com/nitheeshp-irl/microservice-frontend

## Overview

##### Project type and purpose
- This is a full‑stack Node.js web application built with Express.
- It serves both static assets (in `public/`) and dynamic pages via EJS templates (in `views/`).
- It includes a CI pipeline (`.github/workflows/docker-ci.yml`) and Kubernetes manifests (`k8/`) for containerized deployment.

##### File structure
- Top‑level:
- `app.js` – Express application entry point
- `routes/` – route handlers (`index.js`, `origamis.js`)
- `public/` – static assets (CSS, images, client JS)
- `views/` – EJS templates
- `Dockerfile` – container image build instructions
- `k8/` – Kubernetes base manifests and overlays for environment‑specific deployments
- `.github/workflows` – CI that builds and tests Docker image
- Config & dependencies:
- `config.json` – application configuration
- `package.json` – npm dependencies and scripts
- `test/` – integration/unit tests (e.g. `appTest.js`)

##### README
- Specifies Node version, build & launch commands, and default port (3000).
- Confirms it’s a simple Express‑based frontend app.

##### Detailed capture of architectural elements
- Under “Express Pod”, break down subcomponents:
- Static file server (serves `/public`)
- Route handlers (`/`, `/origamis`)
- Template engine (EJS in `views/`)
- Config loader (`config.json`)
- Under “CI/CD”, show steps: checkout → npm install → test → Docker build → push → Kustomize apply
- Under “Kubernetes”, show `base` manifests plus `overlays/development` customizing namespace or replica count

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Flow
    subgraph "User Flow"
        Browser["Browser"]:::frontend
        Ingress["Ingress Controller"]:::frontend
        Service["Kubernetes Service"]:::runtime
    end

    Browser -->|"HTTP Request"| Ingress
    Ingress -->|"Route to Service"| Service
    Service -->|"Forward to Pod"| Pod["Express Pod"]:::runtime

    %% Express Pod Components
    subgraph "Express Pod"
        PodStatic["Static File Server"]:::runtime
        PodRoutes["Route Handlers"]:::runtime
        PodTemplates["EJS Template Engine"]:::runtime
        PodConfig["Config Loader"]:::runtime
    end

    Pod --> PodStatic
    Pod --> PodRoutes
    Pod --> PodTemplates
    Pod --> PodConfig

    %% Static Assets
    PodStatic --> CSS["styles.css"]:::static
    PodStatic --> JS["script.js"]:::static
    PodStatic --> Images["images/"]:::static

    %% Templates & Config & Routes
    PodTemplates --> Views["index.ejs"]:::static
    PodConfig --> ConfigFile["config.json"]:::static
    PodRoutes --> IndexRoute["index.js"]:::runtime
    PodRoutes --> OrigamiRoute["origamis.js"]:::runtime

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GitHub["GitHub Repo & Actions"]:::pipeline
        Checkout["Checkout Code"]:::pipeline
        Install["npm Install"]:::pipeline
        Test["Run Tests"]:::pipeline
        BuildImage["Docker Build"]:::pipeline
        PushImage["Push to Registry"]:::pipeline
        DockerReg["Docker Registry"]:::pipeline
        Deploy["Deploy with Kustomize"]:::pipeline
    end

    GitHub --> Checkout --> Install --> Test --> BuildImage --> PushImage --> DockerReg
    PushImage --> Deploy

    %% Kubernetes Manifests
    Deploy --> K8BaseDeployment["base/deployment.yaml"]:::infra
    Deploy --> K8BaseService["base/service.yml"]:::infra
    Deploy --> K8BaseRBAC["base/rbac.yml"]:::infra
    Deploy --> K8BaseKustomize["base/kustomization.yaml"]:::infra
    Deploy --> DevOverlay["overlays/development/kustomization.yaml"]:::infra

    %% Other project files
    PodConfig---README["README.md"]:::infra
    GitHub---CIWorkflow["docker-ci.yml"]:::pipeline
    BuildImage---Dockerfile["Dockerfile"]:::pipeline
    Install---PackageJSON["package.json"]:::pipeline
    Test---AppTest["appTest.js"]:::pipeline
    PodRoutes---AppEntry["app.js"]:::runtime

    %% Click Events
    click AppEntry "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/app.js"
    click ConfigFile "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/config.json"
    click IndexRoute "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/routes/index.js"
    click OrigamiRoute "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/routes/origamis.js"
    click CSS "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/public/css/styles.css"
    click JS "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/public/script.js"
    click Images "https://github.com/nitheeshp-irl/microservice-frontend/tree/main/public/images/"
    click Views "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/views/index.ejs"
    click Dockerfile "https://github.com/nitheeshp-irl/microservice-frontend/tree/main/Dockerfile"
    click CIWorkflow "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/.github/workflows/docker-ci.yml"
    click K8BaseDeployment "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/k8/base/deployment.yaml"
    click K8BaseService "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/k8/base/service.yml"
    click K8BaseRBAC "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/k8/base/rbac.yml"
    click K8BaseKustomize "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/k8/base/kustomization.yaml"
    click DevOverlay "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/k8/overlays/development/kustomization.yaml"
    click PackageJSON "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/package.json"
    click AppTest "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/test/appTest.js"
    click README "https://github.com/nitheeshp-irl/microservice-frontend/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000;
    classDef runtime fill:#90EE90,stroke:#000;
    classDef pipeline fill:#FFA500,stroke:#000;
    classDef static fill:#D3D3D3,stroke:#000;
    classDef infra fill:#F5F5F5,stroke:#000;
```
