# casa-del-dev/bachelor-frontend architecture

> Architecture diagram of the GitHub repository casa-del-dev/bachelor-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/casa-del-dev/bachelor-frontend
- Repository: https://github.com/casa-del-dev/bachelor-frontend

## Overview

##### Project type and purpose
- This is a single‐page web application (SPA) built with React, TypeScript, and Vite.
- Its purpose is to deliver an interactive coding/tutorial environment: it manages authentication, code editing/running, problem statements, AI‐powered assistance components, and integration with external services like GitHub or a code‐execution API.

##### File structure
- Top level:
- index.html + public/ – static entrypoint and assets (e.g. VideoClip.mp4).
- vite.config.ts, tsconfig*.json, eslint.config.js – build, type, and lint configurations.
- routes.json – SPA routing configuration (e.g. for Netlify).
- src/:
- main.tsx – React application bootstrap.
- App.tsx, Layout.tsx – high‐level routing and layout.
- Contexts: ApiContext.tsx, AuthContext.tsx, CodeContext.tsx – state & side‐effect management.
- components/:
– Feature components (AI_Abstract, AI_Check, Problem_detail, Project_files, etc.).
– Auth/UI pages (Login, SignUp, Profile, Welcome).
- No server‐side code here, so all business logic lives client‐side or is delegated to external services.

##### Extract insights from README
- Provides only the standard Vite + React + TS template instructions.

a. Main components
1) Browser / User’s Device – loads the SPA via index.html.
2) Static Asset Host / CDN – serves built JavaScript, CSS, media from public/ and dist/.
3) React SPA – composed of:
- Presentation Layer: Layout, App, Feature pages (Login, Problem, AI_Editor, etc.).
- UI Components Library: BuildingBlocks/* and shared components.
- Context Layer:
– AuthContext – handles login/logout flows, JWT/storage, token renewal.
– ApiContext – wraps all HTTP calls, injects auth tokens, error handling.
– CodeContext – manages code state, execution requests, results.
4) External Services:
- Authentication Provider (e.g. Auth0, custom API).
- Code Execution API (to compile/run user code).
- GitHub API – accessed by GitHubComponent for repo integration.
- AI Services – e.g. OpenAI for prompts, abstraction, equality checking.
b. Relationships & interactions
- User → Browser → React SPA UI
- UI components dispatch actions to Contexts → Contexts invoke ApiContext or CodeContext
- ApiContext routes calls to Auth Provider, GitHub API, AI endpoints
- CodeContext sends code to Execution API, receives output
- Contexts update global state → UI re‐renders
c. Architectural patterns & design principles
- Component‐Based UI (React function components with CSS modules).
- Context API for state & side effects (avoiding prop drilling).
- Separation of concerns: UI vs. business logic vs. data access.
- Layered architecture: Presentation → Application (contexts) → Infrastructure (API).
d. Key technologies/frameworks
- React 18 + TypeScript + Vite (+ HMR)
- ESLint with recommended & type‐checked rules
- xterm.js (optional) for terminal emulation
- CSS modules / plain .css per component
- Deployment: static hosting (Netlify, Vercel, or S3+CDN)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Infrastructure Layer
    subgraph "Infrastructure" 
        direction TB
        CDN["Static Asset Host / CDN"]:::infra
        VITECFG["vite.config.ts"]:::infra
        TSCONFIG["tsconfig*.json"]:::infra
        ESLINT["eslint.config.js"]:::infra
        ROUTES["routes.json"]:::infra
    end

    %% Client Layer
    subgraph "Client"
        direction TB
        BROWSER["Browser / User’s Device"]:::infra
        INDEX["index.html"]:::infra
    end

    %% React SPA Layer
    subgraph "React SPA" 
        direction TB

        %% Bootstrap
        MAIN["main.tsx"]:::logic

        %% Shell
        subgraph "Shell" 
            direction TB
            APP["App.tsx"]:::ui
            LAYOUT["Layout.tsx"]:::ui
        end

        %% State & Data Layer
        subgraph "Contexts (State & Data)" 
            direction TB
            AUTHCTX["AuthContext"]:::logic
            APICXT["ApiContext"]:::logic
            CODECTX["CodeContext"]:::logic
        end

        %% UI Library
        subgraph "UI Library (BuildingBlocks)" 
            direction TB
            UIBB["BuildingBlocks/*"]:::ui
        end

        %% Presentation Layer
        subgraph "Feature Pages & UI Screens" 
            direction TB
            LOGIN["Login"]:::ui
            SIGNUP["SignUp"]:::ui
            PROFILE["Profile"]:::ui
            WELCOME["Welcome"]:::ui
            WELCOME_TEXT["Welcome_text"]:::ui
            PROBLEM["Problem"]:::ui
            PROB_DETAIL["Problem_detail"]:::ui
            PROJECT_FILES["Project_files"]:::ui
            PROGRAM_IF["Program-interface"]:::ui
            REDIRECT["Redirect"]:::ui

            %% AI Components
            subgraph "AI-Powered Components"
                direction TB
                AI_ABS["AI_Abstract"]:::ui
                AI_CHECK["AI_Check"]:::ui
                AI_ED["AI_Editor"]:::ui
                AI_EQ["AI_EqualityCheck"]:::ui
                AI_PROMPT["AI_Prompt"]:::ui
                AI_TREE["AI_Tree"]:::ui
            end

            GITHUB["GitHubComponent"]:::ui
        end

        %% Assets
        VIDEO["VideoClip.mp4"]:::infra
    end

    %% External Services
    subgraph "External Services" 
        direction TB
        AUTH_SVC["Authentication Provider"]:::ext
        EXEC_SVC["Code Execution API"]:::ext
        GITHUB_API["GitHub API"]:::ext
        AI_SVC["AI Services"]:::ext
    end

    %% Connections
    BROWSER -->|"loads"| INDEX
    INDEX -->|"serves SPA"| MAIN
    CDN -->|"serves assets"| INDEX
    CDN -->|"serves assets"| VIDEO

    MAIN -->|"renders"| APP
    APP -->|"uses layout"| LAYOUT

    APP -->|"provides contexts"| AUTHCTX
    APP -->|"provides contexts"| APICXT
    APP -->|"provides contexts"| CODECTX

    AUTHCTX -->|"injects token"| APICXT
    APICXT -->|"POST /login"| AUTH_SVC
    APICXT -->|"GET /repos"| GITHUB_API
    APICXT -->|"calls AI"| AI_SVC
    CODECTX -->|"runCode()"| EXEC_SVC

    %% UI consumption
    LOGIN -->|"use AuthContext"| AUTHCTX
    SIGNUP -->|"use AuthContext"| AUTHCTX
    PROFILE -->|"use AuthContext"| AUTHCTX
    WELCOME -->|"use ApiContext"| APICXT
    PROBLEM -->|"use CodeContext"| CODECTX
    PROB_DETAIL -->|"use ApiContext"| APICXT
    PROJECT_FILES -->|"use ApiContext"| APICXT
    PROGRAM_IF -->|"use CodeContext"| CODECTX
    REDIRECT -->|"use ApiContext"| APICXT

    AI_ABS -->|"use ApiContext"| APICXT
    AI_CHECK -->|"use ApiContext"| APICXT
    AI_ED -->|"use ApiContext"| APICXT
    AI_EQ -->|"use ApiContext"| APICXT
    AI_PROMPT -->|"use ApiContext"| APICXT
    AI_TREE -->|"use ApiContext"| APICXT

    GITHUB -->|"use ApiContext"| APICXT

    APP -->|"consumes UI Library"| UIBB

    %% Click Events
    click BROWSER "https://github.com/casa-del-dev/bachelor-frontend/blob/main/index.html"
    click CDN "https://github.com/casa-del-dev/bachelor-frontend/tree/main/public/"
    click VIDEO "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/assets/VideoClip.mp4"
    click MAIN "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/main.tsx"
    click APP "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/App.tsx"
    click LAYOUT "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/Layout.tsx"
    click AUTHCTX "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/AuthContext.tsx"
    click APICXT "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/ApiContext.tsx"
    click CODECTX "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/CodeContext.tsx"
    click LOGIN "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Login.tsx"
    click SIGNUP "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/SignUp.tsx"
    click PROFILE "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Profile.tsx"
    click WELCOME "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Welcome.tsx"
    click WELCOME_TEXT "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Welcome_text.tsx"
    click PROBLEM "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Problem.tsx"
    click PROB_DETAIL "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Problem_detail.tsx"
    click PROJECT_FILES "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Project_files.tsx"
    click PROGRAM_IF "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Program-interface.tsx"
    click REDIRECT "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/Redirect.tsx"
    click AI_ABS "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/AI_Abstract.tsx"
    click AI_CHECK "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/AI_Check.tsx"
    click AI_ED "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/AI_Editor.tsx"
    click AI_EQ "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/AI_EqualityCheck.tsx"
    click AI_PROMPT "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/AI_Prompt.tsx"
    click AI_TREE "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/components/AI_Tree.tsx"
    click GITHUB "https://github.com/casa-del-dev/bachelor-frontend/blob/main/src/GitHubComponent.tsx"
    click UIBB "https://github.com/casa-del-dev/bachelor-frontend/tree/main/src/components/BuildingBlocks/"
    click VITECFG "https://github.com/casa-del-dev/bachelor-frontend/blob/main/vite.config.ts"
    click TSCONFIG "https://github.com/casa-del-dev/bachelor-frontend/blob/main/tsconfig.json"
    click ESLINT "https://github.com/casa-del-dev/bachelor-frontend/blob/main/eslint.config.js"
    click ROUTES "https://github.com/casa-del-dev/bachelor-frontend/blob/main/routes.json"

    %% Styles
    classDef ui fill:#e0f7ea,stroke:#2e7d32,stroke-width:1px
    classDef logic fill:#e3f2fd,stroke:#1565c0,stroke-width:1px
    classDef ext fill:#ffe0b2,stroke:#ef6c00,stroke-width:1px
    classDef infra fill:#eeeeee,stroke:#9e9e9e,stroke-width:1px
```
