Hi! I'm Sattwik Sarkar, and this is my personal project: a full-stack payment simulation app built with FastAPI (Python backend) and a simple HTML/CSS/JS frontend. I created this project to learn, experiment, and demonstrate how a modern payment API works from scratch.
I wanted to understand how payment systems work under the hood, practice building REST APIs, and get hands-on with Docker, testing, and frontend integration. This project helped me learn about authentication, database transactions, and background processing.
- Backend: FastAPI, SQLAlchemy, Pydantic
- Database: SQLite (default), PostgreSQL (optional)
- Task Queue: Celery (optional)
- Frontend: HTML, CSS, JavaScript
- Testing: Pytest
- Containerization: Docker, Docker Compose
- User registration with API key authentication
- Payment creation, completion, and cancellation
- Payment history dashboard
- Background email receipts (Celery)
- RESTful API with OpenAPI docs
- Dockerized setup for easy deployment
- Pytest-based test suite
# Register a user
curl -X POST http://localhost:8000/users/ -H "Content-Type: application/json" -d '{"name": "Alice", "balance": 100}'
# Create a payment
curl -X POST http://localhost:8000/payments/ -H "Content-Type: application/json" -H "x-api-key: <your_api_key>" -d '{"payer_id": 1, "payee_id": 2, "amount": 10, "currency": "USD"}'- Add OAuth2 authentication
- Integrate Stripe or Razorpay for real payments
- Add user profile pictures
- Improve frontend UI/UX
- Add admin dashboard
- Deploy to cloud (Azure, Heroku, etc.)
This app lets you:
- Register as a user (with a name and starting balance)
- Get a unique API key for authentication
- Log in using your API key
- View your dashboard (balance and payment history)
- Send payments to other users
- See all payments you've made or received
- (Optionally) Send payment receipts via background tasks (Celery)
Everything is designed for easy local setup, quick prototyping, and clear code structure. You can run it with Docker or just Python, and the frontend is pure HTML/CSS/JS for simplicity.
βββ payment_api/ # FastAPI backend
β βββ main.py # App entrypoint
β βββ models.py # SQLAlchemy models
β βββ routes/ # API routes (users, payments)
β βββ schemas.py # Pydantic schemas
β βββ database.py # DB setup
β βββ config.py # Settings
β βββ tasks.py # Celery tasks (optional)
β βββ ...
βββ frontend/ # HTML/CSS/JS frontend
β βββ index.html # Main UI
β βββ style.css # Styles
β βββ app.js # JS logic
βββ tests/ # Pytest tests
βββ requirements.txt # Python dependencies
βββ dev-requirements.txt # Dev/test dependencies
βββ Dockerfile # Backend Dockerfile
βββ docker-compose.yml # Multi-service orchestration
βββ .env.example # Example environment config
βββ .gitignore # Ignore secrets, DB, etc.
βββ README.md # Project documentation
git clone https://github.com/Sattwik999/FinPal-a-Payment-Simulation-Python-API.git
cd FinPal-a-Payment-Simulation-Python-API- Copy
.env.exampleto.env:cp .env.example .env
- Edit
.envas needed. For quick testing, SQLite is the default.
pip install -r requirements.txtuvicorn payment_api.main:app --reload- The API runs at http://localhost:8000
- Interactive docs: http://localhost:8000/docs
- Open
frontend/index.htmlin your browser. - Use the UI to register, log in, create payments, and view history.
pip install -r dev-requirements.txt
pytestdocker-compose up --build- This starts backend, database, Redis, and Celery worker (if configured).
POST /users/- Register a new userGET /users- List all usersGET /users/{user_id}- Get user by IDPOST /payments/- Create a paymentGET /payments/- List payments for logged-in user
See http://localhost:8000/docs for full API documentation.
- Register a user and copy your API key.
- Log in with your API key.
- Create payments by entering the recipient's name and amount.
- View your payment history in the dashboard.
If you want to contribute:
- Fork the repo and create your feature branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -am "Add new feature" - Push to your branch:
git push origin feature/your-feature
- Open a Pull Request on GitHub.
Sattwik Sarkar
This project is for educational and demonstration purposes. See LICENSE for details.
For questions or issues, open an issue on GitHub or contact me directly.
