# flukeapr/final-project-web architecture

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

- Interactive diagram: https://gitdiagram.com/flukeapr/final-project-web
- Repository: https://github.com/flukeapr/final-project-web

## Overview

##### Main Components

Frontend Layer:
- Client-Side Application (Next.js Pages)
- Components Layer
- Context Providers
- Authentication UI

API Layer:
- REST API Routes
- Authentication Endpoints
- Protected Routes
- Media Handling
- Chat System
- Quiz System

Backend Services:
- Database (MySQL)
- Authentication Service
- File Storage System
- Chat Service
- Quiz Processing Engine

**Client Layer**

**API Gateway Layer**

**Service Layer**

**Data Layer**

##### Component Relationships

- Client components → API Routes (REST calls)
- API Routes → Service Layer (business logic)
- Service Layer → Data Layer (database operations)
- Authentication flow across all layers

##### Specific Implementation Details

Frontend Components:
- Main pages: Homepage, Community, Media, Support
- Authentication flows
- User interaction components

API Structure:
- Related endpoints (auth, media, chat, quiz)
- Protected vs public routes
- File upload paths

Backend Services:
- Database connections
- File storage system
- Authentication service
- Real-time features (chat)

##### Important Elements to Highlight

- Next.js App Router structure
- API route organization
- Authentication flow (including 2FA)
- Media handling pipeline
- Database schema relationships
- User interaction flows
- Chat system architecture
- Quiz system workflow

##### Technical Stack Indicators

Clearly mark:
- Next.js framework
- MySQL database
- Authentication provider
- File storage solution
- API documentation (Swagger)

##### Security Layer

Highlight:
- Authentication middleware
- Protected routes
- 2FA implementation
- Password reset flow
- User permissions

For this specific project, emphasize:

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Pages["Pages"]
        Components["Components Layer"]
        Context["Context Provider"]
        AuthUI["Authentication UI"]
    end

    subgraph APIGateway
        direction TB
        AuthAPI["Authentication API"]
        MediaAPI["Media API"]
        ChatAPI["Chat API"]
        QuizAPI["Quiz API"]
        UserAPI["User Management API"]
        APIDoc["API Documentation"]
    end

    subgraph Services
        direction TB
        AuthService["Authentication Service"]
        FileStorage["File Storage System"]
        DBService["Database Service"]
        ChatService["Chat Service"]
        QuizEngine["Quiz Engine"]
    end

    subgraph Storage
        DB[(MySQL Database)]
        MediaStorage[("Media Storage")]
    end

    %% Client Layer Connections
    Pages --> APIGateway
    Components --> APIGateway
    Context --> APIGateway
    AuthUI --> AuthAPI

    %% API Gateway Connections
    AuthAPI --> AuthService
    MediaAPI --> FileStorage
    ChatAPI --> ChatService
    QuizAPI --> QuizEngine
    UserAPI --> DBService

    %% Service Layer Connections
    AuthService --> DB
    FileStorage --> MediaStorage
    DBService --> DB
    ChatService --> DB
    QuizEngine --> DB

    %% Component Mappings
    click Pages "https://github.com/flukeapr/final-project-web/tree/master/src/app/"
    click Components "https://github.com/flukeapr/final-project-web/tree/master/src/app/components/"
    click Context "https://github.com/flukeapr/final-project-web/blob/master/src/app/context/UsersContext.js"
    click AuthUI "https://github.com/flukeapr/final-project-web/tree/master/src/app/login/"
    click AuthAPI "https://github.com/flukeapr/final-project-web/tree/master/src/app/api/auth/"
    click MediaAPI "https://github.com/flukeapr/final-project-web/tree/master/src/app/api/media/"
    click ChatAPI "https://github.com/flukeapr/final-project-web/tree/master/src/app/api/chat/"
    click QuizAPI "https://github.com/flukeapr/final-project-web/tree/master/src/app/api/quiz/"
    click DBService "https://github.com/flukeapr/final-project-web/blob/master/lib/ConnectDb.js"
    click AuthService "https://github.com/flukeapr/final-project-web/blob/master/lib/auth.js"
    click FileStorage "https://github.com/flukeapr/final-project-web/tree/master/public/media/uploads/"
    click APIDoc "https://github.com/flukeapr/final-project-web/tree/master/src/app/api-doc/"
    click UserAPI "https://github.com/flukeapr/final-project-web/tree/master/src/app/api/updateuser/"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white

    class Pages,Components,Context,AuthUI frontend
    class AuthAPI,MediaAPI,ChatAPI,QuizAPI,UserAPI,APIDoc api
    class AuthService,FileStorage,DBService,ChatService,QuizEngine service
    class DB,MediaStorage storage
```
