Order Service is a microservice for managing orders within the Candy-Star application, built using FastAPI, PostgreSQL, Redis, RabbitMQ, Alembic, and Sentry.
- Python 3.10
- PostgreSQL
- Redis
- RabbitMQ
- Docker (for running RabbitMQ)
- Sentry
-
Clone the repository:
git clone https://github.com/Eastwesser/order-service.git
-
Create and activate a virtual environment:
python -m venv .venv .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create and configure the
.env
file based on.env.example
:cp .env.example .env
Ensure PostgreSQL is installed and running. Configure the connection in the .env
file.
Install and start the Redis server:
# On Ubuntu
sudo apt update
sudo apt install redis-server
sudo systemctl start redis-server
Check the status of Redis:
sudo systemctl status redis-server
Start RabbitMQ using Docker:
docker run -d --hostname my-rabbit --name some-rabbit -p 5672:5672 -p 15672:15672 rabbitmq:3-management
Start the application:
uvicorn app.main:app --reload
The application will be available at http://127.0.0.1:8003.
API documentation will be available at http://127.0.0.1:8003/docs.
order-service/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── crud/
│ │ ├── __init__.py
│ │ ├── crud.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── models.py
│ ├── routers/
│ │ ├── __init__.py
│ │ ├── order.py
│ ├── schemas/
│ │ ├── __init__.py
│ │ ├── order.py
│ ├── db/
│ │ ├── __init__.py
│ │ ├── session.py
├── alembic/
│ ├── versions/
│ ├── env.py
│ ├── script.py.mako
├── .env
├── .env.example
├── Dockerfile
├── requirements.txt
└── README.md
Get All Orders
GET /orders
Create a New Order
POST /orders
{
"product_id": 1,
"user_id": 1,
"quantity": 2,
"total_price": 3.98
}
Get an Order by ID
GET /orders/{order_id}
Update an Order
PUT /orders/{order_id}
{
"product_id": 1,
"user_id": 1,
"quantity": 3,
"total_price": 5.97
}
Delete an Order
DELETE /orders/{order_id}
For questions and suggestions:
Me - eastwesser@gmail.com
GitHub - https://github.com/Eastwesser
© 2024 Candy-Star. All rights reserved.