# zeeguu/web architecture

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

- Interactive diagram: https://gitdiagram.com/zeeguu/web
- Repository: https://github.com/zeeguu/web

## Overview

##### Project type and purpose
- This is a React single-page application (SPA) bootstrapped with Create React App, intended for interactive language learning.
- It’s deployed as a Progressive Web App (PWA) on Firebase Hosting (see firebase.json), uses a service worker for offline support and calls out to a Zeeguu REST API (configured via REACT_APP_API_URL).
- It integrates with browser extensions/bookmarklets and a speech service for text-to-speech functionality.

##### File structure
- Top-level directories:
- src/ – application code, organized by feature rather than by type
- Key src subdirectories:
- api/ – modules to call each backend endpoint (accounts, articles, exercises, nlp, speech, teacher, etc.)
- components/, pages/, reader/, videos/, words/, exercises/, teacher/, userDashboard/ – UI organized by feature
- contexts/ – React Context providers for API, user, routing, navigation, speech, languages
- hooks/ – custom React hooks for timers, pagination, preferences, extension communication
- utils/ – general utilities (cookies, routing, text processing, extension, browser detection)
- .env.* defaults define the API URL for dev/prod; firebase.json shows hosting config; service-worker.js for caching strategy.

##### README for additional insights
- Emphasizes env var configuration, use of VS Code plugins, coding conventions (separate styled components, naming rules, “Notify” pattern).
- Notes the expectation of another Zeeguu project serving the teacher dashboard at /teacher-dashboard.

- Blue rectangles for front-end modules (UI, contexts, hooks)
- Hexagon for browser extension integration

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser and PWA
    subgraph "Browser / Client (Static Assets & PWA Shell)"
        direction TB
        PUBLIC["public/ (Static Assets & PWA Shell)"]:::hosting
        SW["Service Worker"]:::hosting
        MANIFEST["Web App Manifest"]:::hosting
    end
    click PUBLIC "https://github.com/zeeguu/web/tree/master/public/"
    click SW "https://github.com/zeeguu/web/blob/master/public/service-worker.js"
    click MANIFEST "https://github.com/zeeguu/web/blob/master/public/manifest.json"

    FIREBASE["Firebase Hosting"]:::hosting
    click FIREBASE "https://github.com/zeeguu/web/blob/master/firebase.json"

    PUBLIC -->|serves assets| FIREBASE
    FIREBASE -->|returns index.html, bundles| PUBLIC
    PUBLIC --> SW
    SW -->|caches assets & API calls| CACHE["Service Worker Cache"]:::storage
    subgraph "Local Persistence"
        direction TB
        LS["localStorage"]:::storage
        SS["sessionStorage"]:::storage
    end
    SW --> LS
    SW --> SS

    %% React Application
    ENTRY["React App Entry Point"]:::frontend
    click ENTRY "https://github.com/zeeguu/web/blob/master/src/index.js"
    SHELL["React App Shell"]:::frontend
    click SHELL "https://github.com/zeeguu/web/blob/master/src/App.js"
    ENTRY --> SHELL

    ROUTER["Main Routing Layer"]:::frontend
    click ROUTER "https://github.com/zeeguu/web/blob/master/src/MainAppRouter.js"
    SHELL --> ROUTER

    %% Auth Routes & Navigation
    PR1["PrivateRoute"]:::frontend
    click PR1 "https://github.com/zeeguu/web/blob/master/src/PrivateRoute.js"
    PR2["PrivateRouteWithMainNav"]:::frontend
    click PR2 "https://github.com/zeeguu/web/blob/master/src/PrivateRouteWithMainNav.js"
    MN["MainNavWithComponent"]:::frontend
    click MN "https://github.com/zeeguu/web/blob/master/src/MainNavWithComponent.js"
    MN_SC["MainNavWithComponent.sc.js"]:::frontend
    click MN_SC "https://github.com/zeeguu/web/blob/master/src/MainNavWithComponent.sc.js"
    ROUTER --> PR1
    ROUTER --> PR2
    PR2 --> MN
    MN --> MN_SC

    %% Context Providers
    subgraph "State & Context Providers"
        direction TB
        API_CTX["APIContext"]:::frontend
        USER_CTX["UserContext"]:::frontend
        ROUTE_CTX["RoutingContext"]:::frontend
        NAV_CTX["MainNavContext"]:::frontend
        SPEECH_CTX["SpeechContext"]:::frontend
        LANG_CTX["SystemLanguagesContext"]:::frontend
    end
    click API_CTX "https://github.com/zeeguu/web/blob/master/src/contexts/APIContext.js"
    click USER_CTX "https://github.com/zeeguu/web/blob/master/src/contexts/UserContext.js"
    click ROUTE_CTX "https://github.com/zeeguu/web/blob/master/src/contexts/RoutingContext.js"
    click NAV_CTX "https://github.com/zeeguu/web/blob/master/src/contexts/MainNavContext.js"
    click SPEECH_CTX "https://github.com/zeeguu/web/blob/master/src/contexts/SpeechContext.js"
    click LANG_CTX "https://github.com/zeeguu/web/blob/master/src/contexts/SystemLanguagesContext.js"

    SHELL --> API_CTX
    SHELL --> USER_CTX
    SHELL --> ROUTE_CTX
    SHELL --> NAV_CTX
    SHELL --> SPEECH_CTX
    SHELL --> LANG_CTX

    %% API Client Layer
    API_CLIENT["API Client Layer (src/api/*.js)"]:::backend
    click API_CLIENT "https://github.com/zeeguu/web/blob/master/src/api/*.js"
    API_CTX --> API_CLIENT

    %% Features
    subgraph "Feature Modules"
        direction TB
        ART["Articles Module"]:::frontend
        click ART "https://github.com/zeeguu/web/tree/master/src/articles/"
        RDR["Article Reader"]:::frontend
        click RDR "https://github.com/zeeguu/web/blob/master/src/reader/ArticleReader.js"
        EXER["Exercises Module"]:::frontend
        click EXER "https://github.com/zeeguu/web/blob/master/src/exercises/ExercisesRouter.js"
        VID["Videos Module"]:::frontend
        click VID "https://github.com/zeeguu/web/blob/master/src/videos/VideoPlayer.js"
        WORDS["Words Module"]:::frontend
        click WORDS "https://github.com/zeeguu/web/blob/master/src/words/_WordsRouter.js"
        UD["User Dashboard"]:::frontend
        click UD "https://github.com/zeeguu/web/blob/master/src/userDashboard/UserDashboard.js"
        TDASH["Teacher Dashboard"]:::frontend
        click TDASH "https://github.com/zeeguu/web/blob/master/src/teacher/_routing/_TeacherRouter.js"
        LAND["Landing Page"]:::frontend
        click LAND "https://github.com/zeeguu/web/blob/master/src/landingPage/LandingPage.js"
        ONB["Onboarding Pages"]:::frontend
        click ONB "https://github.com/zeeguu/web/tree/master/src/pages/onboarding/"
        PAGES["General Pages"]:::frontend
        click PAGES "https://github.com/zeeguu/web/tree/master/src/pages/"
    end

    ROUTER --> ART
    ART --> RDR
    ROUTER --> EXER
    ROUTER --> VID
    ROUTER --> WORDS
    ROUTER --> UD
    ROUTER --> TDASH
    ROUTER --> LAND
    ROUTER --> ONB
    ROUTER --> PAGES

    %% Feature to API and cache
    ART -->|GET articles| API_CLIENT
    EXER -->|GET /exercises| API_CLIENT
    VID -->|GET videos| API_CLIENT
    WORDS -->|GET words| API_CLIENT
    UD -->|GET dashboard data| API_CLIENT
    TDASH -->|GET teacher data| API_CLIENT
    FEATURE_CACHE["localStorage/sessionStorage"]:::storage
    ART --> FEATURE_CACHE
    EXER --> FEATURE_CACHE

    %% Hooks and Utilities
    subgraph "Hooks & Utilities"
        direction TB
        HOOKS["Custom Hooks"]:::frontend
        click HOOKS "https://github.com/zeeguu/web/tree/master/src/hooks/"
        UTILS["Utilities"]:::frontend
        click UTILS "https://github.com/zeeguu/web/tree/master/src/utils/"
        BOOK["Bookmarklet Integration"]:::external
        click BOOK "https://github.com/zeeguu/web/blob/master/src/bookmarklet/bookmarklet.js"
        SPEECH_MOD["APIBasedSpeech"]:::external
        click SPEECH_MOD "https://github.com/zeeguu/web/blob/master/src/speech/APIBasedSpeech.js"
        LOC_STORE["LocalStorage Wrapper"]:::storage
        click LOC_STORE "https://github.com/zeeguu/web/blob/master/src/assorted/LocalStorage.js"
        SES_STORE["SessionStorage Wrapper"]:::storage
        click SES_STORE "https://github.com/zeeguu/web/blob/master/src/assorted/SessionStorage.js"
        CONSTS["App Constants"]:::frontend
        click CONSTS "https://github.com/zeeguu/web/blob/master/src/appConstants.js"
        CSS["CSS Entry Point"]:::frontend
        click CSS "https://github.com/zeeguu/web/blob/master/src/index.css"
        FT["Feature-toggle Constants"]:::frontend
        click FT "https://github.com/zeeguu/web/blob/master/src/api/feature_toggles.js"
    end

    SHELL --> HOOKS
    SHELL --> UTILS
    SHELL --> BOOK
    SHELL --> SPEECH_MOD
    SHELL --> LOC_STORE
    SHELL --> SES_STORE
    SHELL --> CONSTS
    SHELL --> CSS
    SHELL --> FT

    %% External Services
    ZE["Zeeguu REST API"]:::external
    SPEECH_API["Speech Service"]:::external
    EXT["Browser Extension"]:::external

    API_CLIENT --> ZE
    SPEECH_MOD --> SPEECH_API
    SHELL -->|extension comms| EXT

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#007ACC
    classDef backend fill:#E6F7E6,stroke:#28A745
    classDef storage fill:#E8E8E8,stroke:#606060,stroke-dasharray: 2 2
    classDef hosting fill:#FFE5B4,stroke:#FF9500
    classDef external fill:#F4DEFF,stroke:#AF52DE
```
