English · Español
Digital banking platform: multi-currency accounts, deposits, withdrawals, peer-to-peer transfers and an auditable account statement.
| Layer | Technology |
|---|---|
| Frontend | React 19 + Vite 8 + React Router 8, served by Nginx 1.30 |
| Backend | Python 3.14 + FastAPI + SQLAlchemy 2 + Alembic |
| Database | PostgreSQL 18 |
| Infra | Docker Compose |
cp .env.example .env # required: set POSTGRES_PASSWORD and SECRET_KEY (openssl rand -hex 32)
docker compose up -d --build| Service | URL |
|---|---|
| Web app | http://localhost:3500 |
| API docs (Swagger, dev) | http://localhost:8000/api/docs (this machine only) |
| PostgreSQL (local) | localhost:<DB_PORT> (default 5433; credentials in .env) |
Migrations run automatically when the backend starts. To stop: docker compose down (add -v to also delete the data).
Browser ──► frontend (unprivileged Nginx :8080, published on :3500)
├── / → React SPA
└── /api/* → backend (FastAPI :8000) ──► db (PostgreSQL :5432)
The browser only talks to the frontend; Nginx proxies /api to the backend, so the client code contains no backend IPs or URLs. The database sits on an internal network the frontend cannot reach.
Backend/
app/
core/ configuration (environment variables) and security (JWT, bcrypt, login throttling)
routers/ auth, accounts, transactions, dashboard
services/ ledger.py: all money-movement logic
models.py User, Account, Transaction, LedgerEntry
schemas.py input/output validation (Pydantic)
alembic/ migrations
Frontend/
src/
pages/ Login, Register, Dashboard, Accounts, AccountDetail, Operations, Transactions
components/ Layout (sidebar), UI kit, SVG icons, cash-flow chart, footer
api.js HTTP client
auth.jsx session context
theme.js light/dark theme
- Sidebar navigation (drawer on mobile) and light/dark theme that follows the system or the user's choice.
- Dashboard with total balance, 30-day net flow, quick actions and an 8-week cash-flow chart.
- Accounts shown as bank cards; detail view with statement and actions (copy number, freeze, close).
- Operations form with a live summary of the resulting balance.
- Self-hosted Inter font and inline SVG icons: no external requests, compatible with the strict CSP.
- Precision: amounts are stored as
NUMERIC(18,2)and travel as strings in JSON; floats are never used. - Atomicity: every operation is a single database transaction; it is applied completely or not at all.
- Concurrency: accounts are locked with
SELECT … FOR UPDATE, always in the same order, which prevents overdrafts and deadlocks under concurrent transfers. ACHECK (balance >= 0)constraint acts as the last line of defense. - Audit trail: every balance change creates an immutable
LedgerEntry(debit/credit, amount and resulting balance) with a monotonic posting sequence. - Idempotency: the
Idempotency-Keyheader makes retries (double click, network error) return the original transaction instead of duplicating it. The frontend generates one key per attempt.
- Mandatory secrets:
docker composerefuses to start withoutPOSTGRES_PASSWORDandSECRET_KEY; inproductionthe backend rejects keys shorter than 32 characters and does not publish/api/docs. - Brute force: Nginx limits
/api/auth/*to 10 requests/min per IP and the API to 20 req/s; the backend also locks an email for 15 minutes after 10 failed attempts (configurable viaLOGIN_MAX_FAILURESandLOGIN_LOCKOUT_MINUTES). - Enumeration: login always runs bcrypt even when the email does not exist (constant time), and transfers do not reveal the status of other users' accounts.
- Strict idempotency: reusing an
Idempotency-Keywith different data returns422instead of the previous transaction. - Validation errors: never echo the submitted value (avoids reflecting passwords).
- Headers: strict CSP,
X-Frame-Options: DENY,Permissions-Policy,Cache-Control: no-storeon the API. - Containers: backend and Nginx run as non-root with
cap_drop: ALLandno-new-privileges; backend and database only listen on127.0.0.1.
Every route (except register, login and health) requires Authorization: Bearer <token>.
| Method | Route | Description |
|---|---|---|
| POST | /api/auth/register |
Create user (returns a token) |
| POST | /api/auth/login |
Sign in |
| GET | /api/auth/me |
Current user |
| GET | /api/accounts |
List accounts |
| POST | /api/accounts |
Open account {alias, currency} |
| GET | /api/accounts/currencies |
Supported currencies |
| GET | /api/accounts/{id} |
Account detail |
| PATCH | /api/accounts/{id} |
Change alias or status (ACTIVE/FROZEN/CLOSED) |
| GET | /api/accounts/{id}/statement |
Paginated statement |
| POST | /api/transactions/deposit |
Deposit |
| POST | /api/transactions/withdraw |
Withdrawal |
| POST | /api/transactions/transfer |
Transfer to an account number |
| GET | /api/transactions |
History (account_id, type, limit, offset) |
| GET | /api/dashboard/summary |
Per-currency summary and latest activity |
| GET | /api/health |
Service and database status |
Rules: transfers require the same currency on both accounts; frozen or closed accounts cannot operate; an account can only be closed with a zero balance.
# Backend (with the docker compose PostgreSQL running on the DB_PORT from .env)
cd Backend
pip install -r requirements.txt
export DATABASE_URL=postgresql+psycopg://fintech:<POSTGRES_PASSWORD>@localhost:5433/fintech
alembic upgrade head
uvicorn app.main:app --reload
# Frontend (proxies /api → localhost:8000)
cd Frontend
npm install
npm run dev # http://localhost:5173New migration after changing models.py: alembic revision --autogenerate -m "description".
- Set
ENVIRONMENT=productionand random secrets (the backend refuses to start with a weakSECRET_KEY). - Serve everything behind HTTPS (then enable the HSTS header in
Frontend/security-headers.conf) and stop publishing ports8000and the database port indocker-compose.yml. - With several backend replicas, move the login lockout to Redis (it currently lives in memory).
- Recommended next steps: refresh tokens or
httpOnlycookies instead oflocalStorage, 2FA, KYC and per-user daily limits, and deposits/withdrawals backed by a real payment gateway (today they are recorded directly).
Miguel Villalba (MikeRider27) · mike.mavc27@gmail.com
Released under the MIT License.