# fabiorg06/yuapp architecture

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

## Overview

##### Project Overview & Purpose
- YuApp is an educational web application whose aim is to preserve and promote the Wayuu language. It offers interactive lessons, quizzes, and role-based management, similar in spirit to language-learning apps like Duolingo.
- The application uses a modern tech stack with a Django backend (coupled with PostgreSQL for data persistence), and a frontend built in React (integrating aspects of NestJS as indicated by the README).

##### Main Components Identification
a. Frontend:
– Built with React (and possibly Next.js as suggested by configuration files such as next.config.mjs, tsconfig.json, and tailwind configs).
– Contains UI components for authentication, admin panels, lesson displays, questions, and interactive content.
– Contains API service layers that handle interactions with the backend (grouped by features like chapters, lessons, questions, stats, words).
b. Backend:
– Built on Django; organized under a structured “Uapp” package that splits responsibility by modules.
– Key submodules include:
- Auth_system: Handles user authentication (with JWT support), user management, and related services.
- Content_system: Contains further subdivisions for Chapters, Lessons, Questions, Tags, and WordPhrases. Each has its own models, views, serializers, repositories, services, and URL routing – reflecting an organized, modular pattern.
- Stats_system: Manages user stats, including tracking lesson progress or learning performance.
- A primary Django setup (Uapp folder with settings, URLs, WSGI/ASGI) that ties the modules together.
c. Database:
– PostgreSQL serves as the database backing the Django backend.
d. Docker & Deployment:
– Both the backend and frontend have Dockerfiles indicating containerized deployment.
– A top-level docker-compose.yml orchestrates the deployment services (including the database and potentially other services).

##### Relationships & Interactions
- Frontend communicates with the backend API endpoints using HTTP calls. This includes authentication endpoints (registration, login), content fetching (chapters, lessons, questions), and stats retrieval.
- The backend’s modular structure means that each module (auth, content, stats) handles its specific domain logic. They interact with the database via Django’s ORM and employ design patterns such as repositories and services.
- The JWT authentication middleware ensures secure API access.
- Administrators use dedicated components and endpoints (both on the frontend and backend) for content management.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Each module (auth, content, stats) is self-contained with its own models, repositories, services, and routes. This modular approach helps maintain a clear separation between different domains.
- MVC/MVT Pattern: Django’s typical Model-View-Template (or View) pattern is evident, supported by repositories and service layers for business logic.
- API-First & Micro-modularity: The frontend service layer is clearly divided for different API domains (chapters, lessons, questions, etc.), reinforcing the idea of fine-grained API interactions.
- Containerization & Environment Isolation: Dockerfiles for both frontend and backend indicate a containerized deployment approach.

##### Detailed Components
- Frontend:
– “UI Components” (Authentication forms, Lesson cards, Quiz components, Admin panels)
– “API Services” (grouped by chapters, lessons, questions, stats)
– “State Management & Hooks” (context and utility functions)
- Backend:
– “Authentication Module” (JWT Auth, Users, Middleware, Admin interface)
– “Content Module” subdividing into Chapters, Lessons, Questions, Tags, WordPhrases (each with Models, Repositories, Serializers, Services, and Views)
– “Stats Module” for user progress tracking (with relevant repository and service layers)
– “Core Django Setup” including settings, URL routing, and application entry point.
- Database:
– PostgreSQL database represented as an external component.
- Deployment:
– Docker containers for Frontend and Backend and Docker Compose bridging the services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker & Deployment"
        DCompose("docker-compose.yml"):::docker
    end

    subgraph "Frontend"
        FUI("UI Components"):::frontend
        FAPI("API Services"):::frontend
        FContext("State Context"):::frontend
        FHooks("Hooks"):::frontend
        FDocker("Dockerfile (Frontend)"):::docker
    end

    subgraph "Backend"
        BCore("Core Django Setup"):::backend
        subgraph "Auth Module"
            BUser("User Management"):::backend
            BJWT("JWT Authentication"):::backend
        end
        subgraph "Content Module"
            BChapters("Chapters"):::backend
            BLessons("Lessons"):::backend
            BQuestions("Questions"):::backend
            BTags("Tags"):::backend
            BWordPhrases("WordPhrases"):::backend
        end
        subgraph "Stats Module"
            BStats("User Stats"):::backend
        end
        BDocker("Dockerfile (Backend)"):::docker
    end

    subgraph "Database"
        DB("PostgreSQL Database"):::database
    end

    %% Frontend to Backend interactions
    FAPI -->|"API_calls"| BCore
    FUI -->|"UI/ Admin_requests"| BCore
    FContext -->|"State_updates"| FAPI
    FHooks -->|"Trigger_actions"| FAPI

    %% Backend internal routing
    BCore -->|"routes_to"| BUser
    BCore -->|"routes_to"| BJWT
    BCore -->|"routes_to"| BChapters
    BCore -->|"routes_to"| BLessons
    BCore -->|"routes_to"| BQuestions
    BCore -->|"routes_to"| BTags
    BCore -->|"routes_to"| BWordPhrases
    BCore -->|"routes_to"| BStats

    %% Backend Modules to Database
    BUser -->|"ORM_calls"| DB
    BJWT -->|"Middleware_calls"| DB
    BChapters -->|"CRUD_ops"| DB
    BLessons -->|"CRUD_ops"| DB
    BQuestions -->|"CRUD_ops"| DB
    BTags -->|"CRUD_ops"| DB
    BWordPhrases -->|"CRUD_ops"| DB
    BStats -->|"Data_tracking"| DB

    %% Deployment associations
    FDocker --- DCompose
    BDocker --- DCompose

    %% Click Events
    click FUI "https://github.com/fabiorg06/yuapp/tree/master/Frontend/u-app/app/components"
    click FAPI "https://github.com/fabiorg06/yuapp/tree/master/Frontend/u-app/app/services/api"
    click FContext "https://github.com/fabiorg06/yuapp/tree/master/Frontend/u-app/app/context"
    click FHooks "https://github.com/fabiorg06/yuapp/tree/master/Frontend/u-app/app/hooks"
    click FDocker "https://github.com/fabiorg06/yuapp/tree/master/Frontend/u-app/Dockerfile"
    click BCore "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Uapp"
    click BUser "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Auth_system/Users"
    click BJWT "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Auth_system/jwt_auth"
    click BChapters "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Content_system/Chapters"
    click BLessons "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Content_system/Lessons"
    click BQuestions "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Content_system/Questions"
    click BTags "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Content_system/Tags"
    click BWordPhrases "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Content_system/WordPhrases"
    click BStats "https://github.com/fabiorg06/yuapp/tree/master/Backend/Uapp/Stats_system/user_stats"
    click BDocker "https://github.com/fabiorg06/yuapp/tree/master/Backend/Dockerfile"
    click DCompose "https://github.com/fabiorg06/yuapp/blob/master/docker-compose.yml"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef docker fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#FADBD8,stroke:#922B21,stroke-width:2px;
```
