# minand-mohan/recipe-app-api architecture

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

- Interactive diagram: https://gitdiagram.com/minand-mohan/recipe-app-api
- Repository: https://github.com/minand-mohan/recipe-app-api

## Overview

##### Main Components

a) Client Layer:
- External API consumers
- Supported HTTP methods (GET, POST, PUT, PATCH, DELETE)

b) Proxy Layer:
- Nginx reverse proxy (evident from proxy directory)
- SSL termination and request forwarding

c) Application Layer:
- Django REST Framework API
- User Service (user/ directory)
- Recipe Service (recipe/ directory)
- Core Service (core/ directory)

d) Database Layer:
- PostgreSQL (implied by Django migrations)
- Database relationships between models

##### Component Relationships

- Client → Nginx Proxy → Django Application
- Django Application → Database
- Inter-service communications between Django apps

##### Detailed Component Breakdown

a) API Services (show as separate components):
- User Management API
- Authentication endpoints
- User CRUD operations
- Recipe API
- Recipe management
- Tags management
- Ingredients management
- Core functionality
- Database models
- Shared utilities

b) Infrastructure Components:
- Docker containers (show container boundaries)
- Docker Compose services
- Health check endpoints

##### Specific Implementation Details

- Blue rectangles: Docker containers
- Green rectangles: Django apps
- Yellow diamonds: API endpoints
- Red rectangle: Nginx proxy

##### Additional Elements

Supporting components:
- Environment configuration
- Management commands
- Test suites
- Static/Media file handling

**[Client Layer]**
- ↓
**[Proxy Layer (Nginx)]**
- ↓
**[Application Layer (Django)]**
- ↓
**[Database Layer (PostgreSQL)]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        API_CONSUMER["API Consumer"]
        HTTP_METHODS["HTTP Methods<br/>GET, POST, PUT, PATCH, DELETE"]
    end

    subgraph Proxy["Proxy Layer"]
        direction TB
        NGINX["Nginx Reverse Proxy<br/>SSL Termination"]:::proxy
        PROXY_CONFIG["Proxy Config"]:::config
    end

    subgraph App["Application Layer"]
        direction TB
        subgraph Django["Django REST Framework"]
            direction TB
            ASGI["ASGI Interface"]:::app
            WSGI["WSGI Interface"]:::app
            
            subgraph Services["API Services"]
                direction TB
                USER_SERVICE["User Service"]:::service
                RECIPE_SERVICE["Recipe Service"]:::service
                CORE_SERVICE["Core Service"]:::service
            end

            subgraph Health["Health Monitoring"]
                direction TB
                HEALTH_CHECK["Health Check System"]:::health
            end
        end
    end

    subgraph Data["Database Layer"]
        direction TB
        DB[(PostgreSQL)]:::database
        DB_WAIT["Wait For DB"]:::util
    end

    subgraph Infrastructure["Infrastructure"]
        direction TB
        DOCKER["Docker Container"]:::infra
        DOCKER_COMPOSE["Docker Compose"]:::infra
        ENV_CONFIG["Environment Config"]:::config
    end

    %% Relationships
    API_CONSUMER --> HTTP_METHODS
    HTTP_METHODS --> NGINX
    NGINX --> ASGI
    NGINX --> WSGI
    ASGI --> Services
    WSGI --> Services
    USER_SERVICE --> DB
    RECIPE_SERVICE --> DB
    CORE_SERVICE --> DB
    DB_WAIT --> DB
    
    %% Click Events
    click NGINX "https://github.com/minand-mohan/recipe-app-api/tree/main/proxy"
    click PROXY_CONFIG "https://github.com/minand-mohan/recipe-app-api/blob/main/proxy/default.conf.tpl"
    click USER_SERVICE "https://github.com/minand-mohan/recipe-app-api/tree/main/app/user"
    click RECIPE_SERVICE "https://github.com/minand-mohan/recipe-app-api/tree/main/app/recipe"
    click CORE_SERVICE "https://github.com/minand-mohan/recipe-app-api/tree/main/app/core"
    click ASGI "https://github.com/minand-mohan/recipe-app-api/blob/main/app/app/asgi.py"
    click WSGI "https://github.com/minand-mohan/recipe-app-api/blob/main/app/app/wsgi.py"
    click DB_WAIT "https://github.com/minand-mohan/recipe-app-api/blob/main/app/core/management/commands/wait_for_db.py"
    click HEALTH_CHECK "https://github.com/minand-mohan/recipe-app-api/blob/main/app/core/tests/test_healthcheck.py"
    click DOCKER "https://github.com/minand-mohan/recipe-app-api/tree/main/Dockerfile"
    click DOCKER_COMPOSE "https://github.com/minand-mohan/recipe-app-api/blob/main/docker-compose.yml"
    click ENV_CONFIG "https://github.com/minand-mohan/recipe-app-api/blob/main/.env.sample"

    %% Styling
    classDef proxy fill:#ff6b6b
    classDef config fill:#4ecdc4
    classDef app fill:#45b7d1
    classDef service fill:#96ceb4
    classDef health fill:#ffeead
    classDef database fill:#6c5ce7
    classDef util fill:#a8e6cf
    classDef infra fill:#ff9f1c

    %% Legend
    subgraph Legend
        direction TB
        L1["Proxy Component"]:::proxy
        L2["Configuration"]:::config
        L3["App Component"]:::app
        L4["Service"]:::service
        L5["Health Check"]:::health
        L6["Database"]:::database
        L7["Utility"]:::util
        L8["Infrastructure"]:::infra
    end
```
