# margothuet/quantumcamp-webapp architecture

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

- Interactive diagram: https://gitdiagram.com/margothuet/quantumcamp-webapp
- Repository: https://github.com/margothuet/quantumcamp-webapp

## Overview

##### Project Type and Purpose
- The project is a full‐stack web application.
- The README shows separate commands to run and test both the frontend and backend, and Docker run commands indicate containerized deployments.
- It integrates Supabase (as seen in both frontend and backend files—clientSupabase.ts, backendSupabase.ts) for database or authentication needs.
- There’s a strong focus on modularity with clearly separated concerns for frontend (Next.js-based structure with /src/app and components) and backend (an Express/Node.js application with routes, views, and a designated public folder).

##### Analyzing the File Structure
- Top-Level Directories:
- "frontend": Contains Next.js configuration (next.config.mjs, tsconfig.json, etc.), pages or app structure (under /src/app with routes such as login, signup, learn, etc.), public assets, and tests.
- "backend": Contains a Node.js/TypeScript implementation with routes (files like routes/answers.ts, users.ts, etc.), view templates (using Jade), public assets (stylesheets), and scripts (SQL for seeding or migrations).
- Additional Directories:
- .github directory for CI/CD workflows (ci-workflow.yml, cd-workflow.yml, release-drafter config).
- Docker-related configurations (Dockerfile in both frontend and backend, docker-compose.yaml).
- The presence of tests in both frontend and backend, as well as linting configurations, indicates a well-structured development pipeline.

##### Details
a. Main Components:
- Frontend
- Built using Next.js (React framework). Contains pages, components, and styling.
- Communicates with the backend using API calls.
- Integrates Supabase authentication via supabaseAuth.ts.
- Backend
- Likely built on Express in TypeScript.
- Organizes API endpoints in routes (answers, chapters, courses, progress, users).
- Contains views templates (Jade) for server-rendered pages.
- Manages database interactions possibly through Supabase utilities (see backendSupabase.ts and clientSupabase.ts).
- External Services & Database:
- Supabase is used for authentication and data storage.
- Potential CI/CD systems (GitHub Actions) to automate deployments.
- Containerization:
- Docker images for both frontend and backend.
- Docker Compose used to orchestrate the services, allowing seamless local deployment.

b. Relationships and Interactions:
- Bidirectional communication between the Frontend and Backend over HTTP/REST APIs.
- Backend communicating with Supabase (or any database) for data persistence.
- Interaction flows for testing and linting as parts of the CI/CD pipeline.
- Deployment flow from GitHub Actions (illustrated as an external CI/CD system triggering Docker builds and deployments).

c. Architectural Patterns / Design Principles:
- Separation of Concerns: Clear division between frontend (UI, client-side logic, Next.js pages/components) and backend (API endpoints, business logic, view rendering).
- Layered Architecture: The backend handles API routing, views rendering, and database access via dedicated modules.
- Containerization: Use of Docker ensures consistent environment deployments.
- CI/CD Integration: GitHub workflows as part of the DevOps cycle ensuring continuous integration and delivery.

d. Key Technologies and Frameworks:
- Frontend: Next.js, React, Tailwind CSS (noted via tailwind.config.ts), Jest for testing.
- Backend: Node.js/TypeScript, Express (implied by the structure and routes), Jade templating, ESLint for linting, Jest for tests.
- Database/External Service: Supabase (integration within both frontend and backend for client and backend operations).
- DevOps: Docker and Docker Compose for containerization; GitHub Actions for automated builds, testing, and deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Frontend Application
    subgraph "Frontend Application"
        FE_App["Pages (Next.js)"]:::frontend
        FE_SupabaseAuth["Supabase Auth Integration"]:::frontend
        FE_ClientSupabase["Client-Side Supabase"]:::frontend
        FE_Components["Components"]:::frontend
        FE_Style["Global Styles"]:::frontend
    end

    %% Backend Application
    subgraph "Backend Application"
        BE_Server["Main Server Entry"]:::backend
        BE_Routes["API Endpoints"]:::backend
        BE_Views["View Templates"]:::backend
        BE_Supabase["Backend Supabase Integration"]:::backend
        BE_ClientSupabase["Backend Client Supabase"]:::backend
    end

    %% External Services
    subgraph "External Services"
        Supabase_DB["Supabase Database"]:::external
    end

    %% DevOps Section
    subgraph "DevOps"
        %% Containerization Subgraph
        subgraph "Containerization"
            Docker_FE["Frontend Docker"]:::devops
            Docker_BE["Backend Docker"]:::devops
            Docker_Compose["Docker Compose"]:::devops
        end
        %% Code Quality & Testing Subgraph
        subgraph "Code Quality & Testing"
            ESLint_FE["Frontend ESLint"]:::devops
            ESLint_BE["Backend ESLint"]:::devops
            Testing_FE["Frontend Testing"]:::devops
            Testing_BE["Backend Testing"]:::devops
        end
        CI_CD["CI/CD Workflows"]:::devops
    end

    %% Relationships between Application Layers
    FE_App -->|"APIcalls"| BE_Server
    FE_SupabaseAuth -->|"auth"| Supabase_DB
    FE_ClientSupabase -->|"client-Supabase"| Supabase_DB
    BE_Supabase -->|"DBops"| Supabase_DB
    BE_ClientSupabase -->|"client-access"| Supabase_DB

    %% Relationships from DevOps
    ESLint_FE --> CI_CD
    ESLint_BE --> CI_CD
    Testing_FE --> CI_CD
    Testing_BE --> CI_CD
    CI_CD --> Docker_Compose
    Docker_Compose -->|"deploys"| FE_App
    Docker_Compose -->|"deploys"| BE_Server

    %% Click Events for Frontend
    click FE_App "https://github.com/margothuet/quantumcamp-webapp/tree/main/frontend/src/app"
    click FE_SupabaseAuth "https://github.com/margothuet/quantumcamp-webapp/blob/main/frontend/supabaseAuth.ts"
    click FE_ClientSupabase "https://github.com/margothuet/quantumcamp-webapp/blob/main/frontend/clientSupabase.js"
    click FE_Components "https://github.com/margothuet/quantumcamp-webapp/tree/main/frontend/src/components"
    click FE_Style "https://github.com/margothuet/quantumcamp-webapp/blob/main/frontend/src/app/globals.css"

    %% Click Events for Backend
    click BE_Server "https://github.com/margothuet/quantumcamp-webapp/blob/main/backend/app.ts"
    click BE_Server "https://github.com/margothuet/quantumcamp-webapp/blob/main/backend/bin/www.ts"
    click BE_Routes "https://github.com/margothuet/quantumcamp-webapp/tree/main/backend/routes"
    click BE_Views "https://github.com/margothuet/quantumcamp-webapp/tree/main/backend/views"
    click BE_Supabase "https://github.com/margothuet/quantumcamp-webapp/blob/main/backend/backendSupabase.ts"
    click BE_ClientSupabase "https://github.com/margothuet/quantumcamp-webapp/blob/main/backend/clientSupabase.ts"

    %% Click Events for Containerization
    click Docker_FE "https://github.com/margothuet/quantumcamp-webapp/tree/main/frontend/Dockerfile"
    click Docker_BE "https://github.com/margothuet/quantumcamp-webapp/tree/main/backend/Dockerfile"
    click Docker_Compose "https://github.com/margothuet/quantumcamp-webapp/blob/main/docker-compose.yaml"

    %% Click Events for Code Quality & Testing
    click ESLint_FE "https://github.com/margothuet/quantumcamp-webapp/blob/main/frontend/.eslintrc.json"
    click ESLint_BE "https://github.com/margothuet/quantumcamp-webapp/blob/main/backend/.eslintrc.js"
    click Testing_FE "https://github.com/margothuet/quantumcamp-webapp/blob/main/frontend/jest.config.js"
    click Testing_BE "https://github.com/margothuet/quantumcamp-webapp/blob/main/backend/jest.config.cjs"

    %% Click Event for CI/CD Workflows
    click CI_CD "https://github.com/margothuet/quantumcamp-webapp/tree/main/.github/workflows"

    %% Styles
    classDef frontend fill:#aee,stroke:#333,stroke-width:2px;
    classDef backend fill:#afa,stroke:#333,stroke-width:2px;
    classDef devops fill:#ff9,stroke:#333,stroke-width:2px;
    classDef external fill:#faa,stroke:#333,stroke-width:2px;
```
