Demo link: https://cmarketplace.romansth.com
This API provides 4 routes:
This route handles the retrieval, creation, deletion, and updating of listings.
This route is used for user creation, searching users by ID, searching listings by user ID, and retrieving orders for a logged-in user.
This route manages user login and authentication.
This route is used to create new orders for an existing listing and change the status of a pending order.
-
Clone this repository:
git clone https://github.com/Romansth/College-Marketplace-FASTAPI.git cd College-Marketplace-FASTAPI
-
Create a virtual environment:
python3.9 -m venv <virtual_env_path>
-
Activate the virtual environment:
source <virtual_env_path>/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Start the API:
uvicorn app.main:app --reload
-
Access the API documentation at:
http://127.0.0.1:8000/docs
-
Set up a PostgreSQL database and create a
.env
file in the root folder with the following content:DATABASE_HOSTNAME=localhost DATABASE_PORT=5432 DATABASE_PASSWORD=your_database_password DATABASE_NAME=your_database_name DATABASE_USERNAME=your_database_username SECRET_KEY=09d25e094faa2556c818166b7a99f6f0f4c3b88e8d3e7 ALGORITHM=HS256 ACCESS_TOKEN_EXPIRE_MINUTES=60
Note: Replace the placeholder values with your actual database configuration.
-
Use a secure, unique SECRET_KEY from the FastAPI documentation.
-
To run tests with pytest:
pytest
- Prerequisites:
- Docker: Follow the installation instructions if you don't have it installed.
- Docker Compose: Refer to the official documentation for installation guidance.
- Build the Stack
docker-compose -f local.yml build
- Run the Stack
docker-compose -f docker-compose-dev.yaml up
You can set environment variables manually in docker-compose-dev.yaml
or point .env
variables to the docker-compose-dev.yaml
file.
To run in detached (background) mode:
docker-compose up -d
- Access the API documentation at:
http://127.0.0.1:80/docs
This project is licensed under the MIT License.