Skip to content
MikeRider27Public

About

Digital banking platform: multi-currency accounts, deposits, withdrawals, transfers and an auditable statement. FastAPI + React.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

FinTech

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

Quick start

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).

Architecture

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

Interface

  • 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.

Financial core guarantees

  • 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. A CHECK (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-Key header makes retries (double click, network error) return the original transaction instead of duplicating it. The frontend generates one key per attempt.

Security

  • Mandatory secrets: docker compose refuses to start without POSTGRES_PASSWORD and SECRET_KEY; in production the 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 via LOGIN_MAX_FAILURES and LOGIN_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-Key with different data returns 422 instead 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-store on the API.
  • Containers: backend and Nginx run as non-root with cap_drop: ALL and no-new-privileges; backend and database only listen on 127.0.0.1.

API

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.

Development without Docker

# 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:5173

New migration after changing models.py: alembic revision --autogenerate -m "description".

Before going to production

  • Set ENVIRONMENT=production and random secrets (the backend refuses to start with a weak SECRET_KEY).
  • Serve everything behind HTTPS (then enable the HSTS header in Frontend/security-headers.conf) and stop publishing ports 8000 and the database port in docker-compose.yml.
  • With several backend replicas, move the login lockout to Redis (it currently lives in memory).
  • Recommended next steps: refresh tokens or httpOnly cookies instead of localStorage, 2FA, KYC and per-user daily limits, and deposits/withdrawals backed by a real payment gateway (today they are recorded directly).

Author

Miguel Villalba (MikeRider27) · mike.mavc27@gmail.com

License

Released under the MIT License.

About

Digital banking platform: multi-currency accounts, deposits, withdrawals, transfers and an auditable statement. FastAPI + React.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages