# razgrom47/dierezeptedb architecture

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

- Interactive diagram: https://gitdiagram.com/razgrom47/dierezeptedb
- Repository: https://github.com/razgrom47/dierezeptedb

## Overview

##### Project type and purpose
- This is a full-stack web application named “dieRezepteDB,” whose goal is to provide recipes for healthy nutrition.
- The backend is a Flask-based REST API serving recipe, ingredient, profile, and auth data; the frontend is a React (Vite) single-page app offering search, filter, and user-profile views.

##### File structure
- Top-level directories:
- backend/ – Flask API entry point (app.py), configuration (config.py), ORM models (models.py), migrations/, extensions.py, decorators, plus a blueprints/ folder containing modular routes (auth.py, ingredients.py, meals.py, profile.py).
- frontend/ – React/Vite client (main.jsx, App.jsx), components/, assets/, public/ (static images), plus config files (vite.config.js, eslint.config.js, package.json).
- backend/themealdb/myDB.db: local SQLite database file
- backend/backup/: legacy scripts (creatingDB.py, myMealAPI.py, scape.py) for data scraping and initial API prototype.
- Configuration & build files: requirements.txt, package.json, migrations commands.txt.

##### README for additional insights
- Python backend runs via `python backend/app.py`, with optional venv.
- Migrations support via Flask-Migrate (commands.txt).
- React/Vite dev server via `npm run dev`, using Material-UI and React Router.
- Legacy backup script for reinitializing the DB if needed.

a. Main components
- User’s browser/client
- Frontend SPA (React + Vite)
- Backend REST API (Flask application with blueprints)
- Database (SQLite)
- External/legacy scripts (data scraper & backup tool)
b. Relationships & interactions
1. The user interacts with the SPA in the browser.
2. The SPA issues HTTP requests (GET, POST, PUT, DELETE) to the Flask API endpoints (e.g., /api/meals, /api/ingredients, /api/auth).
3. The Flask app loads configuration, initializes extensions (SQLAlchemy, Migrate, JWT), and registers blueprints.
4. Each blueprint handles a domain (auth, profile, meals, ingredients), invokes models and DB sessions.
5. The API reads/writes to the local SQLite DB.
6. Migrations update the DB schema; backup scripts can regenerate or populate data offline.
c. Architectural patterns & design principles
- Blueprint-based modularization in Flask for separation of concerns.
- MVC-like layering: models.py (data layer), blueprints (controller layer), Flask-provided JSON (view).
- Single-page application pattern on the frontend with component hierarchy and React Router for client-side routing.
- Use of environment isolation (venv, npm modules).
d. Key technologies
- Backend: Python + Flask, Flask-SQLAlchemy, Flask-Migrate, JWT or session auth, SQLite.
- Frontend: React, Vite, MUI (Material UI), React Router.
- Build & run: requirements.txt, package.json, ESLint, Vite dev server.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph "Client Layer"
        UserBrowser["User / Browser"]:::frontend
        ReactSPA["React SPA\n(Vite, MUI, Router)"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer"
        FlaskAPI["Flask REST API"]:::backend
        ConfigModule["Configuration Module"]:::backend
        Extensions["Extensions Init\n(SQLAlchemy, Migrate, JWT)"]:::backend
        Models["ORM Models"]:::backend
        Decorators["Request Decorators"]:::backend
        subgraph "Blueprints"
            AuthBP["Auth Blueprint"]:::backend
            IngredientsBP["Ingredients Blueprint"]:::backend
            MealsBP["Meals Blueprint"]:::backend
            ProfileBP["Profile Blueprint"]:::backend
        end
    end

    %% Data Store
    SQLiteDB["SQLite Database"]:::database

    %% Offline Tools
    subgraph "Offline / Maintenance Tools"
        MigrationTool["Database Migrations"]:::tools
        MigrationsCommands["Migrations Commands"]:::tools
        CreatingDB["creatingDB.py"]:::tools
        MyMealAPI["myMealAPI.py"]:::tools
        Scape["scape.py"]:::tools
    end

    %% Connections
    UserBrowser -->|"interacts with"| ReactSPA
    ReactSPA -->|"HTTP requests"| FlaskAPI
    FlaskAPI -->|"uses config"| ConfigModule
    FlaskAPI -->|"initializes"| Extensions
    FlaskAPI -->|"loads models"| Models
    FlaskAPI -->|"applies"| Decorators
    FlaskAPI -->|"registers"| AuthBP
    FlaskAPI -->|"registers"| IngredientsBP
    FlaskAPI -->|"registers"| MealsBP
    FlaskAPI -->|"registers"| ProfileBP
    FlaskAPI -->|"SQL queries"| SQLiteDB
    MigrationTool -->|"schema migrations"| SQLiteDB
    MigrationsCommands -->|"migration scripts"| SQLiteDB
    CreatingDB -->|"data load"| SQLiteDB
    MyMealAPI -->|"data load"| SQLiteDB
    Scape -->|"data load"| SQLiteDB

    %% Click Events
    click ReactSPA "https://github.com/razgrom47/dierezeptedb/blob/main/frontend/src/main.jsx"
    click ReactSPA "https://github.com/razgrom47/dierezeptedb/blob/main/frontend/src/App.jsx"
    click ReactSPA "https://github.com/razgrom47/dierezeptedb/tree/main/frontend/src/components/"
    click ReactSPA "https://github.com/razgrom47/dierezeptedb/blob/main/frontend/vite.config.js"
    click ReactSPA "https://github.com/razgrom47/dierezeptedb/blob/main/frontend/package.json"
    click FlaskAPI "https://github.com/razgrom47/dierezeptedb/blob/main/backend/app.py"
    click ConfigModule "https://github.com/razgrom47/dierezeptedb/blob/main/backend/config.py"
    click Extensions "https://github.com/razgrom47/dierezeptedb/blob/main/backend/extensions.py"
    click Models "https://github.com/razgrom47/dierezeptedb/blob/main/backend/models.py"
    click Decorators "https://github.com/razgrom47/dierezeptedb/blob/main/backend/decorators.py"
    click AuthBP "https://github.com/razgrom47/dierezeptedb/blob/main/backend/blueprints/auth.py"
    click IngredientsBP "https://github.com/razgrom47/dierezeptedb/blob/main/backend/blueprints/ingredients.py"
    click MealsBP "https://github.com/razgrom47/dierezeptedb/blob/main/backend/blueprints/meals.py"
    click ProfileBP "https://github.com/razgrom47/dierezeptedb/blob/main/backend/blueprints/profile.py"
    click MigrationTool "https://github.com/razgrom47/dierezeptedb/tree/main/backend/migrations/"
    click MigrationsCommands "https://github.com/razgrom47/dierezeptedb/blob/main/backend/migrations/commands.txt"
    click SQLiteDB "https://github.com/razgrom47/dierezeptedb/blob/main/backend/themealdb/myDB.db"
    click CreatingDB "https://github.com/razgrom47/dierezeptedb/blob/main/backend/backup/creatingDB.py"
    click MyMealAPI "https://github.com/razgrom47/dierezeptedb/blob/main/backend/backup/myMealAPI.py"
    click Scape "https://github.com/razgrom47/dierezeptedb/blob/main/backend/backup/scape.py"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#000;
    classDef backend fill:#C8E6C9,stroke:#000;
    classDef database fill:#FFE0B2,stroke:#000;
    classDef tools fill:#E0E0E0,stroke:#000;
```
