# realsuayip/django-sozluk architecture

> Architecture diagram of the GitHub repository realsuayip/django-sozluk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/realsuayip/django-sozluk
- Repository: https://github.com/realsuayip/django-sozluk

## Overview

##### Main Components

a. Frontend Layer:
- Static files (CSS, JS, templates)
- User interface components
- GraphQL client integration

b. Backend Layer:
- Django application server
- GraphQL API (dictionary_graph)
- Celery task queue
- Authentication system
- Admin interface

c. Infrastructure:
- Nginx reverse proxy
- PostgreSQL database
- Docker containers
- Cache layer (Redis/Memcached, implied by cached_db.py)

**[Client Layer]**
- ↓ ↑
**[Load Balancer Layer (Nginx)]**
- ↓ ↑
**[Application Layer]**
- ↓ ↑
**[Data Layer]**

##### Component Details

a. Client Layer:
- Browser/mobile clients
- Static assets (dictionary/static/)
- Template rendering (dictionary/templates/)

b. Load Balancer Layer:
- Nginx configuration (conf/nginx.conf)
- SSL termination
- Static file serving

c. Application Layer:
- Django Web Application
- URL routing (dictionary/urls/)
- Views (dictionary/views/)
- Forms (dictionary/forms/)
- GraphQL API (dictionary_graph/)
- Celery Worker
- Admin Interface

d. Data Layer:
- PostgreSQL Database
- Cache Store
- File Storage (for images)

##### Key Relationships to Highlight

- Authentication flow
- GraphQL API interactions
- Database access patterns
- Caching layer interactions
- Task queue workflow

##### Deployment Context

Two configurations:
- Development environment (docker/dev/)
- Production environment (docker/prod/)

##### Additional Elements

- Version information
- Scaling points
- Security boundaries
- Backup systems

Remember to indicate the Docker container boundaries and how they interact in the production environment, as this is a containerized application with distinct services for web, database, and nginx.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        Mobile["Mobile Client"]
    end

    subgraph "Load Balancer"
        Nginx["Nginx Reverse Proxy"]:::infra
        click Nginx "https://github.com/realsuayip/django-sozluk/blob/master/docker/prod/nginx/nginx.conf"
    end

    subgraph "Application Layer"
        Django["Django Web Server"]:::app
        
        subgraph "Core Components"
            Auth["Authentication System"]:::security
            click Auth "https://github.com/realsuayip/django-sozluk/blob/master/dictionary/views/auth.py"
            
            Views["View Controllers"]:::app
            click Views "https://github.com/realsuayip/django-sozluk/tree/master/dictionary/views/"
            
            URLs["URL Router"]:::app
            click URLs "https://github.com/realsuayip/django-sozluk/tree/master/dictionary/urls/"
            
            I18n["Internationalization"]:::app
            click I18n "https://github.com/realsuayip/django-sozluk/tree/master/dictionary/locale/"
            
            Admin["Admin Interface"]:::app
            click Admin "https://github.com/realsuayip/django-sozluk/tree/master/dictionary/admin/"
        end

        subgraph "Frontend Components"
            Templates["Templates"]:::frontend
            click Templates "https://github.com/realsuayip/django-sozluk/tree/master/dictionary/templates/dictionary/"
            
            Static["Static Assets"]:::frontend
            click Static "https://github.com/realsuayip/django-sozluk/tree/master/dictionary/static/dictionary/"
        end

        subgraph "API Layer"
            GraphQL["GraphQL API"]:::api
            click GraphQL "https://github.com/realsuayip/django-sozluk/tree/master/dictionary_graph/"
        end

        subgraph "Background Processing"
            Celery["Celery Worker"]:::worker
            click Celery "https://github.com/realsuayip/django-sozluk/blob/master/djdict/celery.py"
        end
    end

    subgraph "Data Layer"
        subgraph "Storage"
            PostgreSQL[(PostgreSQL)]:::db
            Redis[(Cache Store)]:::cache
            click Redis "https://github.com/realsuayip/django-sozluk/blob/master/dictionary/backends/sessions/cached_db.py"
            FileStore[("File Storage")]:::storage
        end

        subgraph "Core Models"
            Author["Author Model"]:::model
            click Author "https://github.com/realsuayip/django-sozluk/blob/master/dictionary/models/author.py"
            
            Entry["Entry Model"]:::model
            click Entry "https://github.com/realsuayip/django-sozluk/blob/master/dictionary/models/entry.py"
            
            Topic["Topic Model"]:::model
            click Topic "https://github.com/realsuayip/django-sozluk/blob/master/dictionary/models/topic.py"
        end
    end

    %% Relationships
    Browser --> Nginx
    Mobile --> Nginx
    Nginx --> Django
    Django --> Auth
    Django --> Views
    Django --> URLs
    Django --> Templates
    Django --> Static
    Django --> GraphQL
    Django --> Admin
    Django --> I18n
    Auth --> PostgreSQL
    Views --> PostgreSQL
    GraphQL --> PostgreSQL
    Django --> Celery
    Celery --> PostgreSQL
    PostgreSQL --> Redis
    Django --> Redis
    Django --> FileStore

    %% Styles
    classDef frontend fill:#3498db
    classDef app fill:#2ecc71
    classDef api fill:#9b59b6
    classDef db fill:#f1c40f
    classDef cache fill:#e67e22
    classDef security fill:#e74c3c
    classDef infra fill:#95a5a6
    classDef worker fill:#1abc9c
    classDef storage fill:#34495e
    classDef model fill:#16a085

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Application["Application"]:::app
        API["API"]:::api
        Database["Database"]:::db
        Cache["Cache"]:::cache
        Security["Security"]:::security
        Infrastructure["Infrastructure"]:::infra
        Worker["Worker"]:::worker
        Storage["Storage"]:::storage
        Model["Model"]:::model
    end
```
