How tylerhat/hatfield_financial works
Hatfield Financial is a React financial-analysis dashboard backed by a Flask API. Users authenticate, inspect a stock’s market and company data, explore recommendations and strategies, and manage watchlists or custom ETF portfolios. The repository also supports Markov regime analysis and historical portfolio backtests. The graph follows documented routes and the sampled React, auth, feature, and Lambda code; several route implementations were not sampled, so their internal wiring is intentionally left broad.
Main entry points: App.js Dashboard app · recommendations.py Recommendation routes · data_fetcher.py Market data fetch · walk_forward.py Walk-forward backtest
Components 32
Dashboard
- Dashboard app
Frontend/src/App.js - Sign-in UI
Frontend/src/components/AuthPage.js - Auth context
Frontend/src/AuthContext.js - API client
Frontend/src/api.js - Stock views
Frontend/src/components/StockChart.js - Recommendations UI
Frontend/src/components/Recommendations.js - ETF dashboard
Frontend/src/components/CustomEtfPanel.js
API
- Flask API
Backend/app.py - Auth routes
Backend/routes/auth_routes.py - Stock data routes
Backend/routes/stock_data.py - Stock info routes
Backend/routes/stock_info.py - Recommendation routes
Backend/routes/recommendations.py - Markov routes
Backend/routes/markov.py - Backtest routes
Backend/routes/backtest.py - User data routes
Backend/routes/user_data.py - Custom ETF routes
Backend/routes/custom_etf.py - Strategy routes
Backend/routes/strategies
Investment analysis
- Market data fetch
Backend/data_fetcher.py - Price features
Backend/services/row_features.py - Regime analysis
Backend/services/markov/analyze.py - Recommendation data
Backend/routes/recommendations.py
Custom ETFs
- Rebalance engine
Backend/services/custom_etf/rebalance_core.py - Portfolio simulator
Backend/services/custom_etf/simulator.py - Walk-forward backtest
Backend/services/custom_etf/walk_forward.py
Identity and state
- Application database
Backend/models.py - Recommendation cache
Backend/cache.py
Scheduled jobs
- Rebalance trigger
Backend/lambda_rebalance_handler.py - Recommendation precompute
Backend/lambda_handler.py
Other components
- Investor
- Market data provider
- EventBridge scheduler
- S3 object store
Connections 30
- Investor → Dashboard app: uses
- Dashboard app → Sign-in UI: shows
- Sign-in UI → Auth context: submits credentials
- Auth context → API client: sends requests
- Dashboard app → API client: requests data
- API client → Flask API: HTTP API
- Flask API → Auth routes: registers routes
- Auth routes → Application database: reads and writes users
- Dashboard app → Stock views: renders analysis
- Dashboard app → Recommendations UI: renders recommendations
- Dashboard app → ETF dashboard: renders portfolios
- Stock data routes → Market data fetch: fetches market data
- Stock info routes → Market data fetch: fetches stock info
- Recommendation routes → Market data fetch: fetches prices
- Recommendation routes → Price features: computes features
- Recommendation routes → Regime analysis: computes regimes
- Recommendation routes → Recommendation cache: reads and writes
- Markov routes → Regime analysis: analyzes regimes
- Strategy routes → Market data fetch: uses market data
- Custom ETF routes → Rebalance engine: runs rebalance
- Custom ETF routes → Portfolio simulator: runs simulations
- Backtest routes → Walk-forward backtest: runs backtest
- Walk-forward backtest → Price features: builds historical features
- Walk-forward backtest → Rebalance engine: replays decisions
- User data routes → Application database: reads and writes
- EventBridge scheduler → Rebalance trigger: triggers
- Rebalance trigger → Custom ETF routes: requests rebalance
- EventBridge scheduler → Recommendation precompute: triggers
- Recommendation precompute → Recommendation routes: fetches recommendation data
- Recommendation precompute → S3 object store: writes results