# madihaj14/algolearn architecture

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

- Interactive diagram: https://gitdiagram.com/madihaj14/algolearn
- Repository: https://github.com/madihaj14/algolearn

## Overview

##### Project type and purpose
- From the README and file tree, AlgoLearn is a full-stack, single-page React application (built with Vite and Tailwind CSS) that visualizes Data Structures & Algorithms.
- It integrates authentication, persistent user progress (via Supabase), and external APIs (GPT, LeetCode/GFG) to drive its interactive practice and documentation pages.

##### File structure
- Top-level:
- package.json, vite.config.ts, tsconfig.* → front-end build/config
- index.html, src/main.tsx → SPA entry point
- postcss.config.js, tailwind.config.js, eslint.config.js → styling & linting
- src/components & src/pages → React component hierarchy (UI layer)
- src/lib/algorithms → pure algorithm implementations (visualizer back-end logic)
- src/lib/supabase.ts → data‐access layer for Supabase (auth & persistence)
- src/context & src/store → application state management (theme, auth, progress)
- src/data → static content and TypeScript types

##### README for additional insights
- Front-end: React + Tailwind, Vite
- Back-end: Supabase (instead of self-hosted Django/Flask as stubbed in the README), PostgreSQL
- API integrations: GPT, LeetCode, GFG

##### Detail
- Context and Store modules separately to highlight auth and theme flows.
- How algorithm functions (e.g., BFS, mergeSort) feed step data into the Visualizer component.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser SPA)"
        direction TB
        subgraph "UI Components"
            direction TB
            Navbar["Navbar Component"]:::ui
            Footer["Footer Component"]:::ui
            Cosmic["CosmicBackground"]:::ui
            AuthGuard["AuthGuard"]:::ui
            subgraph "Visualizer UI"
                direction TB
                AlgoVisComp["AlgorithmVisualizer"]:::ui
                VisButton["VisualizerButton"]:::ui
            end
            subgraph "Pages"
                direction TB
                Home["HomePage"]:::ui
                Algorithms["AlgorithmsPage"]:::ui
                DataStructures["DataStructuresPage"]:::ui
                Practice["PracticePage"]:::ui
                Progress["ProgressPage"]:::ui
                Documentation["DocumentationPage"]:::ui
                Login["LoginPage"]:::ui
                Signup["SignupPage"]:::ui
                UserProfile["UserProfile"]:::ui
                AlgoVisPage["AlgorithmVisualizerPage"]:::ui
            end
        end

        subgraph "State Management"
            direction TB
            ThemeCtx["ThemeContext"]:::state
            AuthStore["Authentication Store"]:::state
        end

        subgraph "Business Logic"
            direction TB
            AlgorithmsLib["Algorithms Library"]:::logic
        end

        subgraph "Data Access"
            direction TB
            SupabaseClient["supabase.ts"]:::data
            GPTClient["GPT API Client"]:::data
            LCClient["LeetCode API Client"]:::data
            GFGClient["GFG API Client"]:::data
        end
    end

    %% Services Layer
    subgraph "External Services"
        direction TB
        SupabaseDB["PostgreSQL (Supabase)"]:::service
        GPTAPI["GPT API"]:::service
        LCAPI["LeetCode API"]:::service
        GFGAPI["GFG API"]:::service
    end

    %% User interaction
    User["User"]:::ui -->|"interacts with"| Navbar
    User -->|"interacts with"| AuthGuard

    %% UI to State
    Navbar -->|"reads/writes"| ThemeCtx
    AuthGuard -->|"reads auth state"| AuthStore
    Home -->|"dispatch actions"| AuthStore
    Practice -->|"dispatch actions"| AuthStore

    %% UI to Business Logic
    AlgoVisComp -->|"calls"| AlgorithmsLib
    AlgorithmsLib -->|"returns steps"| AlgoVisComp

    %% State to UI
    ThemeCtx -->|"provides theme"| Navbar
    AuthStore -->|"provides user"| AuthGuard

    %% UI to Data Access
    AuthGuard -->|"calls"| SupabaseClient
    SupabaseClient -->|"queries"| SupabaseDB
    Practice -->|"fetch problems via"| LCClient
    Practice -->|"fetch problems via"| GFGClient
    Documentation -->|"fetch explanation via"| GPTClient
    GPTClient -->|"requests"| GPTAPI

    %% Click Events
    click Navbar "https://github.com/madihaj14/algolearn/blob/main/src/components/Navbar.tsx"
    click Footer "https://github.com/madihaj14/algolearn/blob/main/src/components/Footer.tsx"
    click Cosmic "https://github.com/madihaj14/algolearn/blob/main/src/components/CosmicBackground.tsx"
    click AuthGuard "https://github.com/madihaj14/algolearn/blob/main/src/components/auth/AuthGuard.tsx"
    click AlgoVisComp "https://github.com/madihaj14/algolearn/blob/main/src/components/visualizer/AlgorithmVisualizer.tsx"
    click VisButton "https://github.com/madihaj14/algolearn/blob/main/src/components/visualizer/VisualizerButton.tsx"
    click Home "https://github.com/madihaj14/algolearn/blob/main/src/pages/HomePage.tsx"
    click Algorithms "https://github.com/madihaj14/algolearn/blob/main/src/pages/AlgorithmsPage.tsx"
    click DataStructures "https://github.com/madihaj14/algolearn/blob/main/src/pages/DataStructuresPage.tsx"
    click Practice "https://github.com/madihaj14/algolearn/blob/main/src/pages/PracticePage.tsx"
    click Progress "https://github.com/madihaj14/algolearn/blob/main/src/pages/ProgressPage.tsx"
    click Documentation "https://github.com/madihaj14/algolearn/blob/main/src/pages/DocumentationPage.tsx"
    click Login "https://github.com/madihaj14/algolearn/blob/main/src/pages/auth/LoginPage.tsx"
    click Signup "https://github.com/madihaj14/algolearn/blob/main/src/pages/auth/SignupPage.tsx"
    click UserProfile "https://github.com/madihaj14/algolearn/blob/main/src/pages/auth/UserProfile.tsx"
    click AlgoVisPage "https://github.com/madihaj14/algolearn/blob/main/src/pages/visualization/AlgorithmVisualizerPage.tsx"
    click ThemeCtx "https://github.com/madihaj14/algolearn/blob/main/src/context/ThemeContext.tsx"
    click AuthStore "https://github.com/madihaj14/algolearn/blob/main/src/store/authStore.ts"
    click AlgorithmsLib "https://github.com/madihaj14/algolearn/blob/main/src/lib/algorithms/index.ts"
    click SupabaseClient "https://github.com/madihaj14/algolearn/blob/main/src/lib/supabase.ts"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#0366d6,color:#000
    classDef state fill:#fff3cd,stroke:#856404,color:#000
    classDef logic fill:#d4edda,stroke:#155724,color:#000
    classDef data fill:#ffe5b4,stroke:#d39e00,color:#000
    classDef service fill:#e2e3e5,stroke:#6c757d,color:#000
```
