# eshita-jain/book-recommendation-system architecture

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

- Interactive diagram: https://gitdiagram.com/eshita-jain/book-recommendation-system
- Repository: https://github.com/eshita-jain/book-recommendation-system

## Overview

##### Project type and purpose
- This is a full-stack, single‐service web application built in Flask to recommend books using content-based filtering and cosine similarity.
- The README confirms it’s a “Book-Recommendation-System” with front-end in HTML/CSS and back-end in Flask, using a local SQLite DB and an offline book dataset.

##### File structure
- Top level
- run.py – entry point that launches the Flask app
- requirements.txt – Python dependencies
- README.md – project overview
- BookDataset.zip – raw data archive to be unpacked
- Main/ (the Flask application package)
- __init__.py – app factory and configuration (initializes Flask, database, blueprints)
- main.py – likely contains app setup or CLI commands
- routes.py – HTTP endpoints and view functions
- models.py – SQLAlchemy models for user, book uploads, etc.
- form.py – WTForms classes for login, upload, register
- recomm.py – content-based filtering logic using cosine similarity and the book dataset
- site.db – local SQLite file storing user and book metadata
- static/ – CSS, profile pictures, and other assets
- templates/ – Jinja2 HTML templates for pages (home, login, register, recommendation results, CRUD)

##### README for additional insights
- Confirms algorithms: content-based filtering + cosine similarity
- Walkthrough of web pages (account, home, upload, delete, contact, recommendation)
- Deployment: extract BookDataset.zip, adjust paths in recomm.py, run run.py

##### Main components
a. Client Layer
– Web Browser
– HTTP GET/POST requests
b. Presentation Layer
– Flask web server (Werkzeug)
– routes.py
– Jinja2 template engine (renders templates/*.html)
– static file handler (serving CSS/JS/images from static/)
c. Application Logic Layer
– form.py (input validation)
– recomm.py (recommender engine: loads dataset, vectorizes text, computes cosine similarities)
– models.py (ORM definitions)
d. Data Layer
– site.db (SQLite database)
– BookDataset (CSV/JSON in extracted folder)
e. External / Offline Components
– Initial book dataset (unzipped)
– File uploads (persisted via models to site.db)

##### Relationships and interactions
- Browser → Flask (HTTP)
- Flask/routes → form.py to validate inputs
- routes → models.py to read/write site.db
- routes → recomm.py when user invokes “recommend” endpoint
- recomm.py → reads BookDataset files → preprocesses → computes top-N recommendations → returns results
- Flask/route → passes recommendation results to a Jinja2 template → browser renders the HTML

##### Architectural patterns and design principles
- MVC (Model: models.py + site.db; View: templates; Controller: routes.py)
- Modular separation: static vs. templates vs. business logic vs. data access
- Single-process, synchronous Flask service – no microservices, but clear layer boundaries
- Content-based filtering module separated into recomm.py for reusability and testability

##### Technologies, frameworks, and libraries
- Python, Flask, Flask-SQLite (SQLAlchemy or Flask-SQLAlchemy inferred)
- WTForms (form.py)
- Jinja2 (templating)
- scikit-learn or similar for vectorization & cosine similarity (in recomm.py)
- HTML, CSS (static/main.css)
- Werkzeug built-in dev server

##### Essential details to capture
- The entry point (run.py → app factory in Main/__init__.py)
- The workflow for recommending a book: HTTP request → route → recomm.py → result page
- CRUD operations: uploading/deleting books (forms → models → site.db)
- Static asset serving
- Any configuration (e.g., path adjustments in recomm.py) – note as a comment or annotation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Web Browser"]:::frontend
    Browser -->|"HTTP GET/POST"| Run

    %% Entry Point
    Run["run.py"]:::logic
    click Run "https://github.com/eshita-jain/book-recommendation-system/blob/main/run.py"
    Run -->|"initialize app"| Init

    %% Flask Application
    subgraph "Flask Application" 
        direction TB
        Init["__init__.py\n(App Factory & Config)"]:::logic
        click Init "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/__init__.py"
        MainCLI["main.py\n(CLI Commands)"]:::logic
        click MainCLI "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/main.py"
        Routes["routes.py\n(HTTP Controllers)"]:::logic
        click Routes "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/routes.py"
        Forms["form.py\n(Input Validation)"]:::logic
        click Forms "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/form.py"
        Recommender["recomm.py\n(Recommender Engine)"]:::logic
        click Recommender "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/recomm.py"
        Models["models.py\n(ORM Models)"]:::logic
        click Models "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/models.py"
        Templates["Templates\n(Jinja2 Views)"]:::frontend
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/account.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/contact.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/deletebook.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/home.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/layout.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/login.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/recommender.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/register.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/sample.html"
        click Templates "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/templates/uploadbook.html"
        Static["Static Assets\n(CSS, Images)"]:::frontend
        click Static "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/static/main.css"
        click Static "https://github.com/eshita-jain/book-recommendation-system/tree/main/Main/static/profile_pics/"
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB[(site.db)]:::data
        click DB "https://github.com/eshita-jain/book-recommendation-system/blob/main/Main/site.db"
        Dataset["BookDataset\n(Offline Data)"]:::external
        click Dataset "https://github.com/eshita-jain/book-recommendation-system/blob/main/BookDataset.zip"
    end

    %% Metadata
    subgraph "Project Metadata"
        README["README.md"]:::external
        click README "https://github.com/eshita-jain/book-recommendation-system/blob/main/README.md"
        Req["requirements.txt"]:::external
        click Req "https://github.com/eshita-jain/book-recommendation-system/blob/main/requirements.txt"
    end

    %% Interactions
    Init --> MainCLI
    Init --> Routes
    Routes --> Forms
    Routes --> Models
    Routes --> Recommender
    Routes --> Templates
    Routes --> Static
    Recommender --> Dataset
    Models --> DB
    Routes --> DB
    Run --> README
    Run --> Req

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef logic fill:#D0FFD0,stroke:#333,stroke-width:1px
    classDef data fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#333,stroke-width:1px
```
