# vikasraog6/online-tutorial-web-app-frontend architecture

> Architecture diagram of the GitHub repository vikasraog6/online-tutorial-web-app-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vikasraog6/online-tutorial-web-app-frontend
- Repository: https://github.com/vikasraog6/online-tutorial-web-app-frontend

## Overview

##### Project Type and Purpose
- This is a single-page application (SPA) built with React and bundled by Vite.
- It provides an educational dashboard (pages like Courses, Quizzes, ManageCourses, etc.) and includes an AuthContext for user authentication.
- It is deployed as a static web app (Azure Static Web Apps) via GitHub Actions.

##### File Structure
- **src/**: Contains React components (App.jsx, pages/), context/AuthContext.jsx for state management, and utils/api.js for REST calls.
- **public/index.html** & **src/index.html**: HTML templates.
- **Vite config & ESLint config**: vite.config.js, eslint.config.js drive the build/tooling.
- **.github/workflows/**: Three Azure Static Web Apps CI/CD pipelines.

##### Core Components
a. Developer Environment
- IDE / Local machine
- Node.js / npm (or yarn)
- Vite Dev Server (HMR)
b. Source Code & CI/CD
- GitHub repository
- GitHub Actions workflows (azure-static-web-apps-*.yml)
- Build step (vite build)
- Deploy step (Azure Static Web Apps)
c. Hosting & Runtime
- Azure Static Web Apps (serves built JS/CSS/HTML)
- CDN layer (optional, if used by Azure)
d. Client & Browser
- React SPA running in user’s browser
- React Context for auth, React Router for page navigation
e. API Layer & External Services
- utils/api.js → calls external REST API endpoints (e.g., your backend service)
- Authentication provider (could be Firebase/Auth0/custom backend)
- Backend service(s) & database (PostgreSQL, MongoDB, etc.)

##### Relationships & Data Flows
- Developer → (push) → GitHub
- GitHub Actions → (build) → Vite bundles static assets → (deploy) → Azure Static Web Apps
- Browser → (GET) → Azure Static Web Apps → serves index.html + JS/CSS
- React SPA → (XHR/Fetch via utils/api.js) → Backend API → Database
- React Context/AuthContext → manages login/logout, token storage → Auth provider

##### Architectural Patterns & Technologies
- SPA pattern: all routing & UI rendering client-side
- Context API for global state (authentication)
- Module-based file structure: components in pages/, assets in assets/, utilities in utils/
- Vite for fast development (HMR) and optimized production builds
- ESLint for code quality
- GitOps-style CI/CD via GitHub Actions and Azure Static Web Apps

##### Must-Include Elements
- Build step: **vite build**
- Deployment: **Azure Static Web Apps**
- Client: **Browser** running **React SPA**
- Internal SPA sub-components: **AuthContext**, **Pages**, **API Utils**
- External: **API Server** → **Database**, **Auth Provider**

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Layer
    subgraph "Development Environment"
        direction TB
        DevMachine["Developer Machine\nIDE / Editor"]:::developer
        NodeNpm["Node.js & npm"]:::developer
        ViteDev["Vite Dev Server (HMR)"]:::developer
    end

    DevMachine -->|"runs on"| NodeNpm
    NodeNpm -->|"starts"| ViteDev

    %% Source Control & CI/CD
    subgraph "Source Control & CI/CD"
        direction TB
        GitHubRepo["GitHub Repository"]:::cicd
        GHWorkflows["GitHub Actions Workflows\n(.github/workflows/*.yml)"]:::cicd
        BuildStep["vite build"]:::cicd
        DeployStep["Deploy to Azure Static Web Apps"]:::cicd
    end

    ViteDev -->|"git push"| GitHubRepo
    GitHubRepo --> GHWorkflows
    GHWorkflows -->|"build"| BuildStep
    BuildStep -->|"deploy artifacts"| DeployStep

    %% Hosting Layer
    subgraph "Hosting & Network"
        direction TB
        AzureSWA["Azure Static Web Apps"]:::hosting
        CDN["CDN / Global Distribution"]:::hosting
    end

    DeployStep --> AzureSWA
    AzureSWA --> CDN

    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        Browser["User Browser"]:::client
        ReactSPA["React SPA\n(App.jsx)"]:::client
        AuthContextComp["AuthContext"]:::client
        PagesComp["Pages (Dashboard, Courses, Quizzes)"]:::client
        APIUtils["API Utilities"]:::client
        EntryPoint["main.jsx"]:::client
    end

    CDN -->|"http GET index.html + JS/CSS"| Browser
    Browser --> ReactSPA
    ReactSPA --> EntryPoint
    ReactSPA --> AuthContextComp
    ReactSPA --> PagesComp
    ReactSPA --> APIUtils

    %% External Services
    subgraph "External Backends"
        direction TB
        AuthProvider["Authentication Provider"]:::external
        APIService["Backend Service (REST API)"]:::external
        Database["Database (PostgreSQL/MongoDB)"]:::external
    end

    APIUtils -->|"API request/response"| APIService
    AuthContextComp -->|"token exchange"| AuthProvider
    APIService --> Database

    %% Static & Config Files
    subgraph "Project Files"
        direction TB
        RootHTML["index.html"]:::static
        SrcHTML["src/index.html"]:::static
        Assets["src/assets/images/"]:::static
        ViteConfig["vite.config.js"]:::static
        ESLintConfig["eslint.config.js"]:::static
        PackageJSON["package.json"]:::static
        PublicFolder["public/"]:::static
    end

    DevMachine --> RootHTML
    DevMachine --> SrcHTML
    DevMachine --> Assets
    DevMachine --> ViteConfig
    DevMachine --> ESLintConfig
    DevMachine --> PackageJSON
    DevMachine --> PublicFolder

    %% Click Events
    click AuthContextComp "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/src/context/AuthContext.jsx"
    click APIUtils "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/src/utils/api.js"
    click ReactSPA "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/src/App.jsx"
    click EntryPoint "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/src/main.jsx"
    click PagesComp "https://github.com/vikasraog6/online-tutorial-web-app-frontend/tree/main/src/pages/"
    click RootHTML "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/index.html"
    click SrcHTML "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/src/index.html"
    click Assets "https://github.com/vikasraog6/online-tutorial-web-app-frontend/tree/main/src/assets/images/"
    click ViteConfig "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/vite.config.js"
    click ESLintConfig "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/eslint.config.js"
    click PackageJSON "https://github.com/vikasraog6/online-tutorial-web-app-frontend/blob/main/package.json"
    click GHWorkflows "https://github.com/vikasraog6/online-tutorial-web-app-frontend/tree/main/.github/workflows/"
    click PublicFolder "https://github.com/vikasraog6/online-tutorial-web-app-frontend/tree/main/public/"

    %% Styles
    classDef developer fill:#FFD580,stroke:#333,stroke-width:1px
    classDef cicd fill:#80C0FF,stroke:#333,stroke-width:1px
    classDef hosting fill:#A0FFA0,stroke:#333,stroke-width:1px
    classDef client fill:#FFB0B0,stroke:#333,stroke-width:1px
    classDef external fill:#D0D0D0,stroke:#333,stroke-width:1px
    classDef static fill:#FFE4B5,stroke:#333,stroke-width:1px
```
