# henhhenh13/english-note-v2 architecture

> Architecture diagram of the GitHub repository henhhenh13/english-note-v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/henhhenh13/english-note-v2
- Repository: https://github.com/henhhenh13/english-note-v2

## Overview

##### Project Type and Purpose
- This project is a frontend application—built with React and TypeScript—that aims to aid in learning English. Its primary features include managing vocabulary topics, lectures (especially videos), AI-assisted questions, sentence completion, and grammar exercises.
- The README highlights that users can create, read, update, and delete (CRUD) various educational content, along with AI-driven enhancements for question validation and answer suggestions.

##### File Structure
- The project uses a modern frontend build setup (note the presence of Vite config files such as vite.config.ts and tsconfig files). The entry point is index.html together with src/main.tsx and src/App.tsx.
- The src directory is split into many directories:
- The “components” directory is further broken down into feature areas (exercises, modals, menus, players, etc.). This shows a focus on modular and reusable UI elements.
- The “managers” directory is structured by domain (e.g., ai-question, complete-sentence, grammar, quiz, theme, unit, video-note, video, vocabulary). Each manager typically has subfiles for API handling, interfaces, state management, and the core manager logic. This layer clearly abstracts the business logic and handles communication (likely with external services or internal state).
- Additionally, directories like “hooks,” “utils,” and “contains” (holding global types and constants) support the application with necessary repeated functionality.
- External integration is hinted by a file named supabase-client.ts and by the presence of API files in the managers, which may be responsible for data exchange with a backend (possibly Supabase or a similar service).

##### README for Additional Insights
- The README clearly explains the main features of the app by grouping functionalities: vocabulary topics, lectures (with videos and note-taking), exercises (such as AI-assisted questions, sentence completion, and quizzes), and grammar content.
- The fact that there are multiple specialized modals (for adding, editing, and viewing various content types) suggests a very componentized and modular UI design.

a. Main Components:
- Frontend/Presentation Layer:
- The Entry Point (index.html, main.tsx, App.tsx)
- Pages (grammar.tsx, vocabulary.tsx, unit.tsx, etc.) which act as high-level views/routes.
- UI Components – including reusable elements (menu, sidebar, editor, and various specialized modals, quiz add-ons, and players).
- Business Logic/Managers Layer:
- Domain-specific managers (ai-question, complete-sentence, grammar, quiz, theme, unit, video-note, video, vocabulary). Each consists of API integration, interface definitions, state management, and managerial logic.
- Utilities and Helpers:
- Global utilities, hooks (like use-toast), and type definitions.
- External Services/Integration:
- Supabase client integration
- Third-party libraries like CK Editor for rich-text editing and possibly external AI services (as suggested by Gemini and AI question components).

b. Relationships and Interactions:
- Each manager then performs business logic operations and interacts with APIs (indicated by “api.ts” files) to fetch or update data, possibly using Supabase as the backend.
- Data flows from the external services into the managers, then propagates into the UI components for presentation. Similarly, user actions in the UI components trigger manager methods.
- The managers may also interact with the utilities and hooks for tasks like notifications (via use-toast) or conversion operations (time conversions, uuid generation).

c. Architectural Patterns/Design Principles:
- Component-Based UI Architecture: Clearly demonstrated by the modular directory organization in “components.”
- Separation of Concerns: The use of managers separates the business logic and API handling from the presentation layer.
- Domain-Driven Design: Each feature (e.g., grammar, quiz, vocabulary) is encapsulated in its own manager, which likely mirrors the domain’s needs.
- Reusability and Modularity: Many shared components (such as modals, containers, and players) can be reused across various parts of the application.

d. Relevant Technologies, Frameworks, or Libraries:
- React with TypeScript is the base for the frontend.
- Vite is used as the build tool.
- CK Editor is used within the editor component.
- Supabase (as inferred from supabase-client.ts) for backend connectivity.
- Possibly external AI services integrated via the Gemini API in the managers.

##### Elements
- Entry point / Main App
- Pages (Grammar, Vocabulary, Unit, etc.)
- UI Components (include specific nodes for modals, editors, players, etc.)
- Domain Managers (each for AI questions, quizzes, grammar, vocabulary, etc.)
- Utility Modules (hooks, utils, global types)
- External Services (Supabase, third-party APIs for AI enhancements, CK Editor)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/Presentation Layer
    subgraph "Frontend/Presentation Layer"
        %% Entry Points
        EP1["index.html"]:::frontend
        EP2["main.tsx"]:::frontend
        EP3["App.tsx"]:::frontend

        %% Pages
        subgraph "Pages"
            P1["Grammar Page"]:::frontend
            P2["Vocabulary Page"]:::frontend
            P3["Unit Page"]:::frontend
            P4["API Testing Page"]:::frontend
            P5["UI Testing Page"]:::frontend
        end

        %% UI Components
        subgraph "UI Components"
            UI1["Navigation Menu"]:::frontend
            UI2["Sidebar"]:::frontend
            UI3["Editor (CK Editor)"]:::frontend
            UI4["Video Player"]:::frontend
            UI5["Quiz Display"]:::frontend
            UI6["Quiz Add"]:::frontend
            UI7["Grammar Components"]:::frontend
            UI8["Vocabulary Table"]:::frontend
            UI9["Sentence with AI"]:::frontend
            UI10["Video Note Components"]:::frontend
            UI11["Exercises Components"]:::frontend
            UI12["Modal Components"]:::frontend
        end
    end

    %% Business Logic / Managers Layer
    subgraph "Business Logic / Managers Layer"
        M_AIQ["AI Question Manager"]:::manager
        M_CS["Complete Sentence Manager"]:::manager
        M_GEM["Gemini Integration"]:::manager
        M_Grammar["Grammar Manager"]:::manager
        M_Quiz["Quiz Manager"]:::manager
        M_Theme["Theme Manager"]:::manager
        M_Unit["Unit Manager"]:::manager
        M_VNote["Video Note Manager"]:::manager
        M_Video["Video Manager"]:::manager
        M_Vocab["Vocabulary Manager"]:::manager
        M_Page["Page Manager"]:::manager
    end

    %% Utilities and Helpers
    subgraph "Utilities and Helpers"
        U1["use-toast Hook"]:::utils
        U2["Utility Functions"]:::utils
        U3["Global Types & Constants"]:::utils
    end

    %% External Service Integration
    subgraph "External Service Integration"
        E1["Supabase Client"]:::external
    end

    %% Flow from Entry Points to Pages
    EP1 --> P1
    EP2 --> P2
    EP3 --> P3

    %% Flow from Pages to UI Components (using Grammar Page as representative)
    P1 --> UI1
    P2 --> UI1
    P3 --> UI1
    P4 --> UI1
    P5 --> UI1

    %% UI Components interactions with Business Logic / Managers
    UI1 -->|"triggers"| M_Page
    UI2 --> M_Page
    UI3 --> M_GEM
    UI4 --> M_Video
    UI5 --> M_Quiz
    UI6 --> M_Quiz
    UI7 --> M_Grammar
    UI8 --> M_Vocab
    UI9 --> M_AIQ
    UI10 --> M_VNote
    UI11 --> M_AIQ
    UI11 --> M_CS
    UI12 --> M_Page

    %% UI Components depend on Utilities (illustrative)
    UI1 --- U1
    UI1 --- U2
    UI1 --- U3

    %% Managers depend on Utilities (illustrative using AI Question Manager)
    M_AIQ --- U1
    M_AIQ --- U2
    M_AIQ --- U3

    %% Managers interactions with External Service
    M_AIQ --> E1
    M_CS --> E1
    M_GEM --> E1
    M_Grammar --> E1
    M_Quiz --> E1
    M_Theme --> E1
    M_Unit --> E1
    M_VNote --> E1
    M_Video --> E1
    M_Vocab --> E1

    %% Click Events for Entry Points
    click EP1 "https://github.com/henhhenh13/english-note-v2/blob/main/index.html"
    click EP2 "https://github.com/henhhenh13/english-note-v2/blob/main/src/main.tsx"
    click EP3 "https://github.com/henhhenh13/english-note-v2/blob/main/src/App.tsx"

    %% Click Events for Pages
    click P1 "https://github.com/henhhenh13/english-note-v2/blob/main/src/pages/grammar.tsx"
    click P2 "https://github.com/henhhenh13/english-note-v2/blob/main/src/pages/vocabulary.tsx"
    click P3 "https://github.com/henhhenh13/english-note-v2/blob/main/src/pages/unit.tsx"
    click P4 "https://github.com/henhhenh13/english-note-v2/blob/main/src/pages/api-testing.tsx"
    click P5 "https://github.com/henhhenh13/english-note-v2/blob/main/src/pages/ui-testing.tsx"

    %% Click Events for UI Components
    click UI1 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/menu.tsx"
    click UI2 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/sidebar/index.tsx"
    click UI3 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/editor/ck-editor.tsx"
    click UI4 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/players/custom-react-player.tsx"
    click UI5 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/quiz/item.tsx"
    click UI6 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/quiz/add/form.tsx"
    click UI7 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/grammars/container.tsx"
    click UI8 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/vocabularies/table.tsx"
    click UI9 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/sentense-with-ai/item.tsx"
    click UI10 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/video-note/form.tsx"
    click UI11 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/exercises/ai-question.tsx"
    click UI12 "https://github.com/henhhenh13/english-note-v2/blob/main/src/components/modals/container.tsx"

    %% Click Events for Business Logic / Managers
    click M_AIQ "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/ai-question/manager.ts"
    click M_CS "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/complete-sentence/manager.ts"
    click M_GEM "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/gemini/api.ts"
    click M_Grammar "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/grammar/manager.ts"
    click M_Quiz "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/quiz/manager.ts"
    click M_Theme "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/theme/manager.ts"
    click M_Unit "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/unit/manager.ts"
    click M_VNote "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/video-note/manager.ts"
    click M_Video "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/video/manager.ts"
    click M_Vocab "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/vocabulary/manager.ts"
    click M_Page "https://github.com/henhhenh13/english-note-v2/blob/main/src/managers/page/manager.ts"

    %% Click Events for Utilities and Helpers
    click U1 "https://github.com/henhhenh13/english-note-v2/blob/main/src/hooks/use-toast.ts"
    click U2 "https://github.com/henhhenh13/english-note-v2/blob/main/src/utils/convert-milisecons-to-seconds.ts"
    click U3 "https://github.com/henhhenh13/english-note-v2/blob/main/src/contains/global.ts"

    %% Click Event for External Service Integration
    click E1 "https://github.com/henhhenh13/english-note-v2/blob/main/src/supabase-client.ts"

    %% Styles
    classDef frontend fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef manager fill:#C0EDF2,stroke:#333,stroke-width:2px;
    classDef utils fill:#D3F9B5,stroke:#333,stroke-width:2px;
    classDef external fill:#FBC4AB,stroke:#333,stroke-width:2px;
```
