A full-stack banking application built with a FastAPI backend, MongoDB data storage, and a React frontend. Users can create a profile, sign in, open bank accounts, view account details, deposit money, withdraw money, review transaction history, and view account insights.
- Create a user profile and sign in with JWT authentication.
- Store the signed-in user's token in the frontend and send it with protected API requests.
- Open checking or savings accounts.
- View account details and all accounts for the signed-in user.
- Deposit and withdraw money with validation.
- Maintain transaction records for deposits and withdrawals.
- View transaction history, summaries, categories, and banking insights.
- Protect banking routes so users can only access their own accounts.
- Backend: FastAPI, Python, PyJWT, bcrypt
- Frontend: React, Vite, HTML, CSS, JavaScript
- Database: MongoDB / MongoDB Atlas
- Testing and API tools: pytest, Swagger UI, Postman
Frontend UI
->
REST API controllers
->
Service layer
->
Repository layer
->
MongoDB
Project structure:
backend/
app/
controllers/ API route handlers
services/ Business logic
repositories/ MongoDB access
schemas/ Request and response models
data/ Sample seed data
main.py FastAPI app setup
database.py MongoDB connection
scripts/
seed_mongodb.py
tests/
requirements.txt
frontend/
src/
api/ Frontend API helpers and token storage
components/ Shared UI components
hooks/ Route and banking data hooks
pages/ App screens
package.json
Create a local .env file in the repository root using .env.example as a guide:
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster-url>/?retryWrites=true&w=majority&appName=Cluster0
MONGODB_DB_NAME=banking_app
JWT_SECRET_KEY=<your-local-secret>
ACCESS_TOKEN_EXPIRE_MINUTES=60
Install backend dependencies:
pip install -r backend/requirements.txtInstall frontend dependencies:
cd frontend
npm installFrom the repository root, start the backend:
uvicorn backend.app.main:app --reloadThe API runs at:
http://127.0.0.1:8000
In a second terminal, start the frontend:
cd frontend
npm run devThe frontend runs at:
http://127.0.0.1:5173
To load sample users, accounts, and transactions into MongoDB, run:
python backend/scripts/seed_mongodb.pyThe seed data lives in:
backend/app/data/sample_data.py
FastAPI provides interactive API documentation:
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
Swagger can be used to inspect request and response shapes. Postman is useful for saving a collection of test requests, especially requests that include Authorization headers.
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /health |
Check whether the API is running |
| POST | /signup |
Create a user and return an access token |
| POST | /signin |
Sign in and return an access token |
| POST | /logout |
Validate token and sign out on the client |
| POST | /api/accounts |
Create a bank account |
| GET | /api/accounts/{account_id} |
Get account details |
| GET | /api/users/{user_id}/accounts |
Get all accounts for a user |
| POST | /api/accounts/{account_id}/deposit |
Deposit money |
| POST | /api/accounts/{account_id}/withdraw |
Withdraw money |
| GET | /api/accounts/{account_id}/transactions |
Get transaction history |
| GET | /api/accounts/{account_id}/transactions/summary |
Get transaction totals |
| GET | /api/accounts/{account_id}/transactions/categories |
Get withdrawal categories |
| GET | /api/accounts/{account_id}/insights |
Get banking insights |
Protected endpoints require this header:
Authorization: Bearer <access_token>
The frontend stores the JWT returned from signup or signin in local storage under:
banking_app_token
The shared API helper adds the token to protected requests. Signing out clears the token and returns the user to the public home page. On refresh, the app reads the stored token and user id so the signed-in experience can reload.
Run backend tests:
python -m pytest -p no:cacheprovider backend/testsBuild the frontend:
cd frontend
npm run buildRecommended Postman collection requests:
- Signup or signin
- Create account
- Get account details
- Get user accounts
- Deposit
- Withdraw
- Transaction history
- No token returns
401 - Bad token returns
401 - Accessing another user's account returns
403




