How greenxdshadow/onlinefoodstore works
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