# szeedneigh/learn-vanguard architecture

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

- Interactive diagram: https://gitdiagram.com/szeedneigh/learn-vanguard
- Repository: https://github.com/szeedneigh/learn-vanguard

## Overview

##### Project type and purpose
- From the file tree and README, Learn Vanguard is a single-page React application (built with Vite and Tailwind) that serves as a “Student Resource Hub.” There is no backend code in this repo—data and authentication are provided by external services (Firebase Auth, a REST API, and a WebSocket server).

##### File structure
- Top-level:
- public/ – static assets
- src/ – application code
- ├── app/ – page layouts and route wrappers (auth, dashboard, landing, 404, etc.)
- ├── components/ – reusable UI pieces, organized by domain (calendar, modal, ui primitives)
- ├── config/ – environment, Firebase, auth config
- ├── context/ – React Context providers (AuthContext, PermissionContext)
- ├── hooks/ – custom React hooks (API queries, toast, WebSocket, calendar state)
- ├── lib/ – low-level API clients, helpers, constants, navigation, react-query client
- ├── services/ – higher-level data-access services that wrap lib/api calls
- ├── utils/ – pure helper functions
- └── main.jsx, App.jsx – entry point and root component
- Ancillary config: vite.config.js, postcss.config.js, tailwind.config.js, vercel.json

##### README for additional insights
- The system uses:
- React + Vite + Tailwind + shadcn/ui for the frontend
- Firebase for authentication
- A custom REST API (announcement, event, resource, task, user, etc.)
- A WebSocket endpoint for real-time updates
- React Query (via lib/queryClient.js) for data fetching and caching
- Deployed on Vercel

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser & Entry
    Browser["User's Browser\n(Running React SPA)"]:::external
    Main["main.jsx"]:::frontend
    App["App.jsx"]:::frontend
    Browser -->|"Loads SPA"| Main
    Main -->|"Renders"| App

    %% UI Components Layer
    subgraph "UI Components" 
        direction TB
        UI_Auth["Auth Pages\n(src/app/auth)"]:::frontend
        UI_Dashboard["Dashboard Pages\n(src/app/dashboard)"]:::frontend
        UI_Landing["Landing Page\n(src/app/landing)"]:::frontend
        UI_Pages["Generic Pages\n(src/app/pages)"]:::frontend
        UI_Components["Reusable UI\n(src/components)"]:::frontend
    end
    App -->|"renders routes"| UI_Pages
    UI_Pages --> UI_Auth
    UI_Pages --> UI_Dashboard
    UI_Pages --> UI_Landing
    UI_Auth --> UI_Components
    UI_Dashboard --> UI_Components

    %% State Management Layer
    subgraph "State Management" 
        direction TB
        AuthCtx["AuthContext\n(src/context/AuthContext.jsx)"]:::state
        PermCtx["PermissionContext\n(src/context/PermissionContext.jsx)"]:::state
        QueryClient["React Query Client\n(src/lib/queryClient.js)"]:::state
        Hooks["Custom Hooks\n(src/hooks)"]:::state
    end
    UI_Pages -->|"useContext/useHooks"| AuthCtx
    UI_Pages --> PermCtx
    UI_Pages --> QueryClient
    UI_Pages --> Hooks

    %% Service Layer
    subgraph "Service Layer" 
        direction TB
        AnnouncementSvc["announcementService.js\n(src/services/announcementService.js)"]:::service
        EventSvc["eventService.js\n(src/services/eventService.js)"]:::service
        ResourceSvc["resourceService.js\n(src/services/resourceService.js)"]:::service
        TaskSvc["taskService.js\n(src/services/taskService.js)"]:::service
        UserSvc["userService.js\n(src/services/userService.js)"]:::service
        AuthSvc["authService.js\n(src/services/authService.js)"]:::service
        WebsocketSvc["websocketService.js\n(src/services/websocketService.js)"]:::service
    end
    Hooks -->|"calls service"| AnnouncementSvc
    Hooks --> EventSvc
    Hooks --> ResourceSvc
    Hooks --> TaskSvc
    Hooks --> UserSvc
    AuthCtx --> AuthSvc
    Hooks --> WebsocketSvc

    %% API Clients Layer
    subgraph "API Clients & WebSocket" 
        direction TB
        HTTP_Client["Axios Client\n(src/lib/api/client.js)"]:::api
        AnnApi["announcementApi.js\n(src/lib/api/announcementApi.js)"]:::api
        EventApi["eventApi.js\n(src/lib/api/eventApi.js)"]:::api
        ResourceApi["resourceApi.js\n(src/lib/api/resourceApi.js)"]:::api
        TaskApi["taskApi.js\n(src/lib/api/taskApi.js)"]:::api
        UserApi["userApi.js\n(src/lib/api/userApi.js)"]:::api
        WS_Client["WebSocket Service\n(src/lib/api/websocketService.js)"]:::api
    end
    AnnouncementSvc -->|"HTTP calls"| AnnApi
    EventSvc --> EventApi
    ResourceSvc --> ResourceApi
    TaskSvc --> TaskApi
    UserSvc --> UserApi
    AuthSvc --> HTTP_Client
    WebsocketSvc --> WS_Client
    HTTP_Client -->|"sends HTTP"| RESTAPI

    %% Configuration & Utils
    subgraph "Configuration & Environment" 
        direction TB
        FirebaseCfg["Firebase Config\n(src/config/firebase.js)"]:::config
        AuthCfg["Auth Settings\n(src/config/auth.js)"]:::config
        EnvCfg["Environment Vars\n(src/config/environment.js)"]:::config
    end
    AuthSvc --> FirebaseCfg
    AuthSvc --> AuthCfg
    Main --> EnvCfg

    subgraph "Utilities" 
        direction TB
        Utils["Helpers & Constants\n(src/utils)"]:::util
        LibUtils["Low-level Utils\n(src/lib/utils.js)"]:::util
    end
    Hooks --> Utils
    HTTP_Client --> LibUtils

    %% External Services & Data Store
    Firebase["Firebase Auth"]:::external
    RESTAPI["REST API Server"]:::external
    WS["WebSocket Server"]:::external
    DB["Database"]:::db

    AuthSvc -->|"token request"| Firebase
    HTTP_Client -->|"GET/POST etc."| RESTAPI
    WS_Client -->|"socket.emit/listen"| WS
    RESTAPI -->|"reads/writes"| DB
    WS -->|"push events"| WS_Client

    %% Click Events
    click Main "https://github.com/szeedneigh/learn-vanguard/blob/main/src/main.jsx"
    click App "https://github.com/szeedneigh/learn-vanguard/blob/main/src/App.jsx"
    click UI_Auth "https://github.com/szeedneigh/learn-vanguard/tree/main/src/app/auth"
    click UI_Dashboard "https://github.com/szeedneigh/learn-vanguard/tree/main/src/app/dashboard"
    click UI_Landing "https://github.com/szeedneigh/learn-vanguard/blob/main/src/app/landing/LandingPage.jsx"
    click UI_Pages "https://github.com/szeedneigh/learn-vanguard/tree/main/src/app/pages"
    click UI_Components "https://github.com/szeedneigh/learn-vanguard/tree/main/src/components"
    click AuthCtx "https://github.com/szeedneigh/learn-vanguard/blob/main/src/context/AuthContext.jsx"
    click PermCtx "https://github.com/szeedneigh/learn-vanguard/blob/main/src/context/PermissionContext.jsx"
    click QueryClient "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/queryClient.js"
    click Hooks "https://github.com/szeedneigh/learn-vanguard/tree/main/src/hooks"
    click AnnouncementSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/announcementService.js"
    click EventSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/eventService.js"
    click ResourceSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/resourceService.js"
    click TaskSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/taskService.js"
    click UserSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/userService.js"
    click AuthSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/authService.js"
    click WebsocketSvc "https://github.com/szeedneigh/learn-vanguard/blob/main/src/services/websocketService.js"
    click HTTP_Client "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/client.js"
    click AnnApi "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/announcementApi.js"
    click EventApi "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/eventApi.js"
    click ResourceApi "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/resourceApi.js"
    click TaskApi "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/taskApi.js"
    click UserApi "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/userApi.js"
    click WS_Client "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/api/websocketService.js"
    click FirebaseCfg "https://github.com/szeedneigh/learn-vanguard/blob/main/src/config/firebase.js"
    click AuthCfg "https://github.com/szeedneigh/learn-vanguard/blob/main/src/config/auth.js"
    click EnvCfg "https://github.com/szeedneigh/learn-vanguard/blob/main/src/config/environment.js"
    click Utils "https://github.com/szeedneigh/learn-vanguard/tree/main/src/utils"
    click LibUtils "https://github.com/szeedneigh/learn-vanguard/blob/main/src/lib/utils.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef state fill:#E6FFEA,stroke:#28A745,color:#28A745
    classDef service fill:#FFF5D7,stroke:#FFA500,color:#FFA500
    classDef api fill:#FFEFD5,stroke:#FF8C00,color:#FF8C00
    classDef config fill:#F0F0F0,stroke:#6A737D,color:#6A737D
    classDef util fill:#F5E6FF,stroke:#8A2BE2,color:#8A2BE2
    classDef external fill:#FFD6D6,stroke:#DC3545,color:#DC3545
    classDef db fill:#F0F0F0,stroke:#8B4513,color:#8B4513,shape:cylinder
```
