# chukwuka1488/edupathfinder architecture

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

- Interactive diagram: https://gitdiagram.com/chukwuka1488/edupathfinder
- Repository: https://github.com/chukwuka1488/edupathfinder

## Overview

##### Project Type and Purpose
- This is a full-stack web application called “Edu Path Finder.”
- Frontend: static single-page UI built with HTML/CSS (Tailwind), vanilla JavaScript, served by Nginx in a Docker container.
- Backend: Python Flask REST API (app.py) exposing course and degree endpoints, layered into Resources → Services → Data access.
- Data Store: Azure Cosmos DB (Mongo API) seeded from large JSON files via scripts.
- DevOps: Azure Pipelines for CI/CD, Terraform for infra provisioning (Cosmos DB account, key‐vault policies, etc.), Docker Compose to orchestrate local containers.

##### Main Components
A. Browser / Client Application
B. Static Asset Server (Nginx container)
C. Frontend Application (HTML/JS/Tailwind)
D. Backend API Server (Flask container)
E. Business-Logic Layer (Service classes)
F. Data-Access Layer (Cosmos Mongo DB abstraction)
G. Database (Azure Cosmos DB)
H. Infrastructure Provisioning (Terraform scripts)
I. CI/CD Pipeline (Azure Pipelines YAML files)
J. Secrets Management (Azure Key Vault)

##### Relationships and Data Flows
1. User opens UI in Browser → requests index.html and JS/CSS assets from Nginx.
2. JS in Browser (fetchData.js, renderCourseTable.js, etc.) calls Flask REST endpoints (e.g., `/courses`, `/degrees`).
3. Flask Resources (college_degree_resource.py, course_resource.py) receive HTTP requests.
4. Resources delegate to Services (college_degree_service.py, course_service.py) implementing business logic.
5. Services call Data-Access classes (cosmos_mongo_db.py) to query/update Azure Cosmos DB.
7. Terraform scripts (`backend/terraform/*.tf`) provision Cosmos DB account and supporting infra in Azure.
8. Azure Pipelines (`azure-pipelines.yml`) build Docker images for frontend/backend, run tests, apply Terraform, and deploy containers to Azure.
9. Secrets (COSMOSDB connection strings, Azure AD credentials) are stored in Azure Key Vault and injected into containers at runtime.

##### Architectural Patterns and Principles
- Layered Architecture: Presentation (Resources) → Business Logic (Services) → Data Access (DB scripts).
- SOLID Principles: Each module (Resource, Service, DAO) has a single responsibility; clear abstractions between layers; dependency inversion via injecting config and DAOs into services.
- Infrastructure as Code (Terraform) and CI/CD automation (Azure Pipelines).

##### Key Technologies and Frameworks
- Frontend: HTML, Tailwind CSS, vanilla JS, Nginx, Docker.
- Backend: Python 3, Flask, Flask-RESTful, Pydantic (for config?), Docker.
- Database: Azure Cosmos DB with Mongo API.
- Infra: Terraform, Azure CLI, Azure Key Vault.
- CI/CD: Azure DevOps Pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Tier
    subgraph "Presentation Tier"
        Browser["Browser / Client"]:::frontend
        Nginx["Nginx (Static Server)"]:::frontend
        FrontendApp["Frontend App\n(HTML/CSS/JS)"]:::frontend
    end

    %% Application Tier
    subgraph "Application Tier"
        FlaskAPI["Flask API Server"]:::backend
        subgraph "Resources"
            CourseResource["Course Resource"]:::backend
            DegreeResource["Degree Resource"]:::backend
        end
        subgraph "Services"
            CourseService["Course Service"]:::backend
            DegreeService["Degree Service"]:::backend
        end
        DAO["Data Access\n(Cosmos DAO)"]:::backend
    end

    %% Data & Infra Tier
    subgraph "Data & Infra Tier"
        CosmosDB["Azure Cosmos DB"]:::infra
        KeyVault["Azure Key Vault"]:::infra
        Terraform["Terraform IaC"]:::devops
        AzurePipelines["Azure Pipelines"]:::devops
        DockerCompose["Docker Compose\n(Local)"]:::devops
    end

    %% Connections
    Browser -->|"GET index.html, JS, CSS"| Nginx
    Nginx -->|serves assets| Browser
    Nginx -->|"HTTP/HTTPS"| FrontendApp
    FrontendApp -->|"REST /courses, /degrees"| FlaskAPI
    FlaskAPI -->|"invokes"| CourseResource
    FlaskAPI -->|"invokes"| DegreeResource
    CourseResource -->|"calls"| CourseService
    DegreeResource -->|"calls"| DegreeService
    CourseService -->|"queries"| DAO
    DegreeService -->|"queries"| DAO
    DAO -->|"Mongo API"| CosmosDB
    Terraform -->|"provisions"| CosmosDB
    Terraform -->|"provisions"| KeyVault
    AzurePipelines -->|"runs tests, builds, applies IaC"| Terraform
    AzurePipelines -->|"deploys containers"| DockerCompose
    KeyVault -->|"injects secrets into"| FlaskAPI
    KeyVault -->|"injects secrets into"| Nginx

    %% Click Events
    click Browser "https://github.com/chukwuka1488/edupathfinder/blob/master/frontend/index.html"
    click Nginx "https://github.com/chukwuka1488/edupathfinder/blob/master/frontend/nginx/default.conf"
    click FrontendApp "https://github.com/chukwuka1488/edupathfinder/blob/master/frontend/package.json"
    click FlaskAPI "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/app.py"
    click CourseResource "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/resources/course_resource.py"
    click DegreeResource "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/resources/college_degree_resource.py"
    click CourseService "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/services/course_service.py"
    click DegreeService "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/services/college_degree_service.py"
    click DAO "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/db/cosmos_mongo_db.py"
    click Terraform "https://github.com/chukwuka1488/edupathfinder/blob/master/backend/terraform/main.tf"
    click AzurePipelines "https://github.com/chukwuka1488/edupathfinder/blob/master/azure-pipelines.yml"
    click DockerCompose "https://github.com/chukwuka1488/edupathfinder/blob/master/docker-compose.yaml"

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#D0F2D2,stroke:#228B22,color:#228B22;
    classDef infra fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00;
    classDef devops fill:#E0E0E0,stroke:#696969,color:#696969;
```
