# zorlight/letslearn architecture

> Architecture diagram of the GitHub repository zorlight/letslearn, 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/zorlight/letslearn
- Repository: https://github.com/zorlight/letslearn

## Overview

1. A robust Java-based backend built with Spring Boot (using Maven for dependency management). This backend houses controllers, services, repositories, and configurations (including security with JWT, password encoding, and global exception handling) to support the API endpoints for managing courses, assignments, quizzes, courses’ files, meetings, and messaging.

2. A rich React/Next.js “ui” application that is highly modular, with dedicated sections for dashboard views, course creation and participation, meeting interfaces, quiz attempts, and various components (such as charts, tables, modals, and skeleton states) that give it a modern look and feel.

##### Additional specialized servers
- The “livekit-server” (developed in Go) which appears to handle real-time video conferencing and chat via LiveKit integration.
- The “tldraw-server” which likely acts as a real-time collaborative whiteboard/drawing component for in-meeting interactions.

4. Several Dockerfiles (in the backend, livekit-server, and tldraw-server directories) along with a docker-compose.yaml at the project root, suggesting that these components are containerized and orchestrated together.

a. Main Components to Include:
- Frontend UI: A Next.js application managing the user interface, routing, and state (with Redux, hooks, etc.).
- Backend API Server: The Spring Boot application that handles REST endpoints, authentication, business logic, data processing, and WebSocket connections.
- Video Conferencing Service: The Livekit server (in Go) responsible for real-time communication (video, audio, chat) during meetings.
- Whiteboard Service: The tldraw server currently used for collaborative drawing/whiteboarding sessions.
- Data Persistence Layer: Though not explicitly named in the file tree, include a relational database (or similar storage) which is interfaced via the repository layer in the backend.
- Cloud/Third-party Services: Elements like Cloudinary for file handling and any other integrations (as seen in the “cloudinary” adapters and utilities).

b. Relationships & Interactions:
- The Frontend issues HTTP/REST (and likely WebSocket) requests to the Backend API for most application logic like user authentication, course management, messaging, and quiz data.
- The Backend interacts directly with the Persistence Layer (via repositories) to store and retrieve entities (course, assignment, user, etc.).
- When real-time collaboration is needed (e.g., meetings), the Backend or the Frontend connects with the Livekit Server to establish audio/video conference sessions.
- Similarly, for whiteboarding or drawing interactions during a meeting, the UI communicates with the tldraw Server.
- Docker Compose ties these services together by managing inter-container communication and deployment configurations.

c. Architectural Patterns & Design Principles:
- Use a layered (or MVC-style) design on the backend with clear separation between controllers, services, mappers, and repositories.
- The frontend is component-based and structured per feature (e.g., courses, meeting, chat, dashboard).
- Integration through APIs and WebSockets for real-time updates.
- Containerized deployment, ensuring that each major service (backend API, meeting server, whiteboard server) is independently deployable and scalable.

d. Relevant Technologies & Frameworks:
- Java Spring Boot, Maven for the backend.
- Docker (Dockerfiles and docker-compose) for container orchestration.
- Next.js (React) for the frontend UI.
- LiveKit (Go) for real-time meeting/video collaboration.
- tldraw (Node/TypeScript based) for whiteboard collaboration.
- Cloudinary for file uploads and multimedia management.
- Various libraries for state management (Redux) and UI components.

- RESTful API interactions between the UI and Backend.
- WebSocket communication channels for real-time interactions (chat, meeting events).
- How container orchestration via docker-compose binds these services together.
- Intermediary adapters or utilities (such as Cloudinary or messaging adapters) that connect to external systems.

- “Database” (representing persistence via repositories).
- “Livekit Server (Go)” for meeting and video interactions.
- “tldraw Server” for whiteboard sessions.
- “External Cloud Service (Cloudinary)” for file storage (optional).
- Optionally, illustrate a “Docker Compose” container that groups the Backend, Livekit, and tldraw components, indicating container orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    FE["Frontend UI (Next.js)"]:::frontend
    UICloud["Cloudinary Integration (UI)"]:::external
    Compose["Docker Compose"]:::compose

    subgraph "Container Orchestration (Docker Compose)"
        BE["Backend API (Spring Boot)"]:::backend
        LK["LiveKit Server (Go)"]:::service
        TD["tldraw Server"]:::service
    end

    DB(("Database (RDBMS)")):::database
    BECloud["Cloudinary Integration (Backend)"]:::external

    FE -->|"REST_API/WebSocket"| BE
    FE -->|"Uses"| UICloud
    BE -->|"CRUD"| DB
    BE -->|"RealTime_Video"| LK
    BE -->|"Whiteboard"| TD
    BE -->|"Media_Handling"| BECloud

    Compose ---|"orchestrates"| BE
    Compose ---|"orchestrates"| LK
    Compose ---|"orchestrates"| TD

    click FE "https://github.com/zorlight/letslearn/tree/main/ui/"
    click UICloud "https://github.com/zorlight/letslearn/tree/main/ui/lib/cloudinary/"
    click BE "https://github.com/zorlight/letslearn/tree/main/backend/"
    click BECloud "https://github.com/zorlight/letslearn/blob/main/backend/src/main/java/com/letslive/letslearnbackend/entities/CloudinaryFile.java"
    click LK "https://github.com/zorlight/letslearn/tree/main/livekit-server/"
    click TD "https://github.com/zorlight/letslearn/tree/main/tldraw-server/"
    click Compose "https://github.com/zorlight/letslearn/blob/main/docker-compose.yaml"

    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef service fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#F5CBA7,stroke:#BF360C,stroke-width:2px;
    classDef external fill:#E6E6FA,stroke:#800080,stroke-width:2px;
    classDef compose fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
