# smaga-lms/frontend-lms architecture

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

- Interactive diagram: https://gitdiagram.com/smaga-lms/frontend-lms
- Repository: https://github.com/smaga-lms/frontend-lms

## Overview

##### Main Components Identification
- Frontend (React) Application: The heart of the project running in the browser.
- UI Components: Under the “src/components” directory, you have a wide variety (global UI, home, announcements, attendances, classes, courses, users, etc.). These are the presentational elements that build your pages.
- Pages: The “src/pages” folder contains many role-based and function-specific screens (login pages, profile, home, announcement receivers, class enrollments, etc.).
- Routers: The “src/routers” folder shows clearly defined routing modules, including role-based routing (RoleBasedRoute.tsx) and sub-routing for different domains. This layer defines navigation and access control for various user roles (admin, student, teacher, guest).
- Layouts: The “src/layouts” directory holds different layouts (MemberLayout, GuestLayout, bottom navigation layouts for admin, student, teacher) that wrap the pages with common UI elements and navigation.
- Service Layer (APIs): Located in “src/services/apis”, this layer abstracts the API calls and interactions with backend endpoints. Each domain (announcements, attendances, courses, etc.) has its own service file and associated TypeScript definitions.
- Context & Hooks: Global state and reusable logic live in “src/contexts” and “src/hooks”, for instance, ContextProvider.tsx and useToast hook.

##### Relationships and Interactions
- User Interface (UI) Components and Pages interact through props, context providers, and state hooks.
- The Routers define the navigation flow, connecting URL routes to specific Pages.
- Layouts wrap around pages to provide a consistent look and add navigation elements (e.g., bottom navigation specific to user roles).
- Services encapsulate the business logic for API calls; Pages and components call these service methods to fetch or send data.
- Contexts provide globally available state (e.g., authentication or theme state) which components throughout the tree can consume.
- Utility modules and hooks provide reusable logic for tasks like error handling or toast notifications.

##### Architectural Patterns and Design Principles
- Modular Decomposition: The project separates different concerns (UI, routing, API service, layouts, context) into dedicated folders.
- Role-Based Design: The distinct folders for routes and layouts (admin, teacher, student, guest) indicate a pattern for delivering multiple views based on user roles.
- Component Reusability: A dedicated “global” UI components subfolder suggests a strong emphasis on reusable, styled UI elements.
- Service Abstraction: The API service layer is separated from UI logic, providing clear boundaries between presentation and data fetching.
- Configuration Separation: Build and lint config files (Vite config, Webpack config, ESLint, etc.) indicate that development tooling is handled separately from application logic.

##### Technologies and Frameworks
- React (with TypeScript, as seen by the .tsx and .d.ts files)
- Vite (for build and bundling; see vite.config.ts and references in README)
- ESLint (with configurations provided)
- Tailwind CSS (evidenced by tailwind.config.ts)
- Axios (or a similar HTTP client, implied by services/axiosClient.ts)
- Possibly Babel or SWC for fast refresh via Vite plugins

## Diagram (Mermaid)

```mermaid
flowchart TD
    FE["Frontend (React) Application"]:::frontend

    subgraph "Presentation Layer"
        PAGES["Pages (src/pages)"]:::presentation
        UI["UI Components (src/components)"]:::presentation
        LAYOUTS["Layouts (src/layouts)"]:::presentation
    end

    subgraph "Application Logic Layer"
        ROUTERS["Routers (src/routers)"]:::application
        CONTEXT["Context (src/contexts)"]:::application
        HOOKS["Hooks (src/hooks)"]:::application
    end

    subgraph "Data Access Layer"
        APIS["Service Layer (APIs) (src/services/apis)"]:::data
    end

    subgraph "Configuration & Assets"
        ASSETS["Assets (src/assets)"]:::config
        CONFIG["Configs & Tools (vite.config.ts, tailwind.config.ts, package.json)"]:::config
    end

    FE -->|"defines"| ROUTERS
    ROUTERS -->|"wraps"| LAYOUTS
    LAYOUTS -->|"renders"| PAGES
    PAGES -->|"composes"| UI
    UI -->|"uses"| CONTEXT
    UI -->|"uses"| HOOKS
    UI -->|"calls"| APIS
    PAGES -->|"calls"| APIS

    classDef frontend fill:#f9c,stroke:#333,stroke-width:2px;
    classDef presentation fill:#ccf,stroke:#333,stroke-width:2px;
    classDef application fill:#cfc,stroke:#333,stroke-width:2px;
    classDef data fill:#fc9,stroke:#333,stroke-width:2px;
    classDef config fill:#cff,stroke:#333,stroke-width:2px;

    click FE "https://github.com/smaga-lms/frontend-lms/tree/main/src"
    click UI "https://github.com/smaga-lms/frontend-lms/tree/main/src/components"
    click PAGES "https://github.com/smaga-lms/frontend-lms/tree/main/src/pages"
    click ROUTERS "https://github.com/smaga-lms/frontend-lms/tree/main/src/routers"
    click LAYOUTS "https://github.com/smaga-lms/frontend-lms/tree/main/src/layouts"
    click APIS "https://github.com/smaga-lms/frontend-lms/tree/main/src/services/apis"
    click CONTEXT "https://github.com/smaga-lms/frontend-lms/tree/main/src/contexts"
    click HOOKS "https://github.com/smaga-lms/frontend-lms/tree/main/src/hooks"
    click ASSETS "https://github.com/smaga-lms/frontend-lms/tree/main/src/assets"
    click CONFIG "https://github.com/smaga-lms/frontend-lms/blob/main/vite.config.ts"
```
