# bouanani-soufiane/learntogether architecture

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

- Interactive diagram: https://gitdiagram.com/bouanani-soufiane/learntogether
- Repository: https://github.com/bouanani-soufiane/learntogether

## Overview

##### Main Components
- Frontend (Client): Represent the React-based SPA that handles UI/UX, routing, state management (Redux Toolkit), and interactions with APIs.
- Backend: A Spring Boot application organized in a Domain-Driven Design (DDD) fashion with bounded contexts, including:
- Authentication Service (JWT, role-based access control)
- Content Management Service (for Q&A, blogs, and comments)
- AI Validation Service (content quality and automated review)
- Media Service (integrating Cloudinary or similar for image/media uploads)
- Notification/Search/Reputation Services (implied by the README)
- Database & Persistence: A PostgreSQL database (as indicated by Liquibase change logs) along with potential support for search (e.g., Elasticsearch) and possibly caching components.
- External Services & Infrastructure: Docker for containerized deployment, infrastructure for CI/CD, and integration with external APIs (e.g., for media storage and AI validation).

##### Understand Component Interactions
- How the Frontend communicates with the Backend via HTTP/REST API calls.
- Authentication flow (using JWT): the Frontend sends credentials to the Auth Controller; the Backend issues tokens, and then subsequent API calls include token validation.
- Data persistence by linking backend modules with the database (e.g., via Spring Data repositories) and possibly a search engine.
- Optionally, show communication with external services (e.g., AI validation and Cloudinary integration in media service).

##### Architectural Patterns and Design Principles
- Use Domain-Driven Design (DDD) to segment the application into bounded contexts such as User Management, Content Management, Reputation, and Media.
- Modular approach (Spring Modulith) within the backend to encapsulate each domain.
- Testing and CI/CD pipelines where integration tests are performed (using TestContainers, JUnit, and Cucumber).
- Security measures (JWT-based authentication, Spring Security, role-based access).

##### Including Relevant Technologies
- For the Frontend: React.js, Redux, React Router, Tailwind CSS, and TypeScript.
- For the Backend: Spring Boot (with Spring Security, Spring Data JDBC), Maven, Docker, Liquibase, and possibly Elasticsearch.

##### Detailed Breakdown
- At the top, represent the Client: “Frontend (React)” with routes and main components.
- A “Security Layer” within the Backend that handles JWT authentication:
- AuthController and the JWT filter/provider components.
- Split the Backend into several modules:
- User Module: handling registration, login, profile management (including DTOs, mappers, and repositories).
- Content Module: managing Q&A, blogs, comments, and associated validation (with separate sub-packages for creation and update DTOs).
- Media Module: processing and uploading images (highlighting integration with Cloudinary using MediaController and associated services).
- Optionally, include additional modules mentioned in the README such as the Reputation System and AI Validation services.

- Clearly delineates each architectural component.
- Represents the interactions (data flow and dependencies) between the frontend, backend services, and infrastructure.
- Captures both the overall high-level view and the detailed subcomponents necessary for deep technical understanding.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend"
        FE["React Client"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Spring Boot)"
        %% Security Module
        subgraph "Security Module"
            AC["AuthController"]:::backend
            JWT["JWT Provider"]:::backend
        end

        %% Content Management Module
        subgraph "Content Management Module"
            BC["BlogController"]:::backend
            QC["QuestionController"]:::backend
        end

        %% Media Module
        subgraph "Media Module"
            MC["MediaController"]:::backend
            CS["CloudinaryService"]:::backend
        end

        %% Other Services
        subgraph "Other Services"
            RS["Reputation Service"]:::backend
            AI["AI Validation Service"]:::backend
        end

        DB["PostgreSQL"]:::database
    end

    %% Build & Deployment Tools
    subgraph "Build & Deployment Tools"
        DF["Dockerfile"]:::build
        CY["compose.yaml"]:::build
        MV["Maven Build"]:::build
    end

    %% External Infrastructure
    subgraph "External Services"
        ExAI["External AI Service"]:::external
        Cloud["Cloudinary"]:::external
    end

    %% Connections from Frontend to Backend APIs
    FE -->|"login/API"| AC
    FE -->|"content/API"| BC
    FE -->|"content/API"| QC
    FE -->|"media/API"| MC

    %% Internal Backend interactions
    AC -->|"issues JWT"| JWT
    BC -->|"persist/read"| DB
    QC -->|"persist/read"| DB
    MC -->|"persist/read"| DB
    RS -->|"updates"| DB
    MC -->|"uploads to"| CS
    CS -->|"calls"| Cloud
    AI -->|"validates via"| ExAI

    %% Build & Deployment triggering Backend deployment
    DF -->|"deploy"| AC
    CY -->|"deploy"| AC
    MV -->|"build"| AC

    %% Styling Classes
    classDef frontend fill:#FAD02E,stroke:#333,stroke-width:2px;
    classDef backend fill:#A2D5F2,stroke:#333,stroke-width:2px;
    classDef database fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef external fill:#F5A623,stroke:#333,stroke-width:2px;
    classDef build fill:#E8A0BF,stroke:#333,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/bouanani-soufiane/learntogether/blob/master/client/src/App.tsx"
    click AC "https://github.com/bouanani-soufiane/learntogether/blob/master/backend/src/main/java/yc/ma/LearnTogether/user/web/AuthController.java"
    click JWT "https://github.com/bouanani-soufiane/learntogether/tree/master/backend/src/main/java/yc/ma/LearnTogether/user/infrastructure/jwt/"
    click BC "https://github.com/bouanani-soufiane/learntogether/blob/master/backend/src/main/java/yc/ma/LearnTogether/content/BlogController.java"
    click QC "https://github.com/bouanani-soufiane/learntogether/blob/master/backend/src/main/java/yc/ma/LearnTogether/content/QuestionController.java"
    click MC "https://github.com/bouanani-soufiane/learntogether/blob/master/backend/src/main/java/yc/ma/LearnTogether/media/MediaController.java"
    click CS "https://github.com/bouanani-soufiane/learntogether/blob/master/backend/src/main/java/yc/ma/LearnTogether/media/CloudinaryService.java"
    click DB "https://github.com/bouanani-soufiane/learntogether/tree/master/backend/src/main/resources/db/changelog/"
    click DF "https://github.com/bouanani-soufiane/learntogether/tree/master/backend/Dockerfile"
    click CY "https://github.com/bouanani-soufiane/learntogether/blob/master/backend/compose.yaml"
    click MV "https://github.com/bouanani-soufiane/learntogether/tree/master/backend/mvnw"
```
