# shulimanhossain/online-book-shop architecture

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

- Interactive diagram: https://gitdiagram.com/shulimanhossain/online-book-shop
- Repository: https://github.com/shulimanhossain/online-book-shop

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["Web Browser"]:::blue
    Browser -->|"HTTP(S)"| WSGI["WSGI Server (Gunicorn/uwsgi)"]:::green
    WSGI -->|"WSGI"| FlaskApp["Flask App (app.py)"]:::green
    FlaskApp --> Config["Config (config.py)"]:::green
    FlaskApp -->|"SQL Queries"| DB["MySQL DB (book.sql schema)"]:::orange
    FlaskApp --> StaticAssets["Static Assets"]:::blue
    FlaskApp --> TemplatesGroup["Jinja2 Templates"]:::blue
    DB -->|"Query Results"| FlaskApp
    FlaskApp -->|"SMTP"| EmailService["Email Service"]:::gray

    subgraph "Static Assets"
        StaticAssets
    end

    subgraph "Jinja2 Templates"
        base["base.html"]:::blue
        home["home.html"]:::blue
        first["first.html"]:::blue
        login["login.html"]:::blue
        register["register.html"]:::blue
        loginopt["loginoption.html"]:::blue
        member["member.html"]:::blue
        allbook["all_book.html"]:::blue
        detail["book_detail.html"]:::blue
        search["search_result.html"]:::blue
        cart["cart.html"]:::blue
        orderdet["order_details.html"]:::blue
        reviews["book_reviews.html"]:::blue
        review["review.html"]:::blue
        adminDash["admin_dashboard.html"]:::blue
        addbook["add_book.html"]:::blue
        changeprice["change_price.html"]:::blue
        updatestock["update_stock.html"]:::blue
        deletebook["delete_book.html"]:::blue
        userdet["user_details.html"]:::blue
        revenue["revenue.html"]:::blue
        changeadmin["change_admin_pass.html"]:::blue
    end

    TemplatesGroup --> base
    TemplatesGroup --> home
    TemplatesGroup --> first
    TemplatesGroup --> login
    TemplatesGroup --> register
    TemplatesGroup --> loginopt
    TemplatesGroup --> member
    TemplatesGroup --> allbook
    TemplatesGroup --> detail
    TemplatesGroup --> search
    TemplatesGroup --> cart
    TemplatesGroup --> orderdet
    TemplatesGroup --> reviews
    TemplatesGroup --> review
    TemplatesGroup --> adminDash
    TemplatesGroup --> addbook
    TemplatesGroup --> changeprice
    TemplatesGroup --> updatestock
    TemplatesGroup --> deletebook
    TemplatesGroup --> userdet
    TemplatesGroup --> revenue
    TemplatesGroup --> changeadmin

    classDef blue fill:#cce5ff,stroke:#004085;
    classDef green fill:#d4edda,stroke:#155724;
    classDef orange fill:#fff3cd,stroke:#856404;
    classDef gray fill:#e2e3e5,stroke:#6c757d;

    click FlaskApp "https://github.com/shulimanhossain/online-book-shop/blob/main/app.py"
    click Config "https://github.com/shulimanhossain/online-book-shop/blob/main/config.py"
    click DB "https://github.com/shulimanhossain/online-book-shop/blob/main/book.sql"
    click StaticAssets "https://github.com/shulimanhossain/online-book-shop/tree/main/static/"
    click base "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/base.html"
    click home "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/home.html"
    click first "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/first.html"
    click login "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/login.html"
    click register "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/register.html"
    click loginopt "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/loginoption.html"
    click member "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/member.html"
    click allbook "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/all_book.html"
    click detail "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/book_detail.html"
    click search "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/search_result.html"
    click cart "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/cart.html"
    click orderdet "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/order_details.html"
    click reviews "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/book_reviews.html"
    click review "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/review.html"
    click adminDash "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/admin_dashboard.html"
    click addbook "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/add_book.html"
    click changeprice "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/change_price.html"
    click updatestock "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/update_stock.html"
    click deletebook "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/delete_book.html"
    click userdet "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/user_details.html"
    click revenue "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/revenue.html"
    click changeadmin "https://github.com/shulimanhossain/online-book-shop/blob/main/templates/change_admin_pass.html"
```
