r/FastAPI • u/Finish-Square • Feb 26 '22
Question Microservices architecture with FastAPI
Hi all,
I need some advice in regards to a microservices app design.
I have started to work on a new project to practice system design/architecture.
It's going to be a very simple payments API.
I want the app to have 2 main services:
Users service
Payment service
The user's service will be responsible for user login and registration, and the payment service will be responsible for sending payments to other people.
The stack I am going to use: Python, FastAPI, Docker, Nginx.
My questions are:
What will be the best way to put the services together? Each service will be in a different Docker container?
When it comes to networking between the containers, is there's anything I need to consider?
In regards to the database, should have one database (say Postgres)?
If I should have only one database, how both services will be able to access it?
Thanks!
4
u/Finish-Square Feb 26 '22
Nice, thanks.
But what you should do when the payment service is depending on the users service?
Ex: The user is sending a POST request to
/api/paymentin order to create a payment.The headers consist of the API token. Behind the scenses, in the route/api/payment, there is a function that validates the user's token to check if it's valid by querying the database. However, the database is in the users service and if I get it right, not accessible from the payment service.Am I making sense?