How varunsahu258/ledgerpay works
LedgerPay is a money-transfer API whose main workflow accepts validated account or transfer requests, delegates business operations to services, and persists state in PostgreSQL. Transfers and reversals use idempotency, ordered balance locking, ledger postings, and audit records; account history and reconciliation provide inspection and drift detection. The browser console is served by the API, while a demo seeder exercises the public HTTP endpoints. Some subsystem links are based on README documentation or the SOURCE INDEX because their implementations were not excerpted.
Main entry points: main.py FastAPI app · routes.py HTTP routes · entities.py Ledger entities · transfers.py Transfer service
Components 19
API and clients
- Browser console
app/static/console/app.js - FastAPI app
app/main.py - HTTP routes
app/api/routes.py - Account schemas
app/schemas/account.py - Transfer schemas
app/schemas/transfer.py
Money operations
- Account service
app/services/accounts.py - Transfer service
app/services/transfers.py - Reversal service
app/services/reversals.py - History service
app/services/transactions.py - Reconciliation
app/services/reconciliation.py - Balance locking
app/services/balance_locking.py - Reconciliation CLI
app/reconcile.py
Persistence and invariants
- Async DB sessions
app/db.py - Ledger entities
app/models/entities.py - PostgreSQL
Demo and safety
- Settings
app/core/config.py - Demo safeguards
app/core/demo_safety.py - Demo seeder
app/demo.py
Other components
- API client
Connections 30
- API client → FastAPI app: HTTP requests
README.md - Browser console → FastAPI app: HTTP requests
README.md - FastAPI app → HTTP routes: registers routes
app/main.py - FastAPI app → Demo safeguards: limits writes
app/main.py - FastAPI app → Async DB sessions: health check
app/main.py - FastAPI app → Browser console: serves console
app/main.py - HTTP routes → Account service: calls
app/api/routes.py - HTTP routes → Transfer service: calls
app/api/routes.py - HTTP routes → Reversal service: calls
app/api/routes.py - HTTP routes → History service: calls
app/api/routes.py - HTTP routes → Account schemas: validates and returns
app/api/routes.py - HTTP routes → Transfer schemas: validates and returns
app/api/routes.py - HTTP routes → Async DB sessions: gets session
app/api/routes.py - Account service → Ledger entities: queries and writes
app/services/accounts.py - Transfer service → Ledger entities: writes transfer ledger
app/services/transfers.py - Transfer service → Balance locking: locks balances
app/services/transfers.py - Reversal service → Ledger entities: writes reversal ledger
app/services/reversals.py - Reversal service → Balance locking: locks balances
app/services/reversals.py - History service → Ledger entities: reads history
app/services/transactions.py - Reconciliation → Ledger entities: checks balances
app/services/reconciliation.py - Reconciliation CLI → Reconciliation: runs checks
app/reconcile.py - Async DB sessions → PostgreSQL: connects
app/db.py - Transfer service → PostgreSQL: persists transaction
app/services/transfers.py - Reversal service → PostgreSQL: persists reversal
app/services/reversals.py - Settings → Async DB sessions: configures engine
app/db.py - FastAPI app → Settings: reads settings
app/main.py - FastAPI app → Settings: configures demo limits
app/main.py - Demo seeder → FastAPI app: calls public API
app/demo.py - Demo seeder → PostgreSQL: funds demo accounts
app/demo.py - Demo seeder → Settings: reads settings
app/demo.py