A RESTful web application for managing a library, built with Python/Flask and SQLite. This project is designed for performance testing with JMeter.
This library system allows users to:
- Search and browse books
- Filter by author, year, and genre
- Checkout and return books
- View personalized recommendations based on checkout history
- See trending books (most checked out in the last 7 days)
- Backend: Python 3.11 + Flask
- Database: SQLite
- Frontend: HTML, CSS, JavaScript (vanilla)
- Container: Docker
library-project/
├── app/
│ ├── __init__.py # Flask app factory
│ ├── database.py # Database schema and connection
│ └── routes/
│ ├── __init__.py
│ ├── users.py # User CRUD routes
│ ├── books.py # Book routes with search/filter
│ ├── checkouts.py # Checkout/return routes
│ └── homepage.py # Homepage with recommendations
├── templates/
│ └── index.html # Main HTML template
├── static/
│ ├── css/style.css # Styles
│ ├── js/app.js # Frontend JavaScript
│ └── images/ # Static images
├── scripts/
│ └── import_data.py # Data import script
├── data/ # Database and CSV files
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── run.py # Application entry point
| Method | Route | Description |
|---|---|---|
| GET | /api/books | List books with filters |
| GET | /api/books/ | Get single book |
| GET | /api/books/search?q= | Search books |
| GET | /api/books/filters | Get filter options |
| PATCH | /api/books/ | Update book availability |
| OPTIONS | /api/books | Get allowed methods |
| POST | /api/users | Register user |
| POST | /api/users/login | Login user |
| GET | /api/users/ | Get user |
| PUT | /api/users/ | Update user |
| DELETE | /api/users/ | Delete user |
| POST | /api/checkouts | Checkout a book |
| GET | /api/checkouts | List checkouts |
| GET | /api/checkouts/ | Get checkout details |
| DELETE | /api/checkouts/ | Return a book |
| GET | /api/homepage | Get homepage data |
| GET | /api/homepage/trending | Get trending books |
| GET | /api/homepage/recommendations/ | Get user recommendations |
Download the Book Recommendation Dataset from Kaggle: https://www.kaggle.com/datasets/arashnic/book-recommendation-dataset
Place Books.csv in the data/ directory.
run.bat
-
Build Docker images
-
Start all required containers using docker-compose
-
Launch the application automatically
http://localhost:5000/
-
Docker Desktop installed and running
-
Windows environment (for .bat script)
# Install dependencies
pip install -r requirements.txt
# Run the application
python run.pyThis application includes intentional inefficiencies for performance testing:
- No Caching: Recommendations are recalculated on every page load
- Multiple Queries: Separate database queries for each recommendation type
- N+1 Query Pattern: Similar users recommendations use nested loops
- Full Table Scans: Search uses LIKE queries without optimized indexes
- Image Loading: External images loaded on every request
After baseline JMeter testing, consider optimizing:
- Add caching for trending books and recommendations
- Combine recommendation queries into single optimized query
- Add database indexes for frequent search patterns
- Implement lazy loading for images
- Add pagination to recommendations
- Use connection pooling
After running import_data.py, sample users are created:
- Username:
user1touser100 - Password:
pass1topass100
Example: Login with user1 / pass1
Key endpoints to test:
GET /api/homepage?user_id=1- Full homepage with recommendationsGET /api/books?search=python- Book searchPOST /api/checkouts- Book checkoutGET /api/homepage/recommendations/1- Recommendations only
- [Brian Nguyen]
- [Owen Davis]
- [Dilraj Sooch]
- [Kahlib Stewart]
This project uses Doxygen to generate API documentation from Python docstrings.
# Using Make (recommended)
make docs
# Or using docker-compose directly
docker-compose run --rm docs# Using Make - serves on http://localhost:8080
make docs-serve
# Or manually
docker-compose run --rm docs
docker-compose --profile docs-server up -d docs-serverIf you have Doxygen installed locally:
# Install Doxygen (Ubuntu/Debian)
sudo apt-get install doxygen graphviz
# Generate documentation
doxygen Doxyfile
# Or use Make
make docs-localAfter generation, open docs/html/index.html in your browser, or access http://localhost:8080 if using the docs-server.
Doxyfile- Doxygen configuration filedocs/html/- Generated HTML documentation (gitignored)docs/doxygen_warnings.log- Build warnings log
CSCN73060 - Web Project