A Flask web application that recommends books based on genre input, using a K-Means clustering model trained on TF-IDF genre vectors. The project is part of a PW Skills industrial training submission and includes complete software documentation (Architecture, HLD, LLD, Wireframe, Project Report).
Users select a book genre from a dropdown (populated from the dataset), and the app returns 5 book recommendations from the same K-Means cluster. The recommendation model and book data are pre-trained and saved as book_recommendation_model.pkl and filtered_books.csv respectively.
- At startup,
application.pyloadsbook_recommendation_model.pkl(containskmeans_modelandcluster_booksdict) andfiltered_books.csv. - A TF-IDF vectorizer is fitted on the
genrescolumn offiltered_books.csv. - When a user submits a genre:
- The genre string is transformed by TF-IDF.
- K-Means predicts the cluster.
- 5 random books from that cluster are returned.
genre_vector = tfidf_vectorizer.transform([genre])
cluster = kmeans_model.predict(genre_vector)[0]
recommendations = filtered_df[filtered_df['title'].isin(cluster_books[cluster])].sample(5)| Component | Technology |
|---|---|
| Backend | Python, Flask |
| ML Model | K-Means Clustering (scikit-learn) |
| Text Features | TF-IDF Vectorizer (scikit-learn) |
| Model Persistence | joblib |
| Data | filtered_books.csv (pre-filtered book dataset) |
| Frontend | HTML, CSS (Jinja2 templates) |
| Logging | Python logging module → app.log |
Book-Recommendation_System/
├── application.py # Flask app — routes, model loading, recommendation logic
├── book_recommendation_model.pkl # Pre-trained KMeans model + cluster_books dict
├── filtered_books.csv # Dataset (title, genres, etc.)
├── requirements.txt # Python dependencies
├── templates/
│ ├── index.html # Genre selection form
│ ├── recommendation.html # Recommendations display
│ └── error.html # Error page
├── static/ # CSS / JS assets
├── Architecture.pdf # System architecture diagram
├── HLD.pdf # High Level Design document
├── LLD.pdf # Low Level Design document
├── Wireframe.pdf # UI wireframes
├── Project Report.pdf # Full project report
├── DPR.pdf # Detailed Project Report
└── README.md
| Parameter | Value |
|---|---|
| Algorithm | K-Means Clustering |
| Input Features | TF-IDF vectors of book genre strings |
| Output | Cluster ID → sample 5 books from that cluster |
| Persistence | joblib.load() |
git clone https://github.com/jaideepj2004/Book-Recommendation_System.git
cd Book-Recommendation_System
pip install -r requirements.txt
python application.pyOpen http://0.0.0.0:5000 (or http://localhost:5000).
The repository includes complete software engineering documentation produced for PW Skills industrial training:
| Document | Description |
|---|---|
| Architecture.pdf | Overall system architecture and component interaction |
| HLD.pdf | High Level Design — modules and data flow |
| LLD.pdf | Low Level Design — detailed class/function-level design |
| Wireframe.pdf | UI wireframes for all screens |
| DPR.pdf | Detailed Project Report |
| Project Report.pdf | Complete project write-up |