# mikebgrep/forkapi architecture

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

- Interactive diagram: https://gitdiagram.com/mikebgrep/forkapi
- Repository: https://github.com/mikebgrep/forkapi

## Overview

##### Main Components

a) Client Layer:
- External Web Clients (fork.recipes frontend)
- Admin Panel (Django Admin with Jazzmin)
- Third-party API Consumers

b) Nginx Layer:
- Reverse Proxy
- SSL Termination (optional configuration)
- Static/Media File Serving

c) Application Layer:
- Django Application Server (uWSGI)
- Two main Django Apps:
- Authentication Module
- Recipe Module
- OpenAI Integration (for recipe scraping)

d) Data Layer:
- SQLite Database
- Media Storage (for recipe media files)

##### Component Relationships

- Client requests → Nginx → Django Application
- Django Application ↔ SQLite Database
- Django Application ↔ Media Storage
- Recipe Module ↔ OpenAI API
- Authentication Module ↔ Token Management

##### Specific Implementation Details

- Blue rectangles: External interfaces (Nginx, Client applications)
- Green rectangles: Core application components (Django apps)
- Purple clouds: External services (OpenAI)

##### Authentication Flow

Two authentication methods:
- Header Authentication (for read operations)
- Token Authentication (for create/update operations)

##### Key Technical Elements

Important components:
- uWSGI application server
- Django REST Framework endpoints
- Admin Panel with Jazzmin interface
- Docker containerization boundary

##### Additional Notes

- Request flow directions
- Authentication boundaries
- Container boundaries
- Environment configurations

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Clients
        WC[Web Clients]
        AP["Admin Panel"]:::admin
        TP[Third-party API Consumers]
    end

    subgraph NginxLayer[Nginx Layer]
        NG["Nginx Reverse Proxy"]:::nginx
        SSL["SSL Termination"]:::nginx
        Static["Static/Media Server"]:::nginx
    end
    click NG "https://github.com/mikebgrep/forkapi/blob/master/nginx/nginx.conf"
    click SSL "https://github.com/mikebgrep/forkapi/tree/master/nginx/ssl/"
    click NginxLayer "https://github.com/mikebgrep/forkapi/tree/master/nginx/"

    subgraph AppServer[Application Server]
        UWSGI["uWSGI Server"]:::server
        WSGI["WSGI Application"]:::server
        ASGI["ASGI Application"]:::server
    end
    click UWSGI "https://github.com/mikebgrep/forkapi/blob/master/forkapi/uwsgi.ini"
    click WSGI "https://github.com/mikebgrep/forkapi/blob/master/forkapi/wsgi.py"
    click ASGI "https://github.com/mikebgrep/forkapi/blob/master/forkapi/asgi.py"

    subgraph DjangoApp[Django Application]
        direction TB
        subgraph Auth[Authentication Module]
            AM["Models"]:::auth
            AV["Views"]:::auth
            AS["Serializers"]:::auth
            AU["URLs"]:::auth
        end
        click Auth "https://github.com/mikebgrep/forkapi/tree/master/forkapi/authentication/"
        click AM "https://github.com/mikebgrep/forkapi/blob/master/forkapi/authentication/models.py"
        click AV "https://github.com/mikebgrep/forkapi/blob/master/forkapi/authentication/views.py"
        click AS "https://github.com/mikebgrep/forkapi/blob/master/forkapi/authentication/serializers.py"
        click AU "https://github.com/mikebgrep/forkapi/blob/master/forkapi/authentication/urls.py"

        subgraph Recipe[Recipe Module]
            RM["Models"]:::recipe
            RV["Views"]:::recipe
            RU["URLs"]:::recipe
            HA["Header Authentication"]:::recipe
            OAI["OpenAI Integration"]:::recipe
        end
        click Recipe "https://github.com/mikebgrep/forkapi/tree/master/forkapi/recipe/"
        click RM "https://github.com/mikebgrep/forkapi/blob/master/forkapi/recipe/models.py"
        click RV "https://github.com/mikebgrep/forkapi/blob/master/forkapi/recipe/views.py"
        click RU "https://github.com/mikebgrep/forkapi/blob/master/forkapi/recipe/urls.py"
        click HA "https://github.com/mikebgrep/forkapi/blob/master/forkapi/recipe/HeaderAuthentication.py"
        click OAI "https://github.com/mikebgrep/forkapi/blob/master/forkapi/recipe/openai_util.py"

        Core["Core Settings & URLs"]:::core
    end
    click Core "https://github.com/mikebgrep/forkapi/blob/master/forkapi/settings.py"

    subgraph DataLayer[Data Layer]
        DB[(SQLite Database)]:::storage
        MS[(Media Storage)]:::storage
        TMP[(Temp Media)]:::storage
    end
    click DB "https://github.com/mikebgrep/forkapi/tree/master/forkapi/sql/"
    click MS "https://github.com/mikebgrep/forkapi/tree/master/forkapi/media/"
    click TMP "https://github.com/mikebgrep/forkapi/tree/master/forkapi/media/temp_recipe_media/"

    OpenAI["OpenAI API"]:::external

    %% Connections
    Clients --> NginxLayer
    NginxLayer --> AppServer
    AppServer --> DjangoApp
    Auth <--> DB
    Recipe <--> DB
    Recipe <--> MS
    Recipe <--> TMP
    Recipe <--> OpenAI
    Static <--> MS

    %% Styles
    classDef nginx fill:#6B8E9F,stroke:#333,stroke-width:2px
    classDef server fill:#90A959,stroke:#333,stroke-width:2px
    classDef auth fill:#96B5B4,stroke:#333,stroke-width:2px
    classDef recipe fill:#8FA1B3,stroke:#333,stroke-width:2px
    classDef storage fill:#F0C674,stroke:#333,stroke-width:2px
    classDef external fill:#B294BB,stroke:#333,stroke-width:2px
    classDef core fill:#81A2BE,stroke:#333,stroke-width:2px
    classDef admin fill:#CC6666,stroke:#333,stroke-width:2px
```
