Create a single API that seamlessly exposes the data of three different systems: Warehouse, Accounting, Sales. The system should be available 24/7, scalable, resilient to failures, and the data should be available through different offices around the world.
Design the architecture of the new system and explain your reasons to use itCode at least three microservices with the best code quality possible and expose them via a REST APIThe software artifacts should be covered by unit testsThe software artifacts should be easy to package and deploy
Provide any document or diagram useful to explain your proposal- Applications covered by acceptance tests suites
Define the software technologies that should be used to build a system that’s scalable, reliable, and distributed.- Describe your ideal development workflow considering stability, security, and agility from the beginning.
- Define a versioning policy and a strategy to deploy in production
- Automatically generated documentation
- Mention the software technologies to build your ideal CI/CD environment
Fully functional CI workflow- Fully functional CD workflow
Stack: Python, Django, Postgres, Kubernetes, NGINX
Why Django? Personal curiosity, because I've never worked with it.
Why Kubernetes? Kubernetes allows easily scale services and make clear intra-service communication.
Why Postgres? This is the most common enterprise DB solution.
Why NGINX? It provides the ability to run API Gateway in Kubernetes Cluster
The whole system is supposed to be deployed in a Kubernetes cluster and have cluster API Gateway to all the services.
Service | Deploy |
Each service has several layers, which are flexible to extend and replace. | Each service(django project) has the following files to be able to work with other services within a Kubernetes cluster: |
Intra-service communication
At the moment, the is only one intra-service communication between Sales and Warehouse which is accessible via the following endpoint:
curl "http://<GATEWAY_IP>:<GATEWAY_PORT>/sales/sold_items"
This will run 3 separate services with databases
-
sh small_business_ms/k8s/run_services.sh
- Use
warehouse.init_data.sql
,accounting.init_data.sql
andsales.init_data.sql
scripts to fill in some data (I'm using DBeaver) - Use the corresponding Postman collections to run.
-
You may use any local kubernetes services you like, but this project was run under Docker Desktop Kubernetes. Do the following steps to use it:
-
From the Docker Dashboard, select the Settings.
-
Select Kubernetes from the left sidebar.
-
Next to Enable Kubernetes, select the checkbox.
-
Select Apply & Restart to save the settings and then click Install to confirm.
More information about Kubernetes under Docker Desktop you may find following the link.
-
-
Please, make sure you have kubectl installed. If not, use the instructions to install
-
Using git bash or terminal(macOS) run the following commands:
- Choose a directory you want to clone a project and run:
git clone git@github.com:BarabanovaIrina/small_business_ms.git
- Without changing the directory run build all services necessary images:
sh small_business_ms/k8s/build_images.sh
- Build NGINX API Gateway and enable port forwarding:
sh small_business_ms/k8s/deploy_all.sh
-
If you face issues like
Internal error occurred
, please, run the previous step again. That might happen when parts take some time to deploy. -
As a final result you should see port forwarding messages:
Forwarding from 127.0.0.1:8080 -> 80 Forwarding from [::1]:8080 -> 80 Forwarding from 127.0.0.1:8443 -> 443 Forwarding from [::1]:8443 -> 443
There is a Postman collection with all the available(at the moment) requests you may test.
Replace dummy Dict database with a real Postgres databaseExtend CRUD for other services- Come up with a scenario of using message bus in intra-service communication
Create CD pipelines- Add auto-documentation
- Fix imports in test or divide services into separate repositories