# mb-13/book_recommendation_site architecture

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

- Interactive diagram: https://gitdiagram.com/mb-13/book_recommendation_site
- Repository: https://github.com/mb-13/book_recommendation_site

## Overview

##### Project Type and Purpose
- The repository is a Django-driven web application called “Book Recommendation Site” (a full-stack site).
- It features multiple functionalities such as personalized recommendations, semantic search using SBERT/SentenceTransformer, real‐time search suggestions, infinite scrolling, and user session/authentication.
- The project includes both frontend components (HTML/CSS/JS in static and templates directories) and backend logic (divided into several Django apps).

##### File Structure for Components
- Top-level Django project folder: “Book_Site” where settings, URL routing (urls.py), and WSGI/ASGI configurations reside.
- Several Django apps including:
- Book_Detail_Page: Handles detailed book info pages.
- Genre_Page: Manages genre-specific book listings.
- Home_Page: Likely the landing/home page with featured recommendations.
- Search_Page: Implements the semantic/embedding-based search feature.
- login_and_signup: Manages user authentication (login, register, password reset).
- Other assets:
- Static directories (global and per app) for CSS, JS, and images.
- HTML templates (global base template and app-specific templates).
- CSV data files (e.g., Book-DataV1.csv, Book-DataV2.csv, bestseller.csv) that likely feed into the database or recommendations.
- A demo folder with a demo video illustrating navigation.
- The presence of migrations indicate standard Django ORM integration with a database for persisting user data, book details, etc.
- The README also hints at external modules for natural language processing (SBERT/SentenceTransformer) and web scraping (Beautiful Soup).

##### Architectural Components and Their Relationships
- Frontend Client:
- Browser or client-side interface that loads HTML/CSS/JS.
- Provides pages for home, search, book details, genre browsing, and user authentication.
- Django Server:
- Main “Book_Site” project as the core engine.
- Routes incoming HTTP requests to the appropriate app via URL configurations.
- Each Django app (e.g., Home_Page, Book_Detail_Page, etc.) acts as a modular component handling specific functionalities.
- Database and ORM:
- Django ORM with migrations in every app for persisting and querying data related to books, user details, and recommendations.
- Recommendation & Search Engine:
- Uses SBERT/SentenceTransformer to generate and use book embeddings.
- Responsible for personalized recommendations and embedding-based search.
- External Data Sources:
- CSV data files for seeded book data.
- Web scraping scripts (using Beautiful Soup) to update or create the database from Goodreads.
- User Session Management:
- Handled through the login_and_signup app, ensuring data security and personalized interactions.

- Break the system into clear, separate components:
- Frontend/Client (Browser/User Interface)
- Backend Server (Django Project)
- Book_Detail_Page
- Home_Page
- Genre_Page
- Search_Page
- login_and_signup
- Database (Django ORM-backed RDBMS)
- Recommendation Engine (SBERT & SentenceTransformer component)
- Data Import/Transformation layer (CSV data sources and web scraping scripts)
- Directional interactions:
- Data flow between the Backend Server and the Database (CRUD operations via the ORM).
- Data Import layer (CSV files, Beautiful Soup scraping routines) to the Database for initial/population data.
- Use another for backend modular apps.

##### Final Elements to Be Present
- Clear labels for each component (e.g., “Frontend Client”, “Django Server: Book_Detail_Page”, “Database”, “Recommendation Engine”).
- Client → Django Server (HTTP requests).
- Django Server → Database (ORM queries; migration flows).
- Django Server → External Services/Modules (embedding-based search, web scraping).
- Django apps versus external libraries/services.
- Presentation vs. business logic layers.

Happy designing!

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Subgraph
    subgraph "Frontend"
        A["Frontend Client"]:::frontend
        M["Static Assets"]:::frontend
        N["Base Template"]:::frontend
    end
    M --> A
    N --> A

    %% Django Server Subgraph
    subgraph "Django Server"
        C["Book_Site (URL Router)"]:::backend
        D["Book_Detail_Page"]:::backend
        E["Genre_Page"]:::backend
        F["Home_Page"]:::backend
        G["Search_Page"]:::backend
        H["login_and_signup"]:::backend
    end
    A -->|"HTTP_Requests"| C

    C --> D
    C --> E
    C --> F
    C --> G
    C --> H

    %% Database Node
    I[(Database)]:::database
    D -->|"ORM_queries"| I
    E -->|"ORM_queries"| I
    F -->|"ORM_queries"| I
    G -->|"ORM_queries"| I
    H -->|"ORM_queries"| I

    %% Recommendation Engine
    J["Recommendation Engine (SBERT)"]:::external
    F -->|"embedding"| J
    G -->|"embedding"| J

    %% Data Import & Web Scraping
    K["Data Import & Web Scraping"]:::external
    K -->|"data_load"| I

    %% Demo Video
    L["Demo Video"]:::external
    A -->|"demo"| L

    %% Click Events
    click C "https://github.com/mb-13/book_recommendation_site/blob/main/Book_Site/urls.py"
    click D "https://github.com/mb-13/book_recommendation_site/blob/main/Book_Detail_Page/views.py"
    click E "https://github.com/mb-13/book_recommendation_site/blob/main/Genre_Page/views.py"
    click F "https://github.com/mb-13/book_recommendation_site/blob/main/Home_Page/views.py"
    click G "https://github.com/mb-13/book_recommendation_site/blob/main/Search_Page/views.py"
    click H "https://github.com/mb-13/book_recommendation_site/blob/main/login_and_signup/views.py"
    click M "https://github.com/mb-13/book_recommendation_site/tree/main/static"
    click N "https://github.com/mb-13/book_recommendation_site/blob/main/templates/base.html"
    click K "https://github.com/mb-13/book_recommendation_site/blob/main/Book-DataV1.csv"
    click L "https://github.com/mb-13/book_recommendation_site/blob/main/demo/Demo-video.mp4"

    %% Styles
    classDef frontend fill:#F9E79F,stroke:#000,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#000,stroke-width:2px;
    classDef database fill:#A9DFBF,stroke:#000,stroke-width:2px;
```
