Account Service
Purpose
Financial account lifecycle — creation, status management, and balance projection (not authoritative).
Responsibilities
- Account creation and closure
- Account status management
- Balance projection (derived from ledger events)
- Account metadata (currency, type)
Non-Responsibilities
- Authoritative balances (Ledger Service)
- Payment execution (Payment Service)
- Ledger posting
APIs
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/v1/accounts | Bearer | Create account |
| GET | /api/v1/accounts/{id} | Bearer | Get account |
| GET | /api/v1/accounts/{id}/balance | Bearer | Current balance |
| PUT | /api/v1/accounts/{id}/status | ADMIN | Update status |
Database
| Table | Key Columns | Description |
|---|---|---|
| accounts | id, customer_id, type, currency, status | Account records |
| balance_snapshots | account_id, available, pending, updated_at | Projected balances |
Kafka
Produces: AccountCreated, AccountStatusChanged
Consumes: LedgerEntryCreated (update balance projection)
Dependencies
Sync: Customer Service, Ledger Service Async: Consumes ledger events
Failure Handling
- Stale balance → reconcile from ledger on read
- Account not found → 404
Scaling
Partition by customer_id. Read replicas for balance queries.
Security
Customers access own accounts. ADMIN for status changes.
Observability
Metrics: account_created_total, balance_query_latency.