# greenxdshadow/onlinefoodstore architecture

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

- Interactive diagram: https://gitdiagram.com/greenxdshadow/onlinefoodstore
- Repository: https://github.com/greenxdshadow/onlinefoodstore

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application (“OnlineFoodStore”) built with Python/Flask on the server side and HTML/CSS/JS on the client side.
- Its purpose is to serve an online food ordering storefront: customers browse products, add to cart, checkout, and administrators can upload products.

##### File structure
- Top-level “back-end/OnlineFoodStore” directory contains:
- app.py – Flask application entrypoint (controllers/routes)
- Product.py, User.py – model definitions (ORM or simple data classes)
- database.db – SQLite database file
- populate_db.py – one-off script to seed the database
- requirements.txt – Python dependencies
- templates/ – Jinja2 HTML templates for each page (index, cart, checkout, admin, etc.)
- No separate “frontend” build step; Flask serves both API endpoints and rendered HTML.

##### README for additional insights
- Confirms a simple Python/Flask + SQLite stack
- No external microservices; everything lives in one repo
- Usage: activate virtualenv, install requirements, run `flask run` to launch

##### Main components
a. Client (Web Browser)
- Renders HTML/CSS/JS
- Issues HTTP(S) requests for pages and AJAX calls (ajaxScript.js)
b. Flask Web Server (app.py)
- Controllers / route handlers
- Reference to Product.py and User.py for business logic
- Serves static assets and templates
c. Database (SQLite – database.db)
- Persistent storage of users, products, orders
- Seeded via populate_db.py
d. Static Asset Hosting
e. Templates (Jinja2)
- HTML layout and page wiring
f. Developer Tools (populate_db.py, requirements.txt, venv)

##### Relationships & data flows
- Browser → HTTP GET/POST → Flask Server
- Flask Server ↔ SQL over SQLite driver → database.db
- Flask Server → Renders Jinja2 template + injects data → Browser
- Browser → AJAX (ajaxScript.js) → Flask API endpoints → JSON response → Browser updates DOM
- populate_db.py → Writes directly to SQLite DB (one-time script)

##### Architectural patterns & design principles
- MVC (“Models” in Product.py & User.py; “Views” in templates; “Controllers” in app.py)
- Layered structure: client layer, application layer, data layer
- Separation of concerns between static assets, dynamic routes, and data persistence

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Web Browser"]:::client
        subgraph "Static Assets (served)"
            direction TB
            CSS["CSS Stylesheets"]:::client
            Script["Main JS (script.js)"]:::client
            AJAX["AJAX Script (ajaxScript.js)"]:::client
            Images["Images"]:::client
            Icons["Icons"]:::client
            Fonts["Font Assets"]:::client
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Flask["Flask App (app.py)"]:::app
        subgraph "Models"
            Product["Product Model"]:::app
            User["User Model"]:::app
        end
        Templates["Jinja2 Templates"]:::app
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB[(SQLite Database)]:::db
    end

    %% Developer Tools
    subgraph "Developer Tools"
        direction TB
        Seed["Database Seed Script"]:::tools
        Req["requirements.txt"]:::tools
        Gitignore[".gitignore"]:::tools
        Readme["README.md"]:::tools
    end

    %% Relationships
    Browser -->|HTTP GET/POST| Flask
    Browser -->|loads CSS| CSS
    Browser -->|loads JS| Script
    Browser -->|loads AJAX| AJAX
    Browser -->|loads images| Images
    Browser -->|loads icons| Icons
    Browser -->|loads fonts| Fonts

    Flask -->|"renders templates"| Templates
    Templates -->|HTML| Browser

    Flask -->|"serves static assets"| CSS
    Flask -->|"serves static assets"| Script
    Flask -->|"serves static assets"| AJAX
    Flask -->|"serves static assets"| Images
    Flask -->|"serves static assets"| Icons
    Flask -->|"serves static assets"| Fonts

    AJAX -->|AJAX calls| Flask
    Flask -->|JSON response| AJAX

    Flask -->|SQL queries| DB
    DB -->|query results| Flask

    Seed -->|populates| DB

    %% Click Events
    click CSS "https://github.com/greenxdshadow/onlinefoodstore/tree/main/back-end/OnlineFoodStore/static/css/"
    click Script "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/static/js/script.js"
    click AJAX "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/static/js/ajaxScript.js"
    click Images "https://github.com/greenxdshadow/onlinefoodstore/tree/main/back-end/OnlineFoodStore/static/Images"
    click Icons "https://github.com/greenxdshadow/onlinefoodstore/tree/main/back-end/OnlineFoodStore/static/Icons"
    click Fonts "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/static/font/OFL.txt"
    click Flask "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/app.py"
    click Product "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/Product.py"
    click User "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/User.py"
    click DB "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/database.db"
    click Seed "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/populate_db.py"
    click Req "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/requirements.txt"
    click Gitignore "https://github.com/greenxdshadow/onlinefoodstore/blob/main/back-end/OnlineFoodStore/.gitignore"
    click Readme "https://github.com/greenxdshadow/onlinefoodstore/blob/main/README.md"

    %% Styles
    classDef client fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef app fill:#D4EDDA,stroke:#333,stroke-width:1px
    classDef db fill:#FFF3CD,stroke:#333,stroke-width:1px
    classDef tools fill:#E2E3E5,stroke:#333,stroke-width:1px
```
