# subrat1920/book-recommendation-system architecture

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

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

## Overview

##### Project type and purpose
- This is a full-stack Python application—a Book Recommendation System—with two main subsystems:
- A Streamlit-based web UI (st_app.py)
- A modular recommendation backend (recommend/…)
- It implements two ML strategies (popularity-based & collaborative filtering) and persists data in SQLite.

##### File structure
- Top-level scripts:
- st_app.py – Streamlit entry point for the web UI
- main.py – CLI or orchestration script for running pipelines
- Core package: recommend/
- components/
– data_ingestion.py
– data_transformation/ (cb_filtering.py, popularity_based.py)
– data_validation.py
- constants/ – central configuration values
- exception/ – custom exception hierarchy
- logging/ – application-wide logging setup
- utils/ – helper functions
- Artifacts/ – contains runtime SQLite databases for each stage:
- data_ingestion/*.db
- data_transformation/*/*.db
- data_validation/report.txt
- Notebooks/ – exploratory Data Science work & raw CSV datasets

##### Extract architectural insights from the README
- Three logical phases: Data Collection & Processing → Model Development → Web Application
- Emphasis on modularity, scalability, maintainability
- Hybrid recommendation approach (popularity + collaborative)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Sources
    subgraph "External Sources"
        CSVDatasets["CSV Datasets\nNotebooks/Datasets"]:::external
        Notebooks["Data Science Notebooks\nNotebooks/RecommendationSystem.ipynb"]:::external
    end

    %% Data Pipeline Layer
    subgraph "Data Pipeline Layer"
        Ingest["Data Ingestion\nrecommend/components/data_ingestion.py"]:::service
        RawDBs["Raw Databases\nbooks.db, ratings.db, user.db"]:::db
        subgraph "Data Transformation"
            CB["Collaborative Filtering\nrecommend/components/data_transformation/cb_filtering.py"]:::service
            PB["Popularity-Based Filter\nrecommend/components/data_transformation/popularity_based.py"]:::service
        end
        TransDBs["Transformed DBs\nrating_matrix.db, details_of_popular_books.db"]:::db
        Validate["Data Validation\nrecommend/components/data_validation.py"]:::service
        Report["Validation Report\nreport.txt"]:::external
    end

    %% Application/Service Layer
    subgraph "Application/Service Layer"
        RecEngine["Recommendation Engine\n(calls CB & PB modules)"]:::service
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Streamlit UI\nst_app.py"]:::ui
    end

    %% Orchestration
    Main["Orchestration CLI\nmain.py"]:::service

    %% Cross-Cutting Concerns
    subgraph "Cross-Cutting Concerns"
        Logging["Logging\nrecommend/logging/logging.py"]:::cross
        Exception["Exception Handling\nrecommend/exception/exception.py"]:::cross
        Utils["Utilities\nrecommend/utils"]:::cross
        Const["Constants\nrecommend/constants"]:::cross
    end

    %% Data Flows
    CSVDatasets --> Ingest
    Notebooks --> Ingest
    Ingest --> RawDBs
    RawDBs --> CB
    RawDBs --> PB
    CB --> TransDBs
    PB --> TransDBs
    TransDBs --> Validate
    Validate --> Report
    TransDBs --> RecEngine
    RecEngine --> UI
    UI --> RecEngine
    UI -->|"new input"| Ingest

    Main --> Ingest
    Main --> Validate
    Main --> RecEngine

    %% Cross-Cutting Invocations
    Ingest --> Logging
    CB --> Logging
    PB --> Logging
    Validate --> Logging
    RecEngine --> Logging
    UI --> Logging
    Main --> Logging

    Ingest --> Exception
    CB --> Exception
    PB --> Exception
    Validate --> Exception
    RecEngine --> Exception
    UI --> Exception
    Main --> Exception

    %% Click Events
    click UI "https://github.com/subrat1920/book-recommendation-system/blob/main/st_app.py"
    click Main "https://github.com/subrat1920/book-recommendation-system/blob/main/main.py"
    click Ingest "https://github.com/subrat1920/book-recommendation-system/blob/main/recommend/components/data_ingestion.py"
    click CB "https://github.com/subrat1920/book-recommendation-system/blob/main/recommend/components/data_transformation/cb_filtering.py"
    click PB "https://github.com/subrat1920/book-recommendation-system/blob/main/recommend/components/data_transformation/popularity_based.py"
    click Validate "https://github.com/subrat1920/book-recommendation-system/blob/main/recommend/components/data_validation.py"
    click Logging "https://github.com/subrat1920/book-recommendation-system/blob/main/recommend/logging/logging.py"
    click Exception "https://github.com/subrat1920/book-recommendation-system/blob/main/recommend/exception/exception.py"
    click Utils "https://github.com/subrat1920/book-recommendation-system/tree/main/recommend/utils"
    click Const "https://github.com/subrat1920/book-recommendation-system/tree/main/recommend/constants"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef cross fill:#FFFACD,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
