# hugefrog24/tibiknini-public architecture

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

- Interactive diagram: https://gitdiagram.com/hugefrog24/tibiknini-public
- Repository: https://github.com/hugefrog24/tibiknini-public

## Overview

##### High-Level Architecture Components

a) Client Layer:
- React Frontend (frontend directory)
- Frontend routes and components
- User context provider

b) Network Layer:
- NGINX reverse proxy/load balancer
- WebSocket connections for presence feature

c) Application Layer:
- Django Backend with its major apps:
- Users (authentication/authorization)
- Blog (content management)
- Messages (communication)
- Presence (real-time features)
- Core (site configuration)
- Moderation (content moderation)

d) Data Layer:
- Database (PostgreSQL implied from Django setup)
- Media storage for profile pictures
- Cache layer (if applicable)

##### Component Relationships

a) Client-Server Communication:
- File uploads for profile pictures

b) Internal Service Communication:
- Celery task queue for async operations
- Signal handlers between Django apps
- Database access patterns

##### Specific Implementation Details

Key architectural patterns:

a) Authentication Flow:
- User registration/login paths
- Password reset flow
- Session management

b) Content Management:
- Blog post CRUD operations
- Comment system
- User following system

c) Real-time Features:
- Presence system using WebSocket
- Online users tracking

**[Client Layer]**
- ↓
**[Load Balancer/Reverse Proxy]**
- ↓
**[Application Services]**
- ↓
**[Data Layer]**

##### Important Details

- Docker container boundaries
- Database models relationships
- API endpoints grouping
- WebSocket channels
- Media file handling flow
- Authentication middleware
- Permission checks

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[React Frontend]:::frontend
        COMP[Components]:::frontend
        ROUTES[Routes]:::frontend
        UC[User Context]:::frontend
        
        FE --> COMP
        FE --> ROUTES
        FE --> UC
    end

    subgraph Network
        NGINX[NGINX Reverse Proxy]:::network
        WS[WebSocket Server]:::network
    end

    subgraph "Application Services"
        direction TB
        DJANGO[Django Backend]:::backend
        
        subgraph Auth
            USERS[Users Service]:::service
            AUTH_VIEWS[Auth Views]:::service
            AUTH_MODELS[User Models]:::service
            
            USERS --> AUTH_VIEWS
            USERS --> AUTH_MODELS
        end
        
        subgraph Content
            BLOG[Blog Service]:::service
            BLOG_MODELS[Blog Models]:::service
            COMMENTS[Comment Models]:::service
            
            BLOG --> BLOG_MODELS
            BLOG --> COMMENTS
        end
        
        subgraph Communication
            MSG[Messages Service]:::service
            PRESENCE[Presence Service]:::service
            PRESENCE_CONSUMER[Presence Consumer]:::service
            
            PRESENCE --> PRESENCE_CONSUMER
        end
        
        subgraph Core
            CORE[Core Service]:::service
            MOD[Moderation Service]:::service
            CELERY[Celery Tasks]:::service
            
            CORE --> CELERY
        end
        
        API[API Layer]:::api
        PERMS[Permissions]:::security
        
        DJANGO --> API
        API --> PERMS
    end

    subgraph "Data Layer"
        DB[(PostgreSQL)]:::database
        MEDIA[Media Storage]:::storage
        CACHE[(Cache)]:::cache
    end

    FE --> NGINX
    NGINX --> DJANGO
    WS --> PRESENCE_CONSUMER
    DJANGO --> DB
    DJANGO --> MEDIA
    DJANGO --> CACHE

    %% Click Events
    click FE "https://github.com/HugeFrog24/tibiknini-public/tree/prod/frontend/app/"
    click COMP "https://github.com/HugeFrog24/tibiknini-public/tree/prod/frontend/app/components/"
    click ROUTES "https://github.com/HugeFrog24/tibiknini-public/tree/prod/frontend/app/routes/"
    click UC "https://github.com/HugeFrog24/tibiknini-public/blob/prod/frontend/app/contexts/UserContext.tsx"
    click NGINX "https://github.com/HugeFrog24/tibiknini-public/blob/prod/nginx/nginx.conf.prod"
    click USERS "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/users/"
    click BLOG "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/blog/"
    click MSG "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/messages/"
    click PRESENCE "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/presence/"
    click CORE "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/core/"
    click MOD "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/moderation/"
    click AUTH_MODELS "https://github.com/HugeFrog24/tibiknini-public/blob/prod/backend/users/models.py"
    click AUTH_VIEWS "https://github.com/HugeFrog24/tibiknini-public/blob/prod/backend/users/views.py"
    click BLOG_MODELS "https://github.com/HugeFrog24/tibiknini-public/blob/prod/backend/blog/models/blogpost.py"
    click COMMENTS "https://github.com/HugeFrog24/tibiknini-public/blob/prod/backend/blog/models/comment.py"
    click PRESENCE_CONSUMER "https://github.com/HugeFrog24/tibiknini-public/blob/prod/backend/presence/consumers.py"
    click API "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/api/"
    click PERMS "https://github.com/HugeFrog24/tibiknini-public/blob/prod/backend/api/permissions.py"
    click MEDIA "https://github.com/HugeFrog24/tibiknini-public/tree/prod/backend/media/"

    %% Styling
    classDef frontend fill:#3498db
    classDef network fill:#2ecc71
    classDef backend fill:#27ae60
    classDef service fill:#16a085
    classDef database fill:#f1c40f
    classDef storage fill:#f39c12
    classDef cache fill:#e67e22
    classDef security fill:#e74c3c
    classDef api fill:#9b59b6

    %% Legend
    subgraph Legend
        L_FE[Frontend]:::frontend
        L_NET[Network]:::network
        L_SVC[Services]:::service
        L_DB[(Database)]:::database
        L_STORE[Storage]:::storage
        L_CACHE[(Cache)]:::cache
        L_SEC[Security]:::security
        L_API[API]:::api
    end
```
