How younghoney/financetoy works
1. Repository shape
- This is a split monorepo: Backend/ is the system of record and business engine, while Frontend/ is a Vue 3 work console.
- The root README makes the key architectural choice explicit: the frontend talks to the backend through a Vite dev proxy on /api, and the backend runs against PostgreSQL.
2. Backend runtime and persistence
- The backend is a Java 21 / Spring Boot 3 application (FinanceToyApplication).
- Persistence is repository-based and likely JPA/Hibernate-backed, with domain entities under feature packages and PostgreSQL as the primary database.
- A Docker Compose setup is used to bring up the database locally; tests also run against PostgreSQL rather than an in-memory database, using a dedicated schema.
3. Domain-first backend structure
- The backend is organized into business domains rather than technical layers:
- order for trade order lifecycle
- ledger for balances and ledger entries
- audit for audit logging
- execution for execution simulation / outcomes
- experiment for scenario runs and metrics
- reconciliation for consistency checks and jobs
- common contains shared infrastructure such as time-base entities, exception handling, OpenAPI config, and data seeding.
4. Order processing flow
- OrderController exposes order-related APIs.
- OrderService appears to be the orchestration point for creating and advancing orders.
- Core order state is modeled with TradeOrder, OrderStatus, OrderSide, and FailureMode.
- Order history and traceability are captured via OrderEvent and OrderEventRepository, suggesting each state transition is persisted as an event rather than only overwriting current state.
5. Financial ledger subsystem
- The ledger is separated from order state, with AccountBalance representing current balance and LedgerEntry representing immutable financial movements.
- LedgerEntryType defines the kinds of balance-affecting operations.
- AccountBalanceRepository and LedgerEntryRepository imply that order execution and account mutation are persisted independently, which is important for auditability and reconciliation.
6. Execution simulation boundary
- The execution package contains ExecutionSimulator, ExecutionDecision, and ExternalExecutionOutcome.
- This suggests the system can simulate how an order would be executed, likely producing deterministic or scenario-driven outcomes for testing or experimentation.
- That simulator is a key boundary between business order flow and external market/exchange behavior, even though no real external broker integration is visible in the tree.
7. Experiment analysis subsystem
- ExperimentController, ExperimentService, and ExperimentRunRepository indicate a separate workflow for running experiments over execution scenarios.
- DTOs such as ExperimentRunRequest, ExperimentRunResponse, and ExperimentSummaryMetrics show that this is an analytical/reporting API, not part of the core transaction path.
- This subsystem likely consumes execution/order data to evaluate outcomes and summarize metrics.
8. Reconciliation and consistency
- ReconciliationController, ReconciliationJob, and ReconciliationService form a batch-oriented consistency layer.
- The presence of ReconciliationResultResponse and a job repository suggests scheduled or manually triggered checks that compare order, ledger, and/or execution state to find discrepancies.
- Architecturally, this is the compensating control for the transactional flow: it validates that persisted artifacts stay aligned.
9. Audit and traceability
- AuditLog, AuditLogRepository, and AuditLogService provide a separate audit trail from order events.
- The DTOs in order/dto include timeline responses for audit, ledger, and order events, which implies the UI can render a unified operational timeline built from multiple subsystems.
- This is a strong signal that observability and traceability are first-class requirements of the application.
10. API and error handling conventions
- Controllers are feature-specific, while shared error handling lives in common.exception.GlobalExceptionHandler.
- ApiError, NotFoundException, and InsufficientFundsException indicate the API returns structured errors for business and lookup failures.
- OpenApiConfig suggests the backend publishes API documentation, likely for the frontend work console and manual exploration.
11. Initialization and demo data
- DataInitializer and DemoAccounts point to startup seeding of sample accounts or baseline data.
- This fits the “toy project” nature of the repo and suggests the system is designed to be runnable locally with meaningful demo state immediately after boot.
12. Frontend role
- The frontend is a compact Vue 3 + Vite application rather than a large SPA platform.
- api.js, constants.js, and main.js imply a thin client that centralizes backend calls and UI configuration.
- Based on the backend DTOs, the frontend likely presents order management plus timelines/summary views for audit, ledger, experiment, and reconciliation results.
13. Testing and development topology
- Backend tests include a single integration test class and a PostgreSQL-backed test schema (financetoy_test), which implies a strong integration-test bias over unit-only validation.
- Development topology is local-first: PostgreSQL container on 5430, backend on 8080, frontend on 5173.
- The architecture therefore centers on a single backend service, one relational database, and a lightweight console UI, with no separate microservices or external brokers evident in the tree.
Main entry points: OrderService.java Order Service · BaseTimeEntity.java Common Core · ReconciliationService.java Reconciliation Service · api.js API Client
Components 18
Backend
Spring Boot domain engine and PostgreSQL persistence
- FinanceToy · Java 21 entrypoint for the backend service
Backend/src/main/java/com/financetoy/FinanceToyApplication.java - Order API · Order lifecycle endpoints and operator views
Backend/src/main/java/com/financetoy/order/OrderController.java - Order Service · Coordinates order creation, progression, and timeline assembly
Backend/src/main/java/com/financetoy/order/OrderService.java - Trade Order · Core order state and status model
Backend/src/main/java/com/financetoy/order/TradeOrder.java - Order Events · Persisted order transitions and event history
Backend/src/main/java/com/financetoy/order/OrderEvent.java - Ledger · Balances and immutable money movements
Backend/src/main/java/com/financetoy/ledger/AccountBalance.java - Execution Simulator · Produces execution decisions and external outcomes
Backend/src/main/java/com/financetoy/execution/ExecutionSimulator.java - Experiment API · Runs scenarios and returns summary metrics
Backend/src/main/java/com/financetoy/experiment/ExperimentController.java - Experiment Service · Executes experiment runs and assembles metrics
Backend/src/main/java/com/financetoy/experiment/ExperimentService.java - Recon API · Triggers reconciliation checks and returns results
Backend/src/main/java/com/financetoy/reconciliation/ReconciliationController.java - Reconciliation Service · Compares order, ledger, and execution state
Backend/src/main/java/com/financetoy/reconciliation/ReconciliationService.java - Audit Log · Separate audit records for operational traceability
Backend/src/main/java/com/financetoy/audit/AuditLog.java - Common Core · Time base, errors, API config, and startup seeding
Backend/src/main/java/com/financetoy/common/BaseTimeEntity.java
Frontend
Vue 3 work console
- Vue Console · Thin operator UI for orders, timelines, and reports
Frontend/src/App.vue - API Client · Centralized backend calls used by the console
Frontend/src/api.js
Data
Relational state and local test schema
- PostgreSQL · Primary persistent store for runtime data
Backend/docker-compose.yml - Test Schema · Dedicated PostgreSQL schema for backend tests
Backend/src/test/resources/test-schema.sql - Compose Stack · Local database bootstrap for development
Backend/docker-compose.yml
Connections 24
- Vue Console → API Client: calls · UI issues backend requests through the client adapter
- API Client → Order API: /api · Vite dev proxy routes console traffic to backend endpoints
- API Client → Experiment API: experiments · Console submits scenario runs and reads summaries
- API Client → Recon API: reconcile · Console can trigger consistency checks
- Order API → Order Service: orchestrates · Controller delegates order workflows to the service layer
- Order Service → Trade Order: updates · Service mutates order state
- Order Service → Order Events: records · Each transition is persisted as an event
- Order Service → Ledger: posts · Execution and balance changes are written independently
- Order Service → Execution Simulator: simulates · Order progression depends on simulated execution outcomes
- Execution Simulator → Ledger: affects · Execution outcomes can drive balance movements
- Experiment API → Experiment Service: orchestrates · API delegates scenario execution and reporting
- Experiment Service → Execution Simulator: runs · Experiments reuse execution simulation as the scenario engine
- Experiment Service → Order Service: consumes · Experiment runs build on order lifecycle data
- Recon API → Reconciliation Service: orchestrates · Controller delegates batch consistency checks
- Reconciliation Service → Order Events: checks · Reconciliation inspects order history
- Reconciliation Service → Ledger: checks · Reconciliation compares financial state
- Reconciliation Service → Audit Log: cross-checks · Audit trail supports discrepancy investigation
- Common Core → Order API: errors · Shared exception handling and API error shaping
- Common Core → Experiment API: errors · Shared exception handling and API error shaping
- Common Core → Recon API: errors · Shared exception handling and API error shaping
- Common Core → FinanceToy: boots · Application startup and demo data initialization
- FinanceToy → PostgreSQL: persists · Backend runtime reads and writes PostgreSQL
- Compose Stack → PostgreSQL: starts · Compose brings up the local database
- Test Schema → PostgreSQL: isolates · Tests use a dedicated PostgreSQL schema