Bazar.com is an online marketplace where users can browse and purchase a variety of products conveniently. Whether you're looking for electronics, fashion items, home decor, or more, Bazar.com has something for everyone.
- Get all books.
- Get book by ID.
- Get books by topic
- Purchase a book
- Python (Flask)
- SQLite
- Docker
To get started with Bazarcom, follow these steps:
- Clone this repository to your local machine.
- To run the project using vscode terminal:
- Install the required dependencies by running:
- Uncomment the code for creating the database (from line 49 to 60):
- Start the catalog server:
- If you need to run it another time you sould comment the code for database (from line 49 to 60) because it will recreate the database with the initial data.
- Uncomment the code for creating the database (from line 49 to 51):
- Start the order server:
- If you need to run it another time you sould comment the code for database (from line 49 to 51) because it will recreate the database with the initial data.
- Start the gateway server:
pip install -r requirements.txt
with app.app_context(): db.drop_all() db.create_all() book1 = Book(title='How to get a good grade in DOS in 40 minutes a day', topic="distributed_systems", price=10.99, quantity=100) book2 = Book(title='RPCs for Noobs', topic="distributed_systems", price=15.00, quantity=50) book3 = Book(title='Xen and the Art of Surviving Undergraduate School', topic="undergraduate_school", price=5.00, quantity=30) book4 = Book(title='Cooking for the Impatient Undergrad', topic="undergraduate_school", price=10.00, quantity=70) db.session.add(book1) db.session.add(book2) db.session.add(book3) db.session.add(book4) db.session.commit()
python catalog/catalog.py
Now the catalog server running on
http://0.0.0.0:5000
python order/order.py
Now the order server running on
http://0.0.0.0:6000
python start gateway/gateway.py
Now the order server running on
http://0.0.0.0:5050
- To run the project using docker to separate each service/server into separate docker container (Recomended):
- Open powershell on your windows
- Heads towards your project (copy the path from vscode) then enter this command on powershell:
- Now we need to build images for each one of the servers(make sure that docker server is running on your device):
- Build catalog image
- Build order image
- Build gateway image:
- Now you need to run each image on a separate powershell window:
- Now you can send any request via the gateway and it will works well.
cd 'path/to/project'
cd catalog docker build -t catalog_service .
cd .. cd order docker build -t order_service .
cd .. cd gateway docker build -t gateway_service
docker run -it -p 5000:5000 catalog_service
docker run -it -p 6000:6000 order_service
docker run -it -p 5050:5050 gateway_service
We've made postman documentation here