This is a full-stack bidding application where admins can add products, and users can place bids. The application ensures secure authentication using JWT and includes a React-based frontend and a FastAPI backend.
- Admins can add products for bidding.
- Users can place bids, with the highest bid highlighted after the bidding ends.
- Bids can only be placed if they are higher than the current bid.
- Bids cannot be placed after the bidding end time.
- Authentication is handled using JWT for secure access.
- Next.js with pnpm
- Environment variables stored in
/frontend/.env.
- FastAPI for API services.
- SQLAlchemy for database ORM.
- MySQL as the database.
- Environment variables stored in
/backend/.env.
Make sure the following are installed on your system:
- Node.js
- pnpm
- Python (v3.9 or later)
- MySQL database server
-
Navigate to the backend folder:
cd backend -
Set up a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
-
Windows:
venv\Scripts\activate
-
Linux/Mac:
source venv/bin/activate`
-
-
Install the required dependencies:
pip install -r requirements.txt
-
Configure environment variables::
- Create a .env file in the /backend folder based on the
env.exampleprovided. - Add the necessary configuration values (e.g., database connection URL, JWT secret).
- Create a .env file in the /backend folder based on the
-
Create the Database:
- Create the Database in MySQL e.g. Bidding
-
Run the backend server:
uvicorn app:app --reload --host 0.0.0.0 or python3 app.py
-
Navigate to the frontend folder:
cd frontend -
Install the required dependencies:
pnpm install
-
Configure environment variables:
- Create a .env file in the /frontend folder based on the
env.exampleprovided. - Add the necessary configuration values (e.g., backend URL).
- Create a .env file in the /frontend folder based on the
-
Start the frontend server:
pnpm run dev
The frontend will start running at http://localhost:3000 by default.
- POST /token - Authenticate users and return a JWT token.
- POST /signup - Sign up new users.
- POST /add-admin - Add a new admin (admin-only route).
- GET /refresh-token - Refresh the token when accessing a protected route to persist the cookie and prevent sign out.
- POST /add-product - Add a new product for bidding (admin-only route).
- GET /products - Retrieve all products.
- GET /product/{product_id} - Retrieve details of a specific product.
- DELETE /product/{product_id} - Delete a product (admin-only route).
- POST /product/{product_id}/bid - Place a bid on a product.
-
The application uses a MySQL database. Ensure your database is running and configured properly.
-
The connection URL should be set in the
/backend/.envfile, using the format:DATABASE_URL=mysql://<user>:<password>@<host>:<port>/<database_name>
-
Replace
<user>,<password>,<host>,<port>, and<database_name>with appropriate values.





