The project is consisted of two apps users
and transactions
. The users
app is responsible for user authentication and the transactions app is responsible for creating and listing transactions.
The project uses FastAPI as the web framework and SQLAlchemy as the ORM.
For this you need to have Python 3.8 or higher installed. Click here to download Python.
Create a virtual environment:
# create a virtual environment
python -m venv venv
# activate the virtual environment
source venv/bin/activate
Install the dependencies:
pip install -r requirements.txt
For the database, you need to have PostgreSQL installed. Click here to download PostgreSQL. But I also added a cloud database for testing purposes.
To run the application:
uvicorn main:app --reload
To view the API documentation, go to http://localhost:8000/docs
in your browser after running the application.
- Each app has a separate logic than others and contains its own models, endpoints, and services.
/app
├── models.py
├── schemas.py
├── routes.py
└── services.py
This project uses pytest for testing. To run the tests:
pytest
- Create a user by just giving a
name
. After creating a user, you will get atoken
which you can use to authenticate yourself in the next steps. - Past the JWT token on the top right corner of the page and click on
Authorize
button. (or use it in Postman) - Since the project is designed for event-driven architecture, you can create a list transactions (1 or many) by sending a POST request to
/transactions
endpoint. - The system loads transactions and then writes back in the end to minimize the number of database queries.
- In the end user
credit
andpayable
is also updated + any transaction with theiruser_id
. - App is dockerized and is fully ready to be deployed on any cloud provider.
Parsa Mazaheri, Oct 2023