This project is an asynchronous payment processing API built with FastAPI. It handles payment transactions in the background, integrates with external services (for loyalty and notifications), and uses separate databases for user balances and payment records.
- Asynchronous Processing: Uses FastAPI with background tasks for non-blocking operations.
- Database Separation: Maintains user (wallet) data and payment records in separate databases.
- Reliable Transactions: Implements custom retry logic and explicit transaction management.
- External Service Integration: Communicates with external APIs for loyalty rewards and notifications.
Before starting the application, initialize the databases if they do not exist. The database initialization script is located at app/utils/db/init.py.
To run the initialization script, execute:
python -m app.utils.db.initTo run the application using uvicorn:
uvicorn app.main:app --host $HOST --port $PORT --reloadAlternatively, you can run it via:
python -m app.mainpython -m app.services.loyaltyor using uvicorn:
uvicorn app.services.loyalty:app --host 0.0.0.0 --port 8001 --reloadpython -m app.services.notificationor using uvicorn:
uvicorn app.services.notification:app --host 0.0.0.0 --port 8002 --reloadBelow is an example command for running a PostgreSQL database in Docker:
docker run --name test-pg-15 -p 5432:5432 -e POSTGRES_USER=testuser -e POSTGRES_PASSWORD=testpass -e POSTGRES_DB=test -d postgres:15