# lethabo-t-molefe/foodiepedia architecture

> Architecture diagram of the GitHub repository lethabo-t-molefe/foodiepedia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lethabo-t-molefe/foodiepedia
- Repository: https://github.com/lethabo-t-molefe/foodiepedia

## Overview

##### Project type and purpose
- Foodie-Pedia is a full-stack web application built on the Django (Python) framework.
- Its primary purpose is to let users explore, manage, and share recipes, leveraging the OpenAI API for AI-driven recipe generation.

##### File structure
- Top-level:
- foodie_pedia/ (Django project root containing settings, URLs, WSGI/ASGI, manage.py)
- requirements.txt, README.md, db.sqlite3
- Inside foodie_pedia/foodie_app/ (the main Django “app”):
- models.py, views.py, forms.py, admin.py, tests.py, urls.py
- migrations/ (database schema history)
- templates/foodie_app/ (HTML templates for home, recipe details, random/suggested recipes, edit form, saved recipes)
- Static assets:
- static/css/, static/js/, static/img/
- Global templates & account management:
- templates/base.html, message.html, welcomepage.html
- templates/account/ (login, signup, profile)

##### README
- Confirms core functionality: recipe exploration, management, shar­ing
- Highlights OpenAI API integration for generating recipes

- Web Client (Browser) – UI built with HTML/CSS/JavaScript
- Django Web Server (MVT):
– Models (SQLite)
– Views (business logic, forms, OpenAI integration)
– Templates (HTML rendering)
- Database (SQLite)
- External Service (OpenAI API)
- Authentication subsystem (Django auth in account templates)
b. Relationships & data flows:
1. Browser → HTTP(S) requests → Django URL router → View
2. View ↔ Database (CRUD via Django ORM)
3. View → OpenAI API calls → AI-generated responses
4. View → Template rendering → HTML/CSS/JS → Browser
5. Browser executes client JS (saverecipe.js) to trigger AJAX for saving recipes
c. Architectural patterns & design principles:
- Django’s Model-View-Template (MVT) pattern
- Monolithic deployment (single codebase serving frontend & backend)
- Separation of concerns: static assets vs. dynamic views vs. data layer
- Extensibility point: OpenAI API integration encapsulated in view logic
d. Key technologies & frameworks:
- Python 3.x, Django
- SQLite (db.sqlite3)
- HTML5, CSS3, Vanilla JS
- OpenAI REST API
- Django auth for user management
- WSGI/ASGI (deployment interface)

##### Final recommendations
- Essential elements: URL router, view functions, ORM interactions, template rendering, static file serving, OpenAI API calls
- Review with stakeholders to ensure all components and interactions are represented accurately

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client-side
    subgraph "Client-side" 
        direction TB
        Browser["Browser"]:::client
        CSS["CSS Files"]:::client
        JS["saverecipe.js"]:::client
        IMG["Image Assets"]:::client
    end

    %% Server-side (Django)
    subgraph "Django Server" 
        direction TB
        Router["URL Router"]:::server
        Views["Django Views\n(business logic & OpenAI integration)"]:::server
        Models["Django Models\n(SQLite ORM)"]:::server
        Forms["Django Forms"]:::server
        Templates["HTML Templates"]:::server
        Auth["Auth Subsystem"]:::server
        StaticServe["Static File Serving"]:::server
        Deployment["WSGI/ASGI Interfaces"]:::server
        Migrations["Migrations"]:::server
    end

    %% Persistence
    subgraph "Persistence" 
        direction TB
        SQLiteDB["SQLite DB"]:::db
    end

    %% External Service
    subgraph "External Service"
        direction TB
        OpenAI["OpenAI API"]:::external
    end

    %% Connections
    Browser -->|HTTP GET/POST| Router
    Router -->|dispatch to| Views
    Views -->|CRUD via ORM| Models
    Views -->|validate user input| Forms
    Views -->|render with| Templates
    Views -->|serve static| StaticServe
    StaticServe --> CSS
    StaticServe --> JS
    StaticServe --> IMG
    Views -->|call API| OpenAI
    Views -->|read/write| SQLiteDB
    Router -->|handles auth URLs| Auth
    Deployment --> Router
    Migrations --> Models

    %% Click Events
    click CSS "https://github.com/lethabo-t-molefe/foodiepedia/tree/main/FoodiePedia/foodie_pedia/static/css/"
    click JS "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/static/js/saverecipe.js"
    click IMG "https://github.com/lethabo-t-molefe/foodiepedia/tree/main/FoodiePedia/foodie_pedia/static/img/"
    click Models "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_app/models.py"
    click Views "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_app/views.py"
    click Forms "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_app/forms.py"
    click Router "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_app/urls.py"
    click Router "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_pedia/urls.py"
    click Templates "https://github.com/lethabo-t-molefe/foodiepedia/tree/main/FoodiePedia/foodie_pedia/foodie_app/templates/foodie_app/"
    click Templates "https://github.com/lethabo-t-molefe/foodiepedia/tree/main/FoodiePedia/foodie_pedia/templates/"
    click Auth "https://github.com/lethabo-t-molefe/foodiepedia/tree/main/FoodiePedia/foodie_pedia/templates/account/"
    click Migrations "https://github.com/lethabo-t-molefe/foodiepedia/tree/main/FoodiePedia/foodie_pedia/foodie_app/migrations/"
    click SQLiteDB "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/db.sqlite3"
    click Deployment "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_pedia/asgi.py"
    click Deployment "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/foodie_pedia/wsgi.py"
    click StaticServe "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/foodie_pedia/manage.py"
    click StaticServe "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/requirements.txt"
    click StaticServe "https://github.com/lethabo-t-molefe/foodiepedia/blob/main/FoodiePedia/README.md"

    %% Styles
    classDef client fill:#CEF6FF,stroke:#0000FF;
    classDef server fill:#D5F5E3,stroke:#1D8348;
    classDef db fill:#FDEDEC,stroke:#E74C3C;
    classDef external fill:#E8DAEF,stroke:#8E44AD;
```
