A comprehensive RESTful API for a simple user wallet system, built with a modern Python stack. This project allows for user management, wallet balance updates, and transaction history retrieval. It is fully containerized with Docker and deployed on an AWS EC2 instance with an automated CI/CD pipeline.
The API is live and its interactive documentation (Swagger UI) can be accessed here:
This project is hosted on an AWS EC2 Free Tier instance to manage costs. The instance may be stopped periodically. If the demo link is unavailable, please feel free to email me at aksbal2005@gmail.com, and I will be happy to spin the server up for you.
- List Users: Fetch details (name, email, phone) for all users along with their current wallet balance.
- Update Wallet: Add or deduct an amount from a specific user's wallet, creating a transaction record for each operation.
- Fetch Transactions: Retrieve a complete, chronologically sorted list of all wallet transactions for a specific user.
- Backend: FastAPI, Uvicorn
- Database: PostgreSQL
- ORM: SQLAlchemy
- Data Validation: Pydantic
- Containerization: Docker
- Web Server / Reverse Proxy: Nginx
- Deployment: AWS EC2
- CI/CD: GitHub Actions
The interactive Swagger UI at the /docs endpoint is the best way to explore the API.
| Method | Endpoint | Description |
|---|---|---|
GET |
/users/ |
Fetches all users and their wallet balance. |
POST |
/users/ |
Creates a new user and their wallet. |
POST |
/wallets/update/ |
Adds or deducts funds from a user's wallet. |
GET |
/users/{user_id}/transactions/ |
Gets all transactions for a specific user. |
This project is configured with a complete Continuous Integration and Continuous Deployment (CI/CD) pipeline using GitHub Actions.
- Trigger: A
git pushto themainbranch. - Action: The GitHub Actions workflow automatically connects to the AWS EC2 instance via SSH.
- Deployment: The script on the server then performs the following:
- Pulls the latest code from the
mainbranch. - Installs any new dependencies from
requirements.txt. - Restarts the
Gunicornapplication service to apply the changes.
- Pulls the latest code from the
This ensures that the live application is always up-to-date with the latest version of the code.
To set up and run this project on your local machine, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/user-wallet.git cd user-wallet -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a file named
.envin the project root. - Copy the contents of
.env.exampleand fill in your local database credentials.
- Create a file named
-
Run the application:
uvicorn app.main:app --reload
The API will be available at
http://127.0.0.1:8000.
Akshat Balyan – aksbal2005@gmail.com