A community-focused book discovery and discussion platform built with Flask. ReviewNet lets readers share reviews, comment on other users' thoughts, host book club-style discussions, manage a shopping cart, and receive personalized book recommendations from OpenAI.
- User authentication with registration, login, logout, and profile management (including favourite books and profile picture uploads).
- Comment and review system that supports threaded replies tied to each book entry.
- Dedicated discussion board for new book topics, with admin moderation tools for discussions, comments, and users.
- Shopping cart and order management with customer checkout flow plus admin order overview/status updates.
- OpenAI-powered recommendation API that logs history for authenticated users.
- Contact form and newsletter capture for visitor outreach.
- Python 3.11+ (Flask application)
- Flask extensions:
Flask-MySQLdb,python-dotenv - MySQL database (schema includes accounts, reviews, comments, discussions, cart/order tables, newsletter subscribers, recommendation logs)
- OpenAI
gpt-3.5-turbofor recommendations - JavaScript/HTML templates under
templates/with static assets understatic/
- Install Python dependencies (preferably inside a virtual environment):
python -m venv .venv .venv\Scripts\Activate.ps1 # PowerShell on Windows pip install flask flask_mysqldb mysqlclient openai python-dotenv
- Copy
.env.example(create if missing) to.envand populate the runtime secrets and credentials:FLASK_SECRET_KEY=some-long-random-string OPENAI_API_KEY=sk-xxx MYSQL_HOST=localhost MYSQL_USER=root MYSQL_PASSWORD=PASSWORD MYSQL_DB=geeklogin - Ensure MySQL is running, create the
geeklogindatabase, and load the schema script:mysql -u root -p geeklogin < schema.sql
- Activate the virtual environment, install dependencies, and run the server:
.venv\Scripts\Activate.ps1 python app.py
The app assumes the following tables (columns shown are primary expectations; adapt as needed):
accounts(id PK, username, password, email, is_admin BOOLEAN DEFAULT FALSE, favourite_books TEXT, profile_pic TEXT)reviews(id PK, user_id FK accounts.id, content, created_at)comments(id, review_id FK reviews.id, user_id FK accounts.id, content, parent_id NULLABLE, created_at)discussions(id, user_id, title, brief, book_name, banner_image, created_at)discussion_comments(id, discussion_id, user_id, content, created_at)cart_items(id, user_id, book_title, book_author, price DECIMAL, book_image, quantity)orders(id, user_id, total_amount DECIMAL, payment_method, shipping_address, phone, status, created_at)order_items(id, order_id FK orders.id, book_title, book_author, book_image, price, quantity)recommendation_history(id, user_id, genre, book_read, preferences, recommendations JSON/TEXT, created_at)contact_messages(id, name, email, subject, message, created_at)newsletter_subscribers(id, email UNIQUE)
The included schema.sql file provisions the tables shown below; adapt it if you add new features. Add indexes/FKs as needed and ensure the MySQL user defined in .env has CRUD access.
- The Flask app now reads
FLASK_SECRET_KEY,OPENAI_API_KEY, andMYSQL_{HOST,USER,PASSWORD,DB}from the environment; keep those values out of version control and rotate them before production deploys. - Uploads land in
static/uploads(andstatic/uploads/discussions/). Keep that directory writable and add it to.gitignoreif needed.
.venv\Scripts\Activate.ps1
python app.pyThe server launches on http://127.0.0.1:5000 by default. Access the admin panel via /setup_admin to bootstraps a single admin user (uses key reviewnet_setup_2025).
POST /api/get_recommendations: Payload{ "genre": "", "book_read": "", "preferences": "" }returns OpenAI recommendations and logs history.- Cart management routes (
/api/add-to-cart,/api/get-cart,/api/remove-from-cart,/api/update-cart,/api/clear-cart,/api/get-cart-count) require authentication via session cookie. - Order flow (
/place_order,/order_success/<id>,/my_orders,/order_details/<id>) plus admin order management routes under/admin/orders,/admin/update_order_status,/admin/delete_order.
python test_api.pyexercises the OpenAI client (requiresOPENAI_API_KEYin.env).python check_env.pyconfirms the environment key is loading correctly.
app.py: Flask routes, OpenAI integration, carts, orders, reviews/discussions, admin features.books_data.py: Sample book metadata helpers.templates/: HTML templates (home, book pages, discussion views, admin, cart, etc.).static/: CSS/JS/assets; uploads saved understatic/uploads.
- Secure the secret key and database credentials before deploying.
- Batch your MySQL migrations/schemas in SQL scripts if sharing the project.
- Review
/static/uploadsfor large binary files before committing.
Let me know if you need help adding automated tests, Dockerization, or translating this README to Markdown for GitHub.





