# julianz-cd/uwvault architecture

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

- Interactive diagram: https://gitdiagram.com/julianz-cd/uwvault
- Repository: https://github.com/julianz-cd/uwvault

## Overview

##### Main Components
- Frontend Layer: Represent your Next.js client that includes numerous pages, components, hooks, and tests. This layer is responsible for rendering the UI for user authentication, resource management, course details, and other features.
- Storage Layer: Show the persistence mechanism:
- PostgreSQL for user data, course information, and resource metadata.
- ElasticSearch for document indexing and course search functionalities.
- GCP Cloud Storage to handle file storage for course documents and additional resource files.
- CI/CD Pipeline: Demonstrate how GitHub workflows trigger tests, builds, and the container registry, which then deploy the built images into your infrastructure.
- Infrastructure: Include Docker for containerization and the cloud hosting environment (GCP Compute Engine) that runs your containers and storage services.

##### Detail the Relationships and Interactions
- Backend to Storage: Connect the backend services (e.g., auth, resource, course) to the storage components, showing how data operations (CRUD operations) and search queries are handled.
- Infrastructure Integration: Show that Docker containers and GCP Compute Engine host both the backend services and databases (PostgreSQL, ElasticSearch, Cloud Storage).

##### Architectural Patterns and Design Principles
- Modularity: Emphasize the separation of concerns between the frontend and backend. Each API service (organized under /api/services) is well isolated.
- Routing and Rewrites: The Next.js configuration employs rewrites to seamlessly integrate FastAPI endpoints into the same domain.
- Testing: Note the thorough testing infrastructure with unit, integration, and end-to-end tests in both API and app directories.
- CI/CD Automation: The use of GitHub workflows ensures continuous integration and smooth deployment flow.

##### Relevant Technologies & Frameworks
- Frontend: Next.js, React, Tailwind CSS.
- Backend: Python, FastAPI.
- Databases & Storage: PostgreSQL, ElasticSearch, GCP Cloud Storage.
- Additional Tooling: Docker, GitHub Actions, ESLint, PyTest, and various testing frameworks for both backend and frontend.

##### Putting It All Together
- Next, isolate your “Frontend” and “Backend” clusters, clearly showing the Next.js app in one cluster and the FastAPI services in the other.

## Diagram (Mermaid)

```mermaid
graph TD
    %% CI/CD Pipeline Cluster
    subgraph "CI/CD Pipeline"
        A["GitHub Repository"]:::cicd
        B["Test&Lint"]:::cicd
        C["Build&Package"]:::cicd
        D["PushImage"]:::cicd
        E["Deploy"]:::cicd
        A --> B
        B --> C
        C --> D
        D --> E
    end

    %% Infrastructure Cluster
    subgraph "Infrastructure"
        F["Docker Containers"]:::infrastructure
        G["GCP Compute Engine"]:::infrastructure
        F --> G
    end

    %% Frontend Cluster
    subgraph "Frontend"
        H["Next.js Client"]:::frontend
    end

    %% Backend Cluster
    subgraph "Backend"
        I["FastAPI Server"]:::backend
        subgraph "API Services"
            J["Auth Service"]:::backend
            K["Course Service"]:::backend
            L["Resource Service"]:::backend
            M["Todo Service"]:::backend
        end
        I --> J
        I --> K
        I --> L
        I --> M
    end

    %% Storage Cluster
    subgraph "Storage"
        N["PostgreSQL Database"]:::storage
        O["ElasticSearch"]:::storage
        P["GCP Cloud Storage"]:::storage
    end

    %% Interactions
    H -->|"API_calls"| I
    I -->|"DataOps"| N
    I -->|"SearchOps"| O
    I -->|"FileOps"| P
    E --> F
    F --> H
    F --> I

    %% Styles
    classDef cicd fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef frontend fill:#a1d490,stroke:#333,stroke-width:2px;
    classDef backend fill:#f48fb1,stroke:#333,stroke-width:2px;
    classDef storage fill:#81d4fa,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#ce93d8,stroke:#333,stroke-width:2px;

    %% Click Events
    click H "https://github.com/julianz-cd/uwvault/tree/main/app/"
    click I "https://github.com/julianz-cd/uwvault/tree/main/api/"
    click J "https://github.com/julianz-cd/uwvault/blob/main/api/services/auth_service.py"
    click J "https://github.com/julianz-cd/uwvault/blob/main/api/routers/auth_router.py"
    click K "https://github.com/julianz-cd/uwvault/blob/main/api/services/auth_course_service.py"
    click K "https://github.com/julianz-cd/uwvault/blob/main/api/routers/course_router.py"
    click L "https://github.com/julianz-cd/uwvault/blob/main/api/services/resource_service.py"
    click L "https://github.com/julianz-cd/uwvault/blob/main/api/routers/resources_router.py"
    click M "https://github.com/julianz-cd/uwvault/blob/main/api/services/todo_service.py"
    click M "https://github.com/julianz-cd/uwvault/blob/main/api/routers/todo_router.py"
    click E "https://github.com/julianz-cd/uwvault/tree/main/.github/workflows/"
```
