-
This is a simple microservices project using
Docker
andFlask
. -
For Frontend,
Jinja2
andBootstrap
is used. -
Secret keys are stored in a
.env
file and they are generated using withgenerate_token.py
script. -
The project is divided into 4 microservices:
user
,book
,order
andfrontend
. -
All database migration can be done using
make-migrations.sh
script. -
All databases stored at
<service>/database
folder. -
You can found postman collection in
postman
folder.
-
Default Port:
5000
and Default Host:0.0.0.0
-
/api/user/login
-POST
- Login user - Body:{"username": string, "password": string}
-
/api/user/create
-POST
- Create user - Body:{"username": string, "password": string}
-
/api/user/all
-GET
- Get all users -
/api/user/logout
-Post
- Logout user -
/api/user/get
-GET
- Get Current user -
/api/user/exists/<username>
-GET
- Check if user exists - Path Parameters:username (string)
-
Default Port:
5002
and Default Host:0.0.0.0
-
/api/book/all
-GET
- Get all books -
/api/book/create
-POST
- Create book - Body:{"name": string, "slug": string, "image": string, "price": integer}
-
/api/book/get/<slug>
-GET
- Get book by slug - Path Parameters:slug (string)
-
Default Port:
5001
and Default Host:0.0.0.0
. Also, it depends onuser
andbook
microservices. -
All of the endpoints require authentication except Get all order. Authentication is done using Authorization header as
Authorization: api_key
. Authorization header can be obtained from/api/user/login
endpoint. -
/api/order/all
-GET
- Get all orders -
/api/order/add-item
-POST
- Add order - Body:{"book_id": integer, "quantity": integer}
Also, it requiresAuthorization
header. -
/api/order/checkout
-POST
- Checkout order of user - Also, it requiresAuthorization
header. -
/api/order/
-GET
- Get open order - Also, it requiresAuthorization
header.
-
Default Port:
5003
and Default Host:0.0.0.0
. Also, it depends onuser
,order
andbook
microservices. -
You can access the frontend from
http://0.0.0.0:5003
address.
-
First, you need to install
docker
anddocker-compose
on your machine. -
Then you can run the application using
docker compose build && docker-compose up -d
command infrontend
folder. For stopping the application, you can usedocker-compose down
command. For restarting the application, you can usedocker-compose restart
command.