Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReviewNet

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.

Features

  • 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.

Tech stack

  • 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-turbo for recommendations
  • JavaScript/HTML templates under templates/ with static assets under static/

Getting started

  1. 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
  2. Copy .env.example (create if missing) to .env and 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
    
  3. Ensure MySQL is running, create the geeklogin database, and load the schema script:
    mysql -u root -p geeklogin < schema.sql
  4. Activate the virtual environment, install dependencies, and run the server:
    .venv\Scripts\Activate.ps1
    python app.py

Database schema hints

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.

Configuration

  • The Flask app now reads FLASK_SECRET_KEY, OPENAI_API_KEY, and MYSQL_{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 (and static/uploads/discussions/). Keep that directory writable and add it to .gitignore if needed.

Running the app

.venv\Scripts\Activate.ps1
python app.py

The 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).

API endpoints

  • 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.

Testing & utilities

  • python test_api.py exercises the OpenAI client (requires OPENAI_API_KEY in .env).
  • python check_env.py confirms the environment key is loading correctly.

Directory structure

  • 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 under static/uploads.

Notes

  • Secure the secret key and database credentials before deploying.
  • Batch your MySQL migrations/schemas in SQL scripts if sharing the project.
  • Review /static/uploads for large binary files before committing.

Let me know if you need help adding automated tests, Dockerization, or translating this README to Markdown for GitHub.

Visual previews

  • Homepage dive-in
  • Featured book highlight
  • Discussion board view
  • Cart and checkout
  • Community comments
  • Profile and orders

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages