How shulimanhossain/online-book-shop works
Project Type and Purpose
• This is a full-stack web application (“Online Book Shop Management System”)
• Built with Flask (Python) for the backend, MySQL for persistence, and HTML/CSS (Jinja2 templates) for the frontend.
• Two user roles: Admin and Member (customer), each with distinct features.
File Structure
• app.py – Flask application entry point (controller / route definitions)
• config.py – Configuration & database connection setup
• book.sql – MySQL schema for tables (books, authors, users, orders, reviews, etc.)
• templates/ – Jinja2 templates (views) for all pages (home, login, book detail, admin dashboard, etc.)
• static/ – Static assets (CSS, images)
• No separate “frontend” folder: templates and static are the entire client UI delivered by Flask.
README for Architecture Clues
• Describes two distinct feature sets (Admin vs. Member).
• Mentions session-based, role-based login.
• Emphasizes database operations (CRUD on books, users, orders, reviews).
Main Components
a. Client (Web Browser)
b. Web Server Layer
– Flask Application (app.py + config.py)
– WSGI Server (e.g., Gunicorn/uwsgi) if deployed
c. Presentation Layer
– Jinja2 HTML templates
– Static assets (CSS, images)
d. Application Layer
– Route handlers: /login, /register, /browse, /cart, /admin/*
– Business logic: authentication, authorization, cart management, order processing, review handling
e. Data Layer
– MySQL Database (tables defined in book.sql)
– Connection pool / ORM or raw SQL access via config.py
f. External Services (optional)
– Email service for notifications (if used)
– CDN for static files (if in production)
Relationships & Data Flows
• Browser ↔ HTTP(s) ↔ WSGI ↔ Flask Routes
• Flask handlers → SQL queries → MySQL
• DB → query results → Flask → Jinja2 templates → HTML → Browser
• User sessions stored in server memory or Redis (if configured)
• Admin vs. Member flows branch at authentication layer (role check)
Architectural Patterns / Design Principles
• MVC-style separation:
– Model: MySQL tables + Python data-access code
– View: Jinja2 templates under templates/
– Controller: Flask route functions in app.py
• Layered architecture: Presentation → Application → Data
• Single-process monolith (but can be containerized or scaled horizontally)
• Secure sessions & role-based access control
• Components: Browser, Static CDN (or Flask static folder), Flask App, MySQL DB
• Sub-modules: Templates directory, Config module (DB connection), Route groups (Auth, Catalog, Cart, Admin)
• Data Models: list of primary tables
• External integrations (email, analytics, etc.) if any