# maxkunev/foodie-app architecture

> Architecture diagram of the GitHub repository maxkunev/foodie-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maxkunev/foodie-app
- Repository: https://github.com/maxkunev/foodie-app

## Overview

#### 1. Purpose and entry points
Foodie App is a server-rendered Django recipe discovery and social-interaction application, with a REST API. Runtime entry points are `manage.py` for Django commands, `djangocoursera/wsgi.py` for Gunicorn, and `djangocoursera/asgi.py` for ASGI deployment. Global routing and application configuration begin in `djangocoursera/urls.py` and `djangocoursera/settings.py`.

#### 2. Project composition and routing
The project is divided by domain: recipe management (`recipes/`), authentication/profile management (`accounts/`), comments (`comments/`), and home/category functionality (`foodie_app/`). Django resolves project routes into per-app URL modules, which dispatch to views and templates:
- `djangocoursera/urls.py`
- `recipes/urls.py`
- `accounts/urls.py`

#### 3. Recipe domain: primary application core
`recipes` owns the central Recipe model, user ownership, uploaded images, favorites, likes, recipe CRUD, browsing, search, sorting, category filtering, and public/my/favorite recipe views. It also exposes the API layer and authorization rules. The model-to-view-to-template path is centered on:
- `recipes/models.py`
- `recipes/views.py`
- `recipes/templates/recipes/recipes.html`

Search/filter query construction, pagination behavior, and related reusable logic are separated from views in `recipes/utils.py`. Request-level template context is extended via `recipes/context_processors.py`.

#### 4. User identity and social interactions
`accounts` provides registration, login-adjacent templates, profile editing, profile images, and persisted user preferences such as theme preference. Its profile data extends Django’s user identity and is consumed by recipes and comments:
- `accounts/models.py`
- `accounts/views.py`
- `accounts/forms.py`

Comments are a separate bounded domain associated with recipes and authenticated users. Comment submission and display flow through:
- `comments/models.py`
- `comments/views.py`
- `comments/urls.py`

#### 5. HTML and dynamic interaction flow
Most user requests follow Django’s server-rendered MVC flow: URL → view → form/model/query logic → HTML template. Shared presentation is rooted at `templates/base.html`; feature templates live beside their owning app. Recipe likes/favorites use an HTMX/AJAX-style partial-update boundary, with client behavior in `static/js/recipe/favorites-ajax.js` and reusable UI fragment `recipes/templates/recipes/includes/like_button.html`.

#### 6. API and authorization boundary
Django REST Framework serializers expose recipe data independently of HTML rendering, while custom permissions protect mutation or ownership-sensitive operations. OpenAPI documentation is supplied through drf-spectacular according to project settings/routes. Key API boundary files are:
- `recipes/serializers.py`
- `recipes/permissions.py`
- `recipes/views.py`

#### 7. Persistence, media, and deployment
Django migrations define the relational schema for users/profiles, recipes, and comments. Local development defaults to SQLite; production uses PostgreSQL configured through environment variables and `dj-database-url`. Recipe/profile media is intended for Cloudinary, static assets are served via WhiteNoise, and search/filter results use in-memory caching. Container deployment is defined by:
- `Dockerfile`
- `docker-compose.yml`
- `djangocoursera/settings.py`

The Compose deployment runs the Django/Gunicorn web service with PostgreSQL; Render is the managed production hosting target.

Main entry points: [`recipes/views.py`](https://github.com/maxkunev/foodie-app/blob/develop/recipes/views.py) (Recipe core), [`comments/models.py`](https://github.com/maxkunev/foodie-app/blob/develop/comments/models.py) (Comments), [`djangocoursera/settings.py`](https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/settings.py) (Settings), [`djangocoursera/urls.py`](https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/urls.py) (Project router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_project["Django project"]
  node_manage{{"Django commands<br/>entry point<br/>[manage.py]"}}
  node_wsgi{{"Gunicorn WSGI<br/>deployment entry<br/>[wsgi.py]"}}
  node_asgi{{"ASGI entry<br/>deployment entry<br/>[asgi.py]"}}
  node_settings["Settings<br/>project config<br/>[settings.py]"]
  node_root_urls["Project router<br/>URL routing<br/>[urls.py]"]
end

subgraph group_domains["Domain apps"]
  node_recipe_urls["Recipe routes<br/>app routing<br/>[urls.py]"]
  node_recipe_core["Recipe core<br/>models and views<br/>[views.py]"]
  node_recipe_model[("Recipe model<br/>domain model<br/>[models.py]")]
  node_recipe_query["Recipe query logic<br/>search and pagination<br/>[utils.py]"]
  node_accounts_routes["Account routes<br/>app routing<br/>[urls.py]"]
  node_accounts["Profiles and identity<br/>accounts app<br/>[models.py]"]
  node_account_views["Account views and forms<br/>account workflow<br/>[views.py]"]
  node_comment_routes["Comment routes<br/>app routing<br/>[urls.py]"]
  node_comments[("Comments<br/>social domain<br/>[models.py]")]
  node_comment_views["Comment views<br/>comment workflow<br/>[views.py]"]
end

subgraph group_delivery["Presentation and API"]
  node_html_ui["Server-rendered UI<br/>Django templates<br/>[base.html]"]
  node_recipe_page["Recipe listing page<br/>feature template<br/>[recipes.html]"]
  node_interaction_ui["Like/favorite partial<br/>HTMX fragment<br/>[like_button.html]"]
  node_recipe_js["Favorite AJAX client<br/>browser script<br/>[favorites-ajax.js]"]
  node_api_boundary["Recipe REST API<br/>serializers and permissions<br/>[serializers.py]"]
end

subgraph group_infra["Persistence and deployment"]
  node_database[("SQLite / PostgreSQL<br/>relational database")]
  node_container{{"Compose deployment<br/>Docker deployment<br/>[docker-compose.yml]"}}
end

node_manage -->|"loads"| node_settings
node_wsgi -->|"loads"| node_settings
node_asgi -->|"loads"| node_settings
node_settings -->|"configures"| node_root_urls
node_settings -->|"connects to"| node_database
node_container -->|"runs"| node_wsgi
node_container -->|"runs"| node_database
node_root_urls -->|"includes"| node_recipe_urls
node_root_urls -->|"includes"| node_accounts_routes
node_root_urls -->|"includes"| node_comment_routes
node_recipe_urls -->|"dispatches to"| node_recipe_core
node_accounts_routes -->|"dispatches to"| node_account_views
node_comment_routes -->|"dispatches to"| node_comment_views
node_recipe_core -->|"reads and writes"| node_recipe_model
node_recipe_core -->|"uses"| node_recipe_query
node_recipe_core -->|"uses ownership"| node_accounts
node_recipe_core -->|"shows comments"| node_comments
node_account_views -->|"manages"| node_accounts
node_comment_views -->|"creates and displays"| node_comments
node_comments -->|"belongs to"| node_recipe_model
node_comments -->|"authored by"| node_accounts
node_recipe_model -->|"persists in"| node_database
node_accounts -->|"persists in"| node_database
node_comments -->|"persists in"| node_database
node_recipe_core -->|"renders"| node_html_ui
node_recipe_core -->|"renders"| node_recipe_page
node_recipe_core -->|"updates"| node_interaction_ui
node_recipe_js -->|"requests updates for"| node_interaction_ui
node_recipe_core -->|"exposes API through"| node_api_boundary
node_api_boundary -->|"serializes"| node_recipe_model

click node_manage "https://github.com/maxkunev/foodie-app/blob/develop/manage.py"
click node_wsgi "https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/wsgi.py"
click node_asgi "https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/asgi.py"
click node_settings "https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/settings.py"
click node_root_urls "https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/urls.py"
click node_recipe_urls "https://github.com/maxkunev/foodie-app/blob/develop/recipes/urls.py"
click node_recipe_core "https://github.com/maxkunev/foodie-app/blob/develop/recipes/views.py"
click node_recipe_model "https://github.com/maxkunev/foodie-app/blob/develop/recipes/models.py"
click node_recipe_query "https://github.com/maxkunev/foodie-app/blob/develop/recipes/utils.py"
click node_accounts_routes "https://github.com/maxkunev/foodie-app/blob/develop/accounts/urls.py"
click node_accounts "https://github.com/maxkunev/foodie-app/blob/develop/accounts/models.py"
click node_account_views "https://github.com/maxkunev/foodie-app/blob/develop/accounts/views.py"
click node_comment_routes "https://github.com/maxkunev/foodie-app/blob/develop/comments/urls.py"
click node_comments "https://github.com/maxkunev/foodie-app/blob/develop/comments/models.py"
click node_comment_views "https://github.com/maxkunev/foodie-app/blob/develop/comments/views.py"
click node_html_ui "https://github.com/maxkunev/foodie-app/blob/develop/templates/base.html"
click node_recipe_page "https://github.com/maxkunev/foodie-app/blob/develop/recipes/templates/recipes/recipes.html"
click node_interaction_ui "https://github.com/maxkunev/foodie-app/blob/develop/recipes/templates/recipes/includes/like_button.html"
click node_recipe_js "https://github.com/maxkunev/foodie-app/blob/develop/static/js/recipe/favorites-ajax.js"
click node_api_boundary "https://github.com/maxkunev/foodie-app/blob/develop/recipes/serializers.py"
click node_container "https://github.com/maxkunev/foodie-app/blob/develop/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manage,node_wsgi,node_asgi,node_settings,node_root_urls toneBlue
class node_recipe_urls,node_recipe_core,node_recipe_model,node_recipe_query,node_accounts_routes,node_accounts,node_account_views,node_comment_routes,node_comments,node_comment_views toneAmber
class node_html_ui,node_recipe_page,node_interaction_ui,node_recipe_js,node_api_boundary toneMint
class node_database,node_container toneRose
```

## Components

### Django project

- [Django commands](https://github.com/maxkunev/foodie-app/blob/develop/manage.py): entry point · `manage.py`
- [Gunicorn WSGI](https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/wsgi.py): deployment entry · `djangocoursera/wsgi.py`
- [ASGI entry](https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/asgi.py): deployment entry · `djangocoursera/asgi.py`
- [Settings](https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/settings.py): project config · Configures apps, databases, media, static assets, cache, and API documentation. · `djangocoursera/settings.py`
- [Project router](https://github.com/maxkunev/foodie-app/blob/develop/djangocoursera/urls.py): URL routing · `djangocoursera/urls.py`

### Domain apps

- [Recipe routes](https://github.com/maxkunev/foodie-app/blob/develop/recipes/urls.py): app routing · `recipes/urls.py`
- [Recipe core](https://github.com/maxkunev/foodie-app/blob/develop/recipes/views.py): models and views · Owns recipe CRUD, discovery, ownership, likes, favorites, and API views. · `recipes/views.py`
- [Recipe model](https://github.com/maxkunev/foodie-app/blob/develop/recipes/models.py): domain model · `recipes/models.py`
- [Recipe query logic](https://github.com/maxkunev/foodie-app/blob/develop/recipes/utils.py): search and pagination · `recipes/utils.py`
- [Account routes](https://github.com/maxkunev/foodie-app/blob/develop/accounts/urls.py): app routing · `accounts/urls.py`
- [Profiles and identity](https://github.com/maxkunev/foodie-app/blob/develop/accounts/models.py): accounts app · Extends Django users with profiles, images, and preferences. · `accounts/models.py`
- [Account views and forms](https://github.com/maxkunev/foodie-app/blob/develop/accounts/views.py): account workflow · `accounts/views.py`
- [Comment routes](https://github.com/maxkunev/foodie-app/blob/develop/comments/urls.py): app routing · `comments/urls.py`
- [Comments](https://github.com/maxkunev/foodie-app/blob/develop/comments/models.py): social domain · Persists recipe comments by authenticated users. · `comments/models.py`
- [Comment views](https://github.com/maxkunev/foodie-app/blob/develop/comments/views.py): comment workflow · `comments/views.py`

### Presentation and API

- [Server-rendered UI](https://github.com/maxkunev/foodie-app/blob/develop/templates/base.html): Django templates · Shared layout and feature templates render application pages. · `templates/base.html`
- [Recipe listing page](https://github.com/maxkunev/foodie-app/blob/develop/recipes/templates/recipes/recipes.html): feature template · `recipes/templates/recipes/recipes.html`
- [Like/favorite partial](https://github.com/maxkunev/foodie-app/blob/develop/recipes/templates/recipes/includes/like_button.html): HTMX fragment · Partial UI updates are driven by recipe client JavaScript. · `recipes/templates/recipes/includes/like_button.html`
- [Favorite AJAX client](https://github.com/maxkunev/foodie-app/blob/develop/static/js/recipe/favorites-ajax.js): browser script · `static/js/recipe/favorites-ajax.js`
- [Recipe REST API](https://github.com/maxkunev/foodie-app/blob/develop/recipes/serializers.py): serializers and permissions · Serializes recipes and enforces mutation and ownership rules. · `recipes/serializers.py`

### Persistence and deployment

- **SQLite / PostgreSQL**: relational database · SQLite is the local default; Compose production uses PostgreSQL.
- [Compose deployment](https://github.com/maxkunev/foodie-app/blob/develop/docker-compose.yml): Docker deployment · Runs the Gunicorn web service with PostgreSQL. · `docker-compose.yml`

## Connections

- Django commands → Settings: loads
- Gunicorn WSGI → Settings: loads
- ASGI entry → Settings: loads
- Settings → Project router: configures
- Settings → SQLite / PostgreSQL: connects to
- Compose deployment → Gunicorn WSGI: runs
- Compose deployment → SQLite / PostgreSQL: runs
- Project router → Recipe routes: includes
- Project router → Account routes: includes
- Project router → Comment routes: includes
- Recipe routes → Recipe core: dispatches to
- Account routes → Account views and forms: dispatches to
- Comment routes → Comment views: dispatches to
- Recipe core → Recipe model: reads and writes
- Recipe core → Recipe query logic: uses
- Recipe core → Profiles and identity: uses ownership
- Recipe core → Comments: shows comments
- Account views and forms → Profiles and identity: manages
- Comment views → Comments: creates and displays
- Comments → Recipe model: belongs to
- Comments → Profiles and identity: authored by
- Recipe model → SQLite / PostgreSQL: persists in
- Profiles and identity → SQLite / PostgreSQL: persists in
- Comments → SQLite / PostgreSQL: persists in
- Recipe core → Server-rendered UI: renders
- Recipe core → Recipe listing page: renders
- Recipe core → Like/favorite partial: updates
- Favorite AJAX client → Like/favorite partial: requests updates for
- Recipe core → Recipe REST API: exposes API through
- Recipe REST API → Recipe model: serializes
