This project is an API for renting and selling yachts. The API allows users to register accounts, book yachts, leave reviews, view available yachts, sell yachts, and manage their user data. Administrative access is also enabled to manage users, yachts, and bookings.
- POST /auth/register: Allows users to register.
- POST /auth/login: Allows users to log in and receive a JWT token for further interactions with the API.
- GET /user/show: Displays user information.
- POST /user/upload-picture: Allows users to upload their profile picture.
- GET /yacht: Displays a list of yachts with filters.
- GET /yacht/{id}: Displays yacht details.
- POST /rents: Allows users to book a yacht for rent.
- DELETE /rents/{rent_id}: Allows users to cancel a booking.
- GET /yacht/{id}/active-rents: Displays active rentals for a yacht.
- POST /reviews: Allows users to leave reviews for yachts.
- DELETE /reviews/{review_id}: Allows users to delete their reviews.
- POST /sale: Allows users to sell their yachts.
- GET /sale/my-sales: Displays all sales by the user.
- GET /status: Displays all statuses.
These routes are restricted to admin users and provide functionality to manage users, yachts, and other aspects of the platform.
- GET /user/all-users: View all registered users. (Admin only)
- GET /user/{id}: View user information by ID. (Admin only)
- DELETE /user/{id}: Ban a user by ID. (Admin only)
- POST /user/{id}/admin: Grant admin privileges to a user by ID. (Admin only)
- POST /yacht: Add a new yacht. (Admin only)
- PUT /yacht/{id}: Update yacht details. (Admin only)
- DELETE /yacht/{id}: Delete a yacht by ID. (Admin only)
- POST /yacht/{id}/upload-image: Upload an image for a yacht. (Admin only)
- POST /status: Allows admin to create new status.
This project uses the following technologies:
- FastAPI: Web framework for building APIs quickly.
- SQLAlchemy: ORM for database interactions.
- Pydantic: Data validation.
- MySQL: Database for storing data.
- JWT: For user authentication and authorization.
- Alembic: Database migrations.
Before you start, ensure you have the following installed on your machine:
- Python 3.12 or higher
- pip 22.0.4 or higher (Python package manager)
- A database system compatible with your project
Follow these steps to set up and run the project:
git clone https://github.com/PopovicJovan/devlab-final-fapi.git
cd devlab-final-fapi
python3 -m venv .venv
- to activate virtual environment run:
source .venv/bin/activate
pip install -r requirements.txt
- Update the database configuration files (e.g., settings.py or .env).
cp app/.env.example app/.env
alembic upgrade head
fastapi dev app/main.py