# salahmalih/easyrecipe-mvp architecture

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

- Interactive diagram: https://gitdiagram.com/salahmalih/easyrecipe-mvp
- Repository: https://github.com/salahmalih/easyrecipe-mvp

## Overview

##### Project Type and Purpose
- From the README and file tree, EasyRecipe is a full-stack web application.
- Frontend: React (Create-React-App) + Material-UI
- Backend: Flask (app.py, SQLAlchemy models & schemas)
- Database: MySQL (plus a Redis dump.rdb suggests optional caching or session store)
- Purpose: let users browse, create, update, delete, search recipes; manage profiles and favorites.

##### File Structure
- Top-level separation:
- backend/ – Flask application and ORM (models/, schemas/, static/images/)
- public/ – React’s public assets (index.html, manifest.json, robots.txt)
- src/ – React application source (components/, pages/, scenes/, theme.js, index.js)
- Backend follows an MVC/API-driven pattern:
- models/ define DB tables (users, recipe, ingredients, etc.)
- schemas/ define request/response DTOs
- app.py and database.py wire together Flask, SQLAlchemy, and route definitions
- Frontend organizes by feature:
- components/ (reusable UI pieces: header, footer, navbar, pagination, etc.)
- page/ (route-level pages: Home, Login, Recipes, Dashboard, Admin, Favourite, NoPage, etc.)
- scenes/global for layout (Sidebar, Topbar) + theme.js for styling

##### Key Insights from the README
- The system uses a REST API (Flask) at port 5000.
- React client runs on port 3000 and calls the API to fetch/store data.
- MySQL is the persistent store; Redis (dump.rdb) likely handles caching or session data.
- Static media (images for recipes) are kept under backend/static/images.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        ReactApp["React App\n(Create-React-App)"]:::frontend
        ReactComponents["UI Components\n(src/components/)"]:::frontend
        ReactPages["Pages\n(src/page/)"]:::frontend
        ReactScenes["Scenes\n(src/scenes/)"]:::frontend
        ThemeConfig["Theme Config\n(src/theme.js)"]:::frontend
        PublicAssets["Public Assets\n(public/)"]:::frontend
    end

    %% Server Side
    subgraph "Server Side"
        FlaskAPI["Flask API Server\n(Flask + SQLAlchemy)"]:::backend
        DBConfig["Database Config\n(backend/database.py)"]:::backend
        SQLAlchemyModels["SQLAlchemy Models\n(backend/models/)"]:::backend
        MarshmallowSchemas["Schemas\n(backend/schemas/)"]:::backend
        StaticStore["Static File Store\n(backend/static/images/)"]:::backend
        RedisStore["Redis Cache/Session\n(backend/dump.rdb)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        MySQL["MySQL Database"]:::datastore
        Redis["Redis Cache"]:::datastore
    end

    %% Infrastructure
    NGINX["NGINX / Load Balancer"]:::infra

    %% Connections - Client Side
    ReactApp -->|uses| ReactComponents
    ReactApp -->|routes| ReactPages
    ReactApp -->|layout| ReactScenes
    ReactApp -->|theme| ThemeConfig
    ReactApp -->|assets| PublicAssets

    ReactApp -->|GET/POST REST API| FlaskAPI

    %% Connections - Server Side
    FlaskAPI -->|configures| DBConfig
    FlaskAPI -->|imports| SQLAlchemyModels
    FlaskAPI -->|serializes| MarshmallowSchemas
    FlaskAPI -->|serves| StaticStore
    FlaskAPI -->|reads/writes| RedisStore

    FlaskAPI -->|SQL SELECT/INSERT| MySQL
    FlaskAPI -->|CACHE GET/SET| Redis

    %% Infrastructure connections
    NGINX -->|routes traffic| ReactApp
    NGINX -->|routes API calls| FlaskAPI

    %% Click Events
    click ReactApp "https://github.com/salahmalih/easyrecipe-mvp/blob/main/package.json"
    click ReactApp "https://github.com/salahmalih/easyrecipe-mvp/blob/main/package-lock.json"
    click PublicAssets "https://github.com/salahmalih/easyrecipe-mvp/blob/main/public/index.html"
    click PublicAssets "https://github.com/salahmalih/easyrecipe-mvp/blob/main/public/manifest.json"
    click PublicAssets "https://github.com/salahmalih/easyrecipe-mvp/blob/main/public/robots.txt"
    click ReactComponents "https://github.com/salahmalih/easyrecipe-mvp/tree/main/src/components/"
    click ReactPages "https://github.com/salahmalih/easyrecipe-mvp/tree/main/src/page/"
    click ReactScenes "https://github.com/salahmalih/easyrecipe-mvp/blob/main/src/scenes/index.js"
    click ReactScenes "https://github.com/salahmalih/easyrecipe-mvp/blob/main/src/scenes/global/Sidebar.jsx"
    click ReactScenes "https://github.com/salahmalih/easyrecipe-mvp/blob/main/src/scenes/global/Topbar.jsx"
    click ThemeConfig "https://github.com/salahmalih/easyrecipe-mvp/blob/main/src/theme.js"
    click FlaskAPI "https://github.com/salahmalih/easyrecipe-mvp/blob/main/backend/app.py"
    click DBConfig "https://github.com/salahmalih/easyrecipe-mvp/blob/main/backend/database.py"
    click SQLAlchemyModels "https://github.com/salahmalih/easyrecipe-mvp/tree/main/backend/models/"
    click MarshmallowSchemas "https://github.com/salahmalih/easyrecipe-mvp/tree/main/backend/schemas/"
    click StaticStore "https://github.com/salahmalih/easyrecipe-mvp/tree/main/backend/static/images/"
    click RedisStore "https://github.com/salahmalih/easyrecipe-mvp/blob/main/backend/dump.rdb"

    %% Styles
    classDef frontend fill:#B3D4FC,stroke:#0366d6,color:#000
    classDef backend fill:#CFF6CF,stroke:#2e7d32,color:#000
    classDef datastore fill:#FFE0B2,stroke:#ef6c00,color:#000
    classDef infra fill:#E0E0E0,stroke:#616161,color:#000
```
