# mikebgrep/fork.recipes architecture

> Architecture diagram of the GitHub repository mikebgrep/fork.recipes, 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/fork.recipes
- Repository: https://github.com/mikebgrep/fork.recipes

## Overview

##### Main Components

a) Client Layer:
- Web Browser Interface
- Static Assets (CSS/Images)
- Template System (Django Templates)

b) Application Layer:
- Django Web Application
- Recipe Management Module
- Authentication/Authorization System
- WebSocket Communication
- Recipe Scraping Service (OpenAI Integration)

c) External Services:
- ForkAPI Integration
- OpenAI API (for recipe scraping)

d) Infrastructure Layer:
- Nginx Web Server (with SSL/NoSSL configurations)
- uWSGI Application Server
- Docker Containers

**[Client Layer]**
- ↓
**[Nginx (Reverse Proxy)]**
- ↓
**[uWSGI Server]**
- ↓
**[Django Application]**
- ↓↔
**[External Services]**

##### Specific Implementation Details

a) Frontend Components:
- Template structure (/recipes/templates)
- Static asset management (Tailwind CSS)
- User interaction points (recipe list, detail, edit, etc.)

b) Backend Components:
- Django views and URL routing
- Middleware (especially remote_auth_middleware)
- Utility services (date_util, email_util)
- WebSocket communication layer

c) External Integration Points:
- ForkAPI connection
- OpenAI integration for recipe scraping
- Email service for password reset

##### Infrastructure Details

Docker container boundaries:
- Nginx container (with SSL/NoSSL options)
- Django application container
- How these containers communicate

##### Additional Elements

Annotations for:
- Security layers (SSL termination at Nginx)
- Authentication flow
- Recipe data flow
- Media handling (videos/images)

##### Technical Specifications

Technical details:
- Django 5.x
- Docker deployment
- SSL/NoSSL configurations
- WebSocket capabilities
- Recipe scraping functionality

Remember to highlight the scalability aspects and security measures, particularly the SSL configuration options and authentication middleware.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        Browser["Web Browser"]:::client
        Templates["Django Templates"]:::frontend
        Static["Static Assets"]:::frontend
    end

    subgraph Proxy["Proxy Layer"]
        Nginx["Nginx Reverse Proxy"]:::server
        SSL["SSL Termination"]:::security
    end

    subgraph AppServer["Application Server Layer"]
        uWSGI["uWSGI Server"]:::server
    end

    subgraph Django["Django Application"]
        DjangoCore["Django Core"]:::backend
        click DjangoCore "https://github.com/mikebgrep/fork.recipes/blob/master/fork_recipes/backend/settings.py"
        
        RecipeModule["Recipe Management"]:::backend
        click RecipeModule "https://github.com/mikebgrep/fork.recipes/blob/master/fork_recipes/recipes/models.py"
        
        AuthSystem["Authentication System"]:::security
        click AuthSystem "https://github.com/mikebgrep/fork.recipes/blob/master/fork_recipes/recipes/middleware/remote_auth_middleware.py"
        
        WSHandler["WebSocket Handler"]:::backend
        click WSHandler "https://github.com/mikebgrep/fork.recipes/blob/master/fork_recipes/recipes/ws/api_request.py"
        
        Utils["Utility Services"]:::backend
        click Utils "https://github.com/mikebgrep/fork.recipes/tree/master/fork_recipes/recipes/utils"
    end

    subgraph External["External Services"]
        ForkAPI["ForkAPI"]:::external
        OpenAI["OpenAI API"]:::external
        EmailService["Email Service"]:::external
    end

    %% Client Layer Connections
    Browser --> Templates
    Browser --> Static
    click Templates "https://github.com/mikebgrep/fork.recipes/tree/master/fork_recipes/recipes/templates/recipes"
    click Static "https://github.com/mikebgrep/fork.recipes/tree/master/fork_recipes/recipes/static"

    %% Proxy Layer Connections
    Browser --> Nginx
    Nginx --> SSL
    click Nginx "https://github.com/mikebgrep/fork.recipes/blob/master/nginx/forkrecipes.nginx.template"

    %% Application Server Connections
    Nginx --> uWSGI
    click uWSGI "https://github.com/mikebgrep/fork.recipes/blob/master/fork_recipes/uwsgi.ini"

    %% Django Application Connections
    uWSGI --> DjangoCore
    DjangoCore --> RecipeModule
    DjangoCore --> AuthSystem
    DjangoCore --> WSHandler
    DjangoCore --> Utils

    %% External Service Connections
    RecipeModule -.-> ForkAPI
    RecipeModule -.-> OpenAI
    AuthSystem -.-> EmailService

    %% Styling
    classDef client fill:#E1F5FE,stroke:#01579B
    classDef frontend fill:#E8F5E9,stroke:#2E7D32
    classDef server fill:#FFF3E0,stroke:#E65100
    classDef backend fill:#E8EAF6,stroke:#1A237E
    classDef security fill:#FCE4EC,stroke:#880E4F
    classDef external fill:#F3E5F5,stroke:#4A148C

    %% Legend
    subgraph Legend
        Client_["Client Components"]:::client
        Frontend_["Frontend Components"]:::frontend
        Server_["Server Components"]:::server
        Backend_["Backend Components"]:::backend
        Security_["Security Components"]:::security
        External_["External Services"]:::external
    end
```
