# damika-anupama/jahan.ai-case-study architecture

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

- Interactive diagram: https://gitdiagram.com/damika-anupama/jahan.ai-case-study
- Repository: https://github.com/damika-anupama/jahan.ai-case-study

## Overview

##### Main Components

A. Client Layer:
- NextJS Frontend Application
- Public Pages (Registration, Login)
- Protected Pages (Preferences Management)
- Theme System (Dark/Light mode)
- Responsive UI Components

B. API Layer:
- Django Backend Application
- REST API Endpoints
- JWT Authentication Service
- Validation Layer

C. Data Layer:
- MySQL Database
- User Preferences Models:
- Account Settings
- Notification Settings
- Theme Settings
- Privacy Settings

**[Client Tier]**
- ↕
**[Application Tier]**
- ↕
**[Data Tier]**

##### Detailed Component Connections

Frontend Layer:
**[Next.js App] → [Pages]**
- Registration
- Login
- Preferences Dashboard
- Account Settings
- Notification Settings
- Theme Settings
- Privacy Settings

Backend Layer:
**[Django REST Framework]**
- Authentication Service
- Preferences API
- Account Settings Endpoints
- Notification Settings Endpoints
- Theme Settings Endpoints
- Privacy Settings Endpoints
- Validation Layer

##### Key Interactions to Highlight

- JWT Authentication Flow:
- [Frontend] ←→ [Auth Service] ←→ [Database]
- Preferences Management Flow:
- [Frontend] ←→ [API Layer] ←→ [Models] ←→ [Database]

##### Additional Elements

- Security Layer:
- JWT Token Flow
- Authentication Middleware

- → for one-way communication
- ↔ for two-way communication

- Environment Boundaries:
- Client Environment
- Server Environment
- Database Environment

##### Technical Stack Indicators

Technology badges or labels:
- Frontend: Next.js, TypeScript, Tailwind CSS
- Backend: Django, Django REST Framework
- Database: MySQL
- Authentication: JWT

##### Important Notes

- Clear separation between frontend and backend services
- Protected vs public routes
- Responsive design aspect
- Testing components for both frontend and backend
- Error handling and validation flow
- Where accessibility features are implemented

Remember to maintain a balance between showing enough detail to understand the system's architecture while keeping it clean and readable. The focus should be on the interaction between components rather than implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "API Layer"
        DJANGO["Django Backend"]:::backend
        click DJANGO "https://github.com/Damika-Anupama/jahan.ai-case-study/tree/main/user_preferences_backend/"
        
        AUTH["JWT Auth Service"]:::backend
        click AUTH "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/preferences/auth.py"
        
        API["REST API Endpoints"]:::backend
        click API "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/preferences/views.py"
        
        ROUTES["API Routes"]:::backend
        click ROUTES "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/preferences/urls.py"
        
        VAL["Validation Layer"]:::backend
        
        SERIAL["API Serializers"]:::backend
        click SERIAL "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/preferences/serializers.py"
        
        TESTS["Backend Tests"]:::backend
        click TESTS "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/preferences/tests/test_views.py"
        
        DJANGO --> AUTH
        DJANGO --> API
        DJANGO --> ROUTES
        DJANGO --> VAL
        DJANGO --> SERIAL
        DJANGO --> TESTS
    end
    
    subgraph "Data Layer"
        DB[(MySQL Database)]:::database
        click DB "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/queries.sql"
        
        MODELS["Data Models"]:::backend
        click MODELS "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/preferences/models.py"
        
        SETTINGS["Backend Settings"]:::backend
        click SETTINGS "https://github.com/Damika-Anupama/jahan.ai-case-study/blob/main/user_preferences_backend/user_preferences_backend/settings.py"
        
        DB --- MODELS
        MODELS --- SETTINGS
    end
    
    API -..-> MODELS
    AUTH -..-> MODELS
    
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    
    subgraph Legend
        B["Backend Component"]:::backend
        D["Database Component"]:::database
    end
```
