# arthurhoang15/learnflow-front-end-webapp architecture

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

- Interactive diagram: https://gitdiagram.com/arthurhoang15/learnflow-front-end-webapp
- Repository: https://github.com/arthurhoang15/learnflow-front-end-webapp

## Overview

##### Project type and purpose
- This is a single-page application (SPA) front-end built with ReactJS and Vite in TypeScript. It powers the UI of **LearnFlow**, an interactive, gamified English-learning platform.
- It provides routing between “pages” (Home, Login, Stories, Smart Learning, Admin panels, etc.), reusable UI components, an API-calling layer, and mock data for local development.

##### File structure
- Top-level:
- public/index.html → HTML entry point
- src/main.tsx → React entry point, mounts `<App/>`
- src/App.tsx → Defines top-level router and layout
- vite.config.ts / tsconfig*.json → Build and tooling config
- vercel.json → Deployment config
- Under src:
- src/pages/… → Route-level components (one per URL)
- src/components/… → Reusable UI widgets (cards, navbars, modals)
- src/api/… → Service modules to call backend REST endpoints (dictionary, faq)
- src/mocks/data/… → JSON fixtures for offline/dev mode
- src/assets/images → Static assets imported by components
- src/routes/index.tsx → Route definitions for React Router

##### README for additional insights
- Confirms ReactJS, responsive UI, user authentication (incl. Google OAuth2), gamified lessons, community features, progress tracking.
- Mentions “services” for API logic (in this codebase under src/api).
- Describes typical dev workflow and branch/commit conventions.

##### Thoroughness
- Every folder’s responsibility: pages vs. components vs. api vs. mocks vs. assets
- SPA pattern and its data-flow (user action → component → service → backend → state → render)
- Don’t omit any key path (e.g., OAuth, mock bypass, static asset loading)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure
    subgraph "Static Host (Vercel/CDN)" 
        direction TB
        Vercel["Vercel/CDN"]:::infra
        HTML["index.html"]:::infra
    end

    %% Client
    Browser["Browser / Client"]:::frontend

    %% React Application
    subgraph "React Application" 
        direction TB
        Entry["src/main.tsx"]:::frontend
        Shell["App Shell & Router"]:::frontend
        Pages["Route-Level Pages (src/pages/)"]:::frontend
        Components["UI Components (src/components/)"]:::frontend
        Styles["Global Styles (src/index.css, src/App.css)"]:::frontend
    end

    %% Data Layer
    subgraph "API Layer" 
        direction TB
        Dict["dictionary.ts"]:::frontend
        FAQ["faq.ts"]:::frontend
    end

    subgraph "Mock Data (dev only)" 
        direction TB
        Mocks["src/mocks/data/"]:::dev
    end

    %% Assets and Config
    subgraph "Static Assets" 
        direction TB
        Assets["src/assets/images/"]:::frontend
    end

    subgraph "Build & Tooling Config" 
        direction TB
        ViteConfig["vite.config.ts"]:::infra
        TSConfigAll["tsconfig*.json"]:::infra
        ESLint["eslint.config.js"]:::infra
        EnvTypes["vite-env.d.ts"]:::infra
    end

    %% External Systems
    subgraph "External Services"
        direction TB
        Backend["Backend REST API"]:::external
        OAuth2["Google OAuth2 Provider"]:::external
    end

    %% Connections
    Browser -->|"fetch index.html"| Vercel
    Vercel -->|"serves index.html"| Browser
    Browser -->|"loads bundle"| Entry
    Entry -->|"mounts <App/>"| Shell
    Shell -->|"uses routes"| Pages
    Shell -->|"renders layout"| Components
    Shell -->|"imports styles"| Styles
    Pages -->|"compose UI"| Components
    Components -->|"calls service"| Dict
    Components -->|"calls service"| FAQ
    Dict -->|"HTTP JSON"| Backend
    FAQ -->|"HTTP JSON"| Backend
    Dict -->|"dev intercept"| Mocks
    FAQ -->|"dev intercept"| Mocks
    Components -->|"load images"| Assets
    Shell -->|"auth redirect"| OAuth2
    OAuth2 -->|"token exchange"| Backend

    %% Click Events
    click Vercel "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/vercel.json"
    click HTML "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/public/index.html"
    click Entry "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/main.tsx"
    click Shell "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/App.tsx"
    click Shell "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/routes/index.tsx"
    click Styles "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/index.css"
    click Styles "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/App.css"
    click Pages "https://github.com/arthurhoang15/learnflow-front-end-webapp/tree/main/src/pages/"
    click Components "https://github.com/arthurhoang15/learnflow-front-end-webapp/tree/main/src/components/"
    click Dict "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/api/dictionary.ts"
    click FAQ "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/src/api/faq.ts"
    click Mocks "https://github.com/arthurhoang15/learnflow-front-end-webapp/tree/main/src/mocks/data/"
    click Assets "https://github.com/arthurhoang15/learnflow-front-end-webapp/tree/main/src/assets/images/"
    click ViteConfig "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/vite.config.ts"
    click TSConfigAll "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/tsconfig.json"
    click ESLint "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/eslint.config.js"
    click EnvTypes "https://github.com/arthurhoang15/learnflow-front-end-webapp/blob/main/vite-env.d.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#007BFF,color:#003366
    classDef infra fill:#E6FFE6,stroke:#2E8B57,color:#006400
    classDef external fill:#FFF4E6,stroke:#FF8C00,color:#8B4000
    classDef dev stroke-dasharray: 5 5,fill:none,stroke:#FF00FF,color:#FF00FF
```
