# ccu-class/frontend architecture

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

- Interactive diagram: https://gitdiagram.com/ccu-class/frontend
- Repository: https://github.com/ccu-class/frontend

## Overview

##### Main Components
- Browser / Client:
- Represents the end user’s browser where index.html is loaded and the Vue application starts.
- Vue Application Entry Point:
- Src/main.ts as the bootstrapping file that initializes the app.
- Routing:
- src/router/index.ts, which sets up navigational logic and maps paths to different views.
- State Management:
- The src/store directory (e.g., ccuplus.ts, course.ts, general.ts) that manages application state.
- Views & Pages:
- Components under src/views (e.g., page_home.vue, page_login.vue, page_main.vue, page_admin.vue, etc.) acting as container components that render full pages.
- UI Components:
- Components in src/components (organized into common elements, layout elements like navbar.vue and footer.vue, and page-specific components in pages folder).
- Business Logic & Helper Functions:
- Files under src/functions (such as course_add.ts, course_search.ts, token.ts) which appear to handle API calls, course operations, and other logic (likely interacting with a backend API, as indicated by the README instructions on renaming samole.env to .env).
- Styling & Build Configurations:
- Tailwind (tailwind.config.js, postcss.config.js) and Vite (vite.config.ts) configurations that affect rendering and build processes.

##### Establishing Relationships and Data Flow
- The Vue instance integrates with:
- The router that directs navigation to different views (e.g., home, main, login, tutorial).
- The store that manages shared state across components.
- Views render results, which then incorporate various UI components from the components directory.
- The UI components, in turn, may call business logic functions in the functions/ directory to handle tasks such as course operations, token management, or backend API interactions.
- A connection exists between the functions (service layer) and the backend API, which is configured via environment variables (using .env as indicated by the README).

##### Architectural Patterns and Design Principles
- Component-based Architecture:
- The project is structured in a modular way with reusability in mind (as seen in subfolders like common, layout, and pages).
- Separation of Concerns:
- Clear isolation between view rendering (components and views), routing (router), state management (store), and business logic (functions).
- Configuration-based Deployment:
- Use of .env files and configuration files (Vite, Tailwind, PostCSS) to separate environment-based settings from business logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Browser / Client (index.html)"]:::client
    A -->|"loads"| B["Vue App (src/main.ts)"]:::app

    B -->|"initializes"| C["Router (src/router/index.ts)"]:::routing
    B -->|"initializes"| D["State Management (src/store)"]:::store
    B -->|"initializes"| E["Views & Pages (src/views)"]:::views
    E -->|"composes"| F["UI Components (src/components)"]:::components
    F -->|"triggers"| G["Business Logic & Helper Functions (src/functions)"]:::logic
    G -->|"calls"| H["Backend API/Database"]:::backend

    B -->|"loads"| I["Configurations & Styling"]:::config
    I -->|"includes"| J["Tailwind Config (tailwind.config.js)"]:::config
    I -->|"includes"| K["Vite Config (vite.config.ts)"]:::config
    I -->|"includes"| L["PostCSS Config (postcss.config.js)"]:::config
    I -->|"includes"| M["Environment File (samole.env)"]:::config

    click A "https://github.com/ccu-class/frontend/blob/stable/index.html"
    click B "https://github.com/ccu-class/frontend/blob/stable/src/main.ts"
    click C "https://github.com/ccu-class/frontend/blob/stable/src/router/index.ts"
    click D "https://github.com/ccu-class/frontend/tree/stable/src/store"
    click E "https://github.com/ccu-class/frontend/tree/stable/src/views"
    click F "https://github.com/ccu-class/frontend/tree/stable/src/components"
    click G "https://github.com/ccu-class/frontend/tree/stable/src/functions"
    click J "https://github.com/ccu-class/frontend/blob/stable/tailwind.config.js"
    click K "https://github.com/ccu-class/frontend/blob/stable/vite.config.ts"
    click L "https://github.com/ccu-class/frontend/blob/stable/postcss.config.js"
    click M "https://github.com/ccu-class/frontend/blob/stable/samole.env"

    classDef client fill:#EAEAEA,stroke:#333,stroke-width:2px;
    classDef app fill:#FFEFD5,stroke:#333,stroke-width:2px;
    classDef routing fill:#D0E6A5,stroke:#333,stroke-width:2px;
    classDef store fill:#F8C471,stroke:#333,stroke-width:2px;
    classDef views fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef components fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef logic fill:#D7BDE2,stroke:#333,stroke-width:2px;
    classDef backend fill:#C39BD3,stroke:#333,stroke-width:2px;
    classDef config fill:#A3E4D7,stroke:#333,stroke-width:2px;
```
