Rating API is a full-featured rating and review platform built with a modern tech stack. It allows users to rate and review items, discover new content through recommendations, and provides administrators with powerful analytics tools.
- User Authentication - Secure login/signup system
- Item Rating & Reviews - Rate items on a 1-5 scale and leave detailed comments
- Personal Recommendations - Get personalized recommendations based on rating history
- Profile Management - Update personal information and view rating history
- Complete User Management - Create, update, and manage user accounts
- Item Management - Add, update, and categorize items
- Category System - Organize items into customizable categories
- Tag System - Add flexible tags to better describe items
- Content Moderation - Remove inappropriate reviews/comments
- Analytics Dashboard - Comprehensive analytics including:
- Rating distributions
- User growth metrics
- Engagement statistics
- Overall platform performance
- FastAPI - High-performance API framework
- SQLAlchemy - ORM for database interactions
- PostgreSQL - Robust relational database
- Pydantic - Data validation and settings management
- JWT - Token-based authentication
- Next.js - React framework for web interface
- React Query - Data fetching and state management
- Tailwind CSS - Utility-first CSS framework
- Chart.js - Data visualization
RatingApp/
β
βββ app/ # Backend application
β βββ api/ # API routes and endpoints
β β βββ endpoints/ # Individual route modules
β β βββ auth.py # Authentication handlers
β β βββ security.py # Security utilities
β β
β βββ application/ # Application layer
β β βββ schemas/ # Pydantic schemas/DTOs
β β βββ services/ # Business logic services
β β
β βββ domain/ # Domain models
β β βββ user.py
β β βββ item.py
β β βββ category.py
β β βββ tag.py
β β βββ rating.py
β β
β βββ infrastructure/ # Data access layer
β β βββ repositories/ # Repository pattern implementations
β β βββ database.py # Database connection
β β
β βββ config.py # Application configuration
β βββ main.py # Application entry point
β
βββ migrations/ # Database migration files
βββ tests/ # Test suite
βββ docker/ # Docker configuration
β βββ Dockerfile.api # API service Dockerfile
β βββ Dockerfile.frontend # Frontend Dockerfile
β βββ docker-compose.yml # Docker composition
β
βββ requirements.txt # Python dependencies
βββ .env.example # Example environment variables
βββ README.md # Project documentation
- Python 3.9+
- Node.js 16+
- PostgreSQL
- Docker (optional)
- Clone the repository:
git clone https://github.com/Alwil17/rating-api.git
cd rating-api
- Set up a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
cp .env.example .env
# Edit .env with your database credentials and settings
- Initialize the database migrations:
# Make sure your database connection details are in .env file
# DATABASE_URL=postgresql://username:password@localhost:5432/ratingapp
# Create the versions directory if it doesn't exist
mkdir -p alembic/versions
# Create a new migration
alembic revision --autogenerate -m "Initial migration"
# Apply the migrations
alembic upgrade head
- Start the backend server:
uvicorn app.api.main:app --reload
For a quick setup with Docker:
docker-compose up -d
This will start both the backend API and frontend services, along with a PostgreSQL database.
The API uses JWT tokens for authentication:
- Get a token by calling POST
/auth/token
with email and password - Include the token in subsequent requests as a Bearer token in the Authorization header
Before running tests, you need to set up a test database:
# Create the test database
python setup_test_db.py
# Run all tests
pytest
# Run specific test file
pytest tests/test_auth.py
# Run with verbose output
pytest -v
Tests use a separate database named rating_db_test
by default to avoid affecting your development or production data.
API documentation is automatically generated and available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.