# redcoat21/dolphin-streak architecture

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

- Interactive diagram: https://gitdiagram.com/redcoat21/dolphin-streak
- Repository: https://github.com/redcoat21/dolphin-streak

## Overview

##### Main Architecture Components

The system follows a modern full-stack architecture with clear separation between frontend and backend:

a) Frontend Layer (dolphin-streak-frontend):
- Built with Next.js (React-based framework)
- Uses TRPC for type-safe API communication
- Contains UI components and pages
- Implements internationalization (i18n)
- Uses Tailwind CSS for styling

b) Backend Layer (dolphin-streak-backend):
- Built with NestJS framework
- Contains multiple domain-specific modules
- Implements authentication and authorization
- Handles file uploads and cloud storage
- Includes AI/Voice recognition capabilities

##### Key Components

Frontend Components:
**[Client Browser] → [Next.js Frontend]**
- Auth Pages
- Course Pages
- Forum System
- Daily Challenges
- Language Preference System

Backend Services:
**[NestJS Backend]**
- Core Services
- Auth Service
- User Service
- Course Service
- Language Service
- Question Service
- Supporting Services
- AI Service
- Voice AI Service
- Mail Service
- Upload Service
- Security Layer
- Encryption Service

##### Data Flow and Integration Points

Key interactions:
- Client-Server communication via TRPC
- Authentication flow with JWT
- File upload flow to Cloudinary
- Voice recognition processing
- Email notification system

##### Database and External Services

Components:
- MongoDB Database (indicated by schema files)
- Cloudinary (for media storage)
- Email Service Integration
- AI/Voice Recognition Services

##### Security Layer

Security components:
- JWT Authentication
- Bearer Token Authorization
- Role-based Access Control
- Password Reset System

##### Data Layer (Bottom)

Remember to emphasize the language learning specific features like:
- Course progression
- Question types (multiple choice, fill-in-the-blanks)
- Voice recognition exercises
- User streak tracking
- Forum interactions for community learning

This architecture should be represented as a modern, scalable system that can handle multiple users learning different languages simultaneously while maintaining performance and security.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    Client["Client Browser"]

    %% Frontend Layer
    subgraph Frontend
        NextJS["Next.js Frontend"]:::frontend
        AuthPages["Auth Pages"]:::frontend
        CoursePages["Course Pages"]:::frontend
        ForumPages["Forum System"]:::frontend
        DailyChallenge["Daily Challenges"]:::frontend
        LangPref["Language Preferences"]:::frontend
        TRPC["tRPC Router"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        NestJS["NestJS Backend"]:::backend

        subgraph CoreServices["Core Services"]
            AuthService["Auth Service"]:::backend
            UserService["User Service"]:::backend
            CourseService["Course Service"]:::backend
            LangService["Language Service"]:::backend
            QuestionService["Question Service"]:::backend
        end

        subgraph SupportServices["Supporting Services"]
            AIService["AI Service"]:::backend
            VoiceAI["Voice AI Service"]:::backend
            MailService["Mail Service"]:::backend
            UploadService["Upload Service"]:::backend
        end

        subgraph Security["Security Layer"]
            Encryption["Encryption Service"]:::security
            JWTAuth["JWT Authentication"]:::security
            Guards["Auth Guards"]:::security
        end
    end

    %% External Services
    subgraph External["External Services"]
        MongoDB[(MongoDB)]:::external
        Cloudinary["Cloudinary Storage"]:::external
        EmailProvider["Email Provider"]:::external
    end

    %% Relationships
    Client --> NextJS
    NextJS --> AuthPages & CoursePages & ForumPages & DailyChallenge & LangPref
    NextJS --> TRPC
    TRPC <--> NestJS

    NestJS --> CoreServices
    NestJS --> SupportServices
    NestJS --> Security

    UploadService --> Cloudinary
    MailService --> EmailProvider
    NestJS --> MongoDB

    %% Click Events
    click AuthPages "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-frontend/src/core/pages/auth/"
    click AuthService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/auth/"
    click CoursePages "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-frontend/src/core/components/courses/"
    click CourseService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/courses/"
    click ForumPages "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-frontend/src/core/pages/forum/"
    click LangPref "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-frontend/src/core/pages/auth/language-preference-form/"
    click LangService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/languages/"
    click AIService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/ai/"
    click VoiceAI "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/voiceai/"
    click UserService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/users/"
    click QuestionService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/questions/"
    click MailService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/mail/"
    click UploadService "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/upload/"
    click Guards "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-backend/src/auth/guard/"
    click DailyChallenge "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-frontend/src/core/pages/daily-challenge/"
    click TRPC "https://github.com/Redcoat21/dolphin-streak/tree/main/dolphin-streak-frontend/src/server/routers/"
    click NestJS "https://github.com/Redcoat21/dolphin-streak/blob/main/dolphin-streak-backend/src/app.module.ts"
    click MongoDB "https://github.com/Redcoat21/dolphin-streak/blob/main/dolphin-streak-frontend/prisma/schema.prisma"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Service"]:::backend
        Security_L["Security Component"]:::security
        External_L["External Service"]:::external
    end
```
