How dashfin-fardb/financial-asset-relationship-db works
1. Overall shape
This repo is a hybrid application with two user-facing paths: a legacy Gradio app started from app.py, and a newer Next.js frontend + FastAPI backend split across frontend/ and api/. Both sit on top of the same financial-asset relationship domain.
2. Primary request/response flow
In the modern path, the browser talks to the Next.js UI on the frontend side, which calls the FastAPI API in api/main.py. The API serves asset graph data, metrics, and visualization payloads through routers such as api/routers/assets.py and api/routers/graph.py.
3. Core domain engine
The architectural center is src/logic/asset_graph.py. This is where assets are loaded into a graph, relationships are discovered or added, strengths are calculated, and network metrics are produced. The README indicates this engine also produces the 3D visualization data consumed by the UIs.
4. Domain model boundary
src/models/financial_models.py defines the financial entities and enums that represent the business domain: equities, bonds, commodities, currencies, and regulatory events. This layer is the shared vocabulary used by the graph engine, data layer, and report generation.
5. Data ingestion and persistence
The data boundary lives in src/data/. sample_data.py seeds demo content, real_data_fetcher.py suggests optional external data ingestion, and repository.py plus database.py/db_models.py abstract persistence. The repo also includes asset_graph.db and migrations/001_initial.sql, which indicate a lightweight local database schema and migration path.
6. Visualization subsystem
src/visualizations/ contains the rendering logic for graph and metric views. The files are split by concern: graph layout/positions/traces, validation, directional arrows, and metric visuals. This is the presentation transformation layer that turns graph state into plot-ready structures, likely using Plotly as noted in the README.
7. Reporting subsystem
src/reports/ generates schema and integration reports, including schema_report.py and schema_report_generator.py. This looks like a non-UI output path used for documentation, validation, and possibly API exposure through the schema-report router in src/api/routers/schema_report.py and the analogous api/ package.
8. API-specific infrastructure
The api/ package contains cross-cutting concerns for the backend: auth.py, cors_utils.py, database.py, graph_lifecycle.py, and models.py. That suggests the FastAPI service is responsible not just for endpoints, but also for access control, CORS policy, and graph/resource lifecycle management.
9. Frontend structure
frontend/app/ is a standard Next.js app-router structure with reusable components such as AssetList, MetricsDashboard, and NetworkVisualization. frontend/app/lib/api.ts is the likely boundary where the UI integrates with the FastAPI backend, while frontend/app/types/api.ts defines the contract shape used by the client.
10. Legacy interface
app.py is the original top-level entry point described in the README as a Gradio-based interface. Architecturally, it provides an alternative UI path over the same core financial graph logic, separate from the newer web stack.
11. Validation and test boundary
The repo has a strong test split: Python unit/integration tests under tests/, API and database tests at the root, and frontend Jest tests under frontend/__tests__/. That indicates most subsystem boundaries are explicitly verified: domain logic, persistence, API contracts, and UI components.
12. Operational/tooling layer
The repository includes extensive CI/CD and security automation under .github/workflows/, plus Docker, deployment, and quality tooling. These do not define runtime architecture, but they are important operational boundaries because they validate, scan, and package the Python backend, the frontend, and container deployments.
13. Recommended diagram emphasis
An accurate architecture diagram should show: data sources / sample data / DB → repository and graph engine → metrics, relationships, and 3D visualization data → FastAPI and/or Gradio UI → Next.js frontend. The key split is between the shared domain core and the two presentation stacks built on top of it.
Main entry points: main.py API app · asset_graph.py Asset graph · api.ts API client · page.tsx Next.js app
Components 20
Core domain
Shared financial-asset graph engine and domain model
- Asset graph · Loads assets, discovers relationships, computes strength and metrics, and prepares visualization data
src/logic/asset_graph.py - Financial models · Equities, bonds, commodities, currencies, and event vocabularies
src/models/financial_models.py - Sample data · Demo asset and relationship fixtures
src/data/sample_data.py - Data fetcher · Optional external data acquisition layer
src/data/real_data_fetcher.py - Repository · Abstracts reads and writes for graph state
src/data/repository.py - DB layer · Database access and connection support
src/data/database.py - DB models · Database schema objects for stored graph data
src/data/db_models.py
Backend services
FastAPI services and data access around the shared core
- API app · Backend application entrypoint
api/main.py - Assets API · Asset and relationship endpoints
api/routers/assets.py - Graph API · Graph payload and visualization endpoints
api/routers/graph.py - Auth · Backend access control boundary
api/auth.py - API DB · Backend database wiring
api/database.py - Lifecycle · Graph/resource lifecycle management
api/graph_lifecycle.py - Schema reports · Schema and integration report generation
src/reports/schema_report.py
Frontend UI
Next.js browser application and client boundary
- Next.js app · Browser-facing application shell
frontend/app/page.tsx - Network view · Asset network visualization component
frontend/app/components/NetworkVisualization.tsx - Metrics dashboard · UI for graph metrics and summaries
frontend/app/components/MetricsDashboard.tsx - Asset list · Asset browsing and selection component
frontend/app/components/AssetList.tsx - API client · Frontend-to-backend request layer
frontend/app/lib/api.ts
Legacy/ops
Alternate UI entrypoint and repository operations
- Legacy app · Original top-level user interface entrypoint
app.py
Connections 23
- Sample data → Repository: seed · Seeds the local persistence layer
- Data fetcher → Repository: ingest · Brings external data into storage
- Repository → DB layer: stores · Uses the database abstraction for persistence
- DB layer → DB models: maps · Persists through schema models
- Repository → Asset graph: loads · Provides assets and relations to the graph engine
- Financial models → Asset graph: types · Shared domain vocabulary for graph operations
- Asset graph → Schema reports: reports · Feeds schema and integration reporting
- Asset graph → Assets API: serves · Asset data exposed through API routes
- Asset graph → Graph API: serves · Graph and visualization payloads exposed through API routes
- API app → Assets API: mounts · Registers asset router
- API app → Graph API: mounts · Registers graph router
- API app → Auth: uses · Applies authentication and access control
- API app → API DB: uses · Initializes backend database wiring
- API app → Lifecycle: uses · Manages graph and resource lifecycle
- Next.js app → API client: calls · Browser UI requests backend data
- API client → API app: requests · Client boundary to FastAPI service
- Next.js app → Network view: renders · Shows graph visualization
- Next.js app → Metrics dashboard: renders · Shows metrics views
- Next.js app → Asset list: renders · Shows asset browsing UI
- Network view → API client: loads data · Consumes graph payloads
- Metrics dashboard → API client: loads data · Consumes metric payloads
- Asset list → API client: loads data · Consumes asset listings
- Legacy app → Asset graph: uses · Legacy UI path built on the same domain core