# alvaradoa/employee-application architecture

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

- Interactive diagram: https://gitdiagram.com/alvaradoa/employee-application
- Repository: https://github.com/alvaradoa/employee-application

## Overview

##### Main Components
- App Layer: This is represented by the contents of the “app” directory. It includes:
- app.py (the core Python application logic),
- templates (HTML pages such as about.html, addemp.html, etc.),
- static assets (files in the static folder),
- Dockerfile (for containerizing the application).
- Database Layer: Found in the “db” directory. It contains:
- MySQL schema (mysql.sql),
- Dockerfile (to build the MySQL container),
- Additional README for configuration.
- Orchestration & Deployment: The “manifest” directory contains Kubernetes YAML files for various resources (applications, services, config maps, secrets, PVCs, HPA configurations, etc.) and other deployment-related documentation. The docker-compose.yml file gives an overview on local multi-container practices.
- CI/CD Pipeline: The README mentions GitHub Actions for automatically building and pushing Docker images to Amazon ECR and deploying them to an Amazon EKS cluster.

##### File Structure & Architecturally Relevant Details
- The separation of “app” and “db” directories indicates a two-tier separation (web application and database).
- The “manifest” directory contains individual YAML definitions for Kubernetes components such as:
- Deployment descriptors (app.yaml, db.yaml) – representing pods or microservice deployments.
- Service and Ingress definitions – managing external accessibility.
- Persistent Volume Claims (app_pvc.yaml) – showing that storage persistence is managed.
- ConfigMaps and Secrets – emphasizing configuration and security management.
- The presence of a docker-compose.yml file implies local multi-container orchestration before transition to a full Kubernetes environment.
- Multiple README and documentation files across directories provide deployment instructions, further clarifying the architectural intent.

##### Construction
a. Main Components to Represent:
- Frontend/User Interface: Represent HTML templates and static files as part of the user interface hosted by the web server.
- Backend/Application Server: Represent this as the container encapsulated by the “app” directory which handles business logic.
- Database: Represent the MySQL database (from the “db” directory).
- Container Orchestration: Represent Kubernetes with the various resources (deployments, pods, services, PVCs, etc.) indicated by the “manifest” files.
- CI/CD Pipeline: Represent GitHub Actions and Amazon ECR as part of the automated build, test, and deploy cycle.
- Cloud Infrastructure: Represent Amazon EKS (for deployment), and note where cost, high availability, and scalability considerations come in.

b. Relationships and Interactions:
- How the CI/CD pipeline triggers new Docker image builds and pushes them to ECR, which then triggers deployments on the Kubernetes cluster.

c. Architectural Patterns & Principles:
- Containerization: Use Docker to encapsulate both the web application and database.
- Separation of Concerns: Clearly separate the web server (application logic and UI) from the database and infrastructure management.
- Declarative Infrastructure: The use of Kubernetes manifests illustrates Infrastructure as Code (IaC).
- Scalability and Availability: Include elements such as HPA (Horizontal Pod Autoscaling) and persistent storage from the manifest files.

d. Technologies, Frameworks, and Tools:
- Python (for app.py),
- Docker (for containerization),
- Kubernetes/EKS (for orchestration),
- MySQL (as the database),
- GitHub Actions (for CI/CD),
- Amazon ECR (for container registry),
- Docker Compose (local orchestration),
- And supporting files like ConfigMaps, Secrets which detail configuration and security management.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Layer
    subgraph "User Layer"
        U("User"):::user
    end

    %% Application Layer
    subgraph "Application Layer"
        WA("Web Application Container"):::app
        DB("MySQL Database Container"):::db
    end

    %% Container Orchestration & Deployment
    subgraph "Container Orchestration & Deployment"
        K8S("Kubernetes Cluster (Amazon EKS)"):::k8s
        Man("Kubernetes Manifests"):::manifest
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CICD("GitHub Actions Pipeline"):::cicd
        ECR("Amazon ECR"):::cicd
    end

    %% Local Development
    subgraph "Local Development"
        DC("Docker Compose (Local Multi-Container Setup)"):::local
    end

    %% Connections: User to Application
    U -->|"HTTP_Request"| WA

    %% Connections: Application to Database
    WA -->|"SQL_Query"| DB

    %% Connections: Manifests to Kubernetes Cluster
    Man -->|"DefineDeployment"| K8S

    %% Connections: Kubernetes Cluster deploys Application and Database
    K8S -->|"Deploys"| WA
    K8S -->|"Deploys"| DB

    %% Connections: CI/CD Pipeline builds and pushes images
    CICD -->|"BuildAndPush"| ECR
    ECR -->|"DeploysImage"| K8S

    %% Connections: Local Development orchestration
    DC -->|"LocalDeployment"| WA
    DC -->|"LocalDeployment"| DB

    %% Click Events
    click WA "https://github.com/alvaradoa/employee-application/tree/main/app/"
    click DB "https://github.com/alvaradoa/employee-application/tree/main/db/"
    click Man "https://github.com/alvaradoa/employee-application/tree/main/manifest/"
    click DC "https://github.com/alvaradoa/employee-application/blob/main/docker-compose.yml"
    click CICD "https://github.com/alvaradoa/employee-application/blob/main/README.md"

    %% Styles
    classDef user fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef app fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef db fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef k8s fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef manifest fill:#e6ccff,stroke:#333,stroke-width:2px;
    classDef cicd fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef local fill:#fce5cd,stroke:#333,stroke-width:2px;
```
