# fanygomez/recipe-drf-api architecture

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

- Interactive diagram: https://gitdiagram.com/fanygomez/recipe-drf-api
- Repository: https://github.com/fanygomez/recipe-drf-api

## Overview

##### Main Components
a. API Clients/Consumers:
b. Django Application:
- “RecipeAPI” Package: This contains high-level configurations, routing (urls.py), ASGI/WGSI setups, and overall settings.
- “Core” App: Includes business logic such as models, admin, management commands (e.g., wait_for_db), and tests. This is where domain-specific functionality (recipe operations, ingredient/tag tracking) primarily occurs.
- Internal interactions among modules (e.g., the “core” app providing business logic to the “RecipeAPI” endpoints).
c. Database:
- A dedicated component for the PostgreSQL database (as specified in the README).
d. Docker Environment:
- Docker configuration environment, representing the Docker container image (Dockerfile) and the orchestration layer via docker-compose.
- That the Django application and the PostgreSQL database (and possibly other services) run inside separate containers.
e. CI/CD Pipeline:
- A component for “GitHub Actions CI” as defined by the GitHub workflows. This highlights automated testing, linting (Flake8), and integration checks.
f. Development Tools:
- That development practices include automated testing and linting. This can be annexed to the CI/CD component or flagged within the Docker development environment.

##### Relationships and Data Flow
- API Consumers → Django API (HTTP request/response flow)
- Django API → Database (ORM-driven interactions for CRUD operations)
- VCS/Repository → CI/CD Pipeline (triggering builds, tests, and linting checks)
- Docker orchestration encompassing both Django and PostgreSQL containers, showing how these are isolated yet interact over the network.

##### Architectural Patterns and Design Principles
- Model-View-Controller (MVC) or more specifically the Model-Template-View (MTV) pattern common to Django. Emphasize how models (in the “core” app) support business rules and interact with views/routes defined in “recipeapi”.
- Separation of concerns by isolating configuration, business logic, and container orchestration.
- That the project utilizes modern DevOps practices (containerization and CI/CD) which are key concepts in the architectural layout.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% API Consumers
    A("API Consumers"):::consumers

    %% Django Application Subgraph
    subgraph "Django Application"
        R("RecipeAPI Package"):::django
        C("Core App"):::django
        R -->|"uses_logic"| C
    end

    %% Docker Environment Subgraph
    subgraph "Docker Environment"
        DC("Django Container"):::docker
        PC("PostgreSQL Container"):::docker
        DC -->|"ORM_calls"| PC
    end

    %% CI/CD and Repository
    Repo("Version Control Repository"):::ci
    CI("GitHub Actions CI"):::ci
    Repo -->|"triggers_pipeline"| CI
    CI -->|"deploys_builds"| DC

    %% Development Tools Subgraph
    subgraph "Development Tools"
        F("Flake8 Config"):::dev
        DR("Dev Requirements"):::dev
        RQ("Requirements"):::dev
    end
    CI -->|"runs_linting"| F

    %% Connections from API Consumers to Django environment
    A -->|"HTTP_request"| DC
    DC -->|"serves_API"| R

    %% Connection from Django App to Database (via Docker containers)
    DC -->|"processes_data"| PC

    %% Click events for component mappings
    click R "https://github.com/fanygomez/recipe-drf-api/tree/main/src/recipeapi"
    click C "https://github.com/fanygomez/recipe-drf-api/tree/main/src/core"
    click DC "https://github.com/fanygomez/recipe-drf-api/blob/main/Dockerfile and docker-compose.yml"
    click CI "https://github.com/fanygomez/recipe-drf-api/blob/main/.github/workflows/checks.yml"
    click F "https://github.com/fanygomez/recipe-drf-api/blob/main/src/.flake8"
    click DR "https://github.com/fanygomez/recipe-drf-api/blob/main/requirements/requirements.dev.txt"
    click RQ "https://github.com/fanygomez/recipe-drf-api/blob/main/requirements/requirements.txt"

    %% Styles
    classDef consumers fill:#ffe6f0,stroke:#cc3366,stroke-width:2px;
    classDef django fill:#cce5ff,stroke:#3366cc,stroke-width:2px;
    classDef docker fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef ci fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef dev fill:#f4cccc,stroke:#cc0000,stroke-width:2px;
```
