How hmdank/ourportfolios works
Purpose and Runtime
OurPortfolios is a stock-analysis platform for investor portfolio research: selecting securities, analyzing individual tickers and industries, comparing instruments, and creating recommendation frameworks. It is a Python Reflex application, started locally with uv run reflex run; Reflex configuration and app composition are centered in rxconfig.py and ourportfolios/ourportfolios.py. An optional PostgreSQL URI is supplied through .env.
Application Composition and Routing
The Reflex app assembles page-level views into a multi-page frontend. Page modules are the primary route boundaries, with reusable visual elements separated from page orchestration:
• ourportfolios/ourportfolios.py
• ourportfolios/pages/landing/index.py
• ourportfolios/pages/analyze/index.py
Likely user flow begins at landing, then moves through security selection, ticker/industry analysis, comparison, and recommendations.
Selection and Search Workflow
The selection experience combines filtering/control UI with page-local state, while shared search and ticker-board state support reusable market-navigation surfaces:
• ourportfolios/pages/select/index.py
• ourportfolios/pages/select/filters.py
• ourportfolios/pages/select/state.py
• ourportfolios/state/search_state.py
• ourportfolios/state/ticker_board_state.py
This creates a boundary between interactive Reflex state/event handling and declarative page components.
Instrument and Financial Analysis
Ticker analysis is decomposed into company identity, metrics, performance, and chart presentation. Financial-statement handling is a cross-cutting state concern, with transformations isolated under utilities:
• ourportfolios/pages/ticker_analysis/index.py
• ourportfolios/pages/ticker_analysis/state.py
• ourportfolios/state/financial_statement_state.py
• ourportfolios/components/financial_statement.py
• ourportfolios/utils/compute_instrument.py
• ourportfolios/utils/preprocessing/financial_statements.py
Data is loaded and normalized before being computed into instrument-level metrics and rendered as cards, statements, and price charts.
Comparison and Portfolio Cart
Comparison uses dedicated controls, cards, and shared comparison state; cart state represents a separate selection/portfolio boundary:
• ourportfolios/pages/compare/index.py
• ourportfolios/pages/compare/controls.py
• ourportfolios/state/comparison_state.py
• ourportfolios/state/cart_state.py
• ourportfolios/components/metric_cards.py
The expected control flow is user selection → stateful comparison/cart updates → rendered comparative metrics.
Recommendation Frameworks
Recommendations are modeled as user-managed frameworks, with dialogs for creating or editing framework definitions and state for their lifecycle:
• ourportfolios/pages/recommend/index.py
• ourportfolios/pages/recommend/state.py
• ourportfolios/pages/recommend/framework_cards.py
• ourportfolios/state/framework_state.py
This is the main extensibility point for converting analysis inputs into personalized portfolio criteria.
Shared UI, Data Access, and External Boundaries
Reusable components provide consistent navigation, dialogs/drawers, charts, cards, and loading behavior:
• ourportfolios/components/navbar.py
• ourportfolios/components/dialog.py
• ourportfolios/components/price_chart.py
• assets/chart.js
Data-access/query concerns are isolated from page code in ourportfolios/utils/load_data.py and ourportfolios/utils/generate_query.py; PostgreSQL is the explicit external persistence option. Text/event preprocessing and a scheduler suggest prepared market/news-derived content and periodic background-oriented work:
• ourportfolios/utils/preprocess_texts.py
• ourportfolios/utils/preprocessing/events_texts.py
• ourportfolios/utils/scheduler.py
Main entry points: ourportfolios.py App composition · select/index.py Security selection · ticker_analysis/index.py Ticker analysis · compare/index.py Comparison
Components 27
Reflex Runtime
- Reflex config · Local Reflex runtime configuration.
rxconfig.py - App composition · Registers and assembles multi-page views.
ourportfolios/ourportfolios.py
Page Routes
- Landing
ourportfolios/pages/landing/index.py - Security selection
ourportfolios/pages/select/index.py - Ticker analysis
ourportfolios/pages/ticker_analysis/index.py - Comparison
ourportfolios/pages/compare/index.py - Recommendations
ourportfolios/pages/recommend/index.py - Selection filters
ourportfolios/pages/select/filters.py - Comparison controls
ourportfolios/pages/compare/controls.py
Interactive State
- Ticker state · Coordinates ticker analysis interactions.
ourportfolios/pages/ticker_analysis/state.py - Search state
ourportfolios/state/search_state.py - Ticker board state
ourportfolios/state/ticker_board_state.py - Comparison state
ourportfolios/state/comparison_state.py - Portfolio cart state
ourportfolios/state/cart_state.py - Framework state · Manages recommendation framework lifecycle.
ourportfolios/state/framework_state.py - Financial statement state · Cross-cutting financial-statement handling.
ourportfolios/state/financial_statement_state.py
Data & Analysis
- Query and data loading · Builds queries and loads market data outside page code.
ourportfolios/utils/load_data.py - Statement normalization
ourportfolios/utils/preprocessing/financial_statements.py - Instrument metrics · Computes instrument-level financial metrics.
ourportfolios/utils/compute_instrument.py - Text and event preparation · Prepares market or news-derived content for periodic work.
ourportfolios/utils/preprocess_texts.py - Scheduler
ourportfolios/utils/scheduler.py - PostgreSQL · Optional database configured through .env.
Shared UI
- Shared navigation and dialogs
ourportfolios/components/navbar.py - Financial statement view
ourportfolios/components/financial_statement.py - Price chart · Uses a charting asset for price presentation.
ourportfolios/components/price_chart.py - Chart asset
assets/chart.js - Metric cards
ourportfolios/components/metric_cards.py
Connections 26
- Reflex config → App composition: configures
- App composition → Landing: routes
- App composition → Security selection: routes
- App composition → Ticker analysis: routes
- App composition → Comparison: routes
- App composition → Recommendations: routes
- Security selection → Selection filters: composes
- Security selection → Search state: searches through
- Security selection → Ticker board state: uses
- Ticker analysis → Ticker state: drives
- Ticker state → Financial statement state: uses
- Financial statement state → Statement normalization: normalizes with
- Statement normalization → Instrument metrics: feeds
- Instrument metrics → Ticker state: provides metrics
- Ticker analysis → Financial statement view: renders
- Ticker analysis → Price chart: renders
- Price chart → Chart asset: uses
- Comparison → Comparison controls: composes
- Comparison → Comparison state: updates
- Comparison → Portfolio cart state: manages selections
- Comparison state → Metric cards: renders metrics
- Recommendations → Framework state: manages
- Query and data loading → PostgreSQL: queries
- Query and data loading → Statement normalization: supplies raw data
- Scheduler → Text and event preparation: runs periodically
- Shared navigation and dialogs → Landing: supports navigation