# lekhoi2709/lumen architecture

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

- Interactive diagram: https://gitdiagram.com/lekhoi2709/lumen
- Repository: https://github.com/lekhoi2709/lumen

## Overview

##### Project Type & Purpose
- Lumen is a full-stack web-based LMS aimed at enabling educators to create/manage courses and students to access course materials.
- The README clearly outlines features such as course management, content creation, assignments, gradebook, and communication.
- The project is split into a frontend (client) built with React, TypeScript, Vite, TailwindCSS, Tauri (for desktop packaging) and a backend server built with ExpressJS and Node.js. It uses MongoDB for data persistence and Supabase for file storage.

##### Analyzing the File Structure
- The top-level directories are:
- /client (the frontend side)
- /server (the backend side)
- /docs (documentation)
- In the /client directory you see:
- A clear separation between UI source files (client/src) with components, routes, contexts, layouts, services, etc.
- A Tauri integration area in client/src-tauri that includes Rust code, Tauri configurations, and build scripts. This informs you that the frontend might be packaged as a desktop app.
- The /server directory contains:
- Controllers that handle application logic for admin, courses, users, authentication, and more.
- Models and routes indicating typical MVC organizational patterns.
- Middleware for tasks like authentication and utilities (JWT, email sending).

##### Key Components
a. Frontend Component:
- Client UI built with React using Vite.
- Tauri module (client/src-tauri) for desktop application support.
- Sub-components: pages (routes), layouts, contexts (e.g., auth, theme), and shared UI components.
- Communication layer via services (API calls) – note the separation into services/api, mutations, and queries.

b. Backend Server:
- ExpressJS server handling REST API endpoints.
- Controllers for administrators, courses, authentication, OTP management, and more.
- Models that interact with the database (MongoDB) and the routing system.
- Middleware for authentication (JWT) and other global tasks.

c. Database:
- Use MongoDB for data persistence (keeping track of courses, users, assignments, etc.).

d. External/Integrations:
- Supabase is used for file storage.
- Tauri integration for building desktop versions (leveraging Rust components).
- Optional external services (e.g., mailing services, OAuth if indicated in controllers).

##### Architectural Patterns and Design Principles
- Separation of concerns: Frontend (presentation), backend (business logic) and data persistence are clearly separated.
- MVC-like pattern in the backend, where models, views (or controllers) and routes work together.
- API-driven communication: the frontend calls backend APIs using well-defined routes exposed in the server.
- Modular structure in the frontend ensures reusable components and layered architecture (e.g., authentication context separate from UI components).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        fc1["Frontend Client / UI"]:::frontend
        fc2["Components"]:::frontend
        fc3["Routes"]:::frontend
        fc4["Contexts"]:::frontend
        fc5["Layouts"]:::frontend
        fc6["Services"]:::frontend
        fc1 --> fc2
        fc1 --> fc3
        fc1 --> fc4
        fc1 --> fc5
        fc1 --> fc6
    end

    %% Tauri Integration
    subgraph "Tauri Integration"
        tauri_node["Tauri Desktop Integration"]:::tauri
        tauri_main["main.rs"]:::tauri
        tauri_conf["tauri.conf.json"]:::tauri
        tauri_node --> tauri_main
        tauri_node --> tauri_conf
    end

    %% Backend Layer
    subgraph "Backend Layer"
        bs["Backend Server"]:::backend
        bc["Controllers"]:::backend
        br["Routes"]:::backend
        bm["Middlewares"]:::backend
        bmo["Models"]:::backend
        be1["express.config.ts"]:::backend
        be2["index.ts"]:::backend
        bs --> bc
        bs --> br
        bs --> bm
        bs --> bmo
        bs --> be1
        bs --> be2
    end

    %% Data & External Storage
    subgraph "Data & External Storage"
        db["Database (MongoDB)"]:::database
        fs["File Storage (Supabase)"]:::external
    end

    %% Interactions between layers
    fc1 -->|"APIcalls"| bs
    bs -->|"CRUD"| db
    bs -->|"FileOperations"| fs
    fc1 ---|"DesktopPackaging"| tauri_node

    %% Click Events for Frontend
    click fc1 "https://github.com/lekhoi2709/lumen/tree/main/client/src"
    click fc2 "https://github.com/lekhoi2709/lumen/tree/main/client/src/components"
    click fc3 "https://github.com/lekhoi2709/lumen/tree/main/client/src/routes"
    click fc4 "https://github.com/lekhoi2709/lumen/tree/main/client/src/contexts"
    click fc5 "https://github.com/lekhoi2709/lumen/tree/main/client/src/layouts"
    click fc6 "https://github.com/lekhoi2709/lumen/tree/main/client/src/services"

    %% Click Events for Tauri Integration
    click tauri_node "https://github.com/lekhoi2709/lumen/tree/main/client/src-tauri"
    click tauri_main "https://github.com/lekhoi2709/lumen/blob/main/client/src-tauri/src/main.rs"
    click tauri_conf "https://github.com/lekhoi2709/lumen/blob/main/client/src-tauri/tauri.conf.json"

    %% Click Events for Backend
    click bs "https://github.com/lekhoi2709/lumen/tree/main/server/src"
    click bc "https://github.com/lekhoi2709/lumen/tree/main/server/src/controllers"
    click br "https://github.com/lekhoi2709/lumen/tree/main/server/src/routes"
    click bm "https://github.com/lekhoi2709/lumen/tree/main/server/src/middlewares"
    click bmo "https://github.com/lekhoi2709/lumen/tree/main/server/src/models"
    click be1 "https://github.com/lekhoi2709/lumen/blob/main/server/src/express.config.ts"
    click be2 "https://github.com/lekhoi2709/lumen/blob/main/server/src/index.ts"

    %% Click Events for Data & External Storage
    click db "https://github.com/lekhoi2709/lumen/blob/main/server/src/database.ts"
    click fs "https://github.com/lekhoi2709/lumen/blob/main/server/src/supabaseClient.ts"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef tauri fill:#ffebee,stroke:#c62828,stroke-width:2px;
    classDef backend fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    classDef database fill:#e3f2fd,stroke:#1565c0,stroke-width:2px,stroke-dasharray:5,5;
    classDef external fill:#fff3e0,stroke:#ef6c00,stroke-width:2px,stroke-dasharray:5,5;
```
