Big refactoring
This commit is contained in:
30
.kiro/steering/product.md
Normal file
30
.kiro/steering/product.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Product Overview
|
||||
|
||||
Signal Dashboard is an investing-signal platform for NASDAQ stocks that surfaces optimal trading opportunities through multi-dimensional scoring.
|
||||
|
||||
## Core Philosophy
|
||||
|
||||
Don't predict price. Find the path of least resistance, key support/resistance zones, and asymmetric risk:reward setups.
|
||||
|
||||
## Key Features
|
||||
|
||||
- Multi-dimensional scoring engine (technical, S/R quality, sentiment, fundamental, momentum)
|
||||
- Risk:Reward scanner with ATR-based stops (default 3:1 threshold)
|
||||
- Support/Resistance detection with strength scoring and merge-within-tolerance
|
||||
- Sentiment analysis with time-decay weighted scoring (Gemini 2.0 Flash with search grounding)
|
||||
- Auto-populated watchlist (top-10 by composite score) + manual entries (cap: 20)
|
||||
- Interactive candlestick chart with S/R overlays
|
||||
- JWT auth with admin role and user access control
|
||||
- Scheduled jobs: OHLCV collection, sentiment polling, fundamentals fetch, R:R scanning
|
||||
|
||||
## Data Providers
|
||||
|
||||
- Alpaca: OHLCV price data
|
||||
- Gemini 2.0 Flash: Sentiment analysis via search grounding
|
||||
- Financial Modeling Prep: Fundamental data (P/E, revenue growth, earnings surprise, market cap)
|
||||
|
||||
## User Roles
|
||||
|
||||
- Admin: Full access including user management, job control, data cleanup, system settings
|
||||
- User: Access to watchlist, scanner, rankings, ticker details (when has_access=true)
|
||||
- Registration: Configurable via admin settings
|
||||
87
.kiro/steering/structure.md
Normal file
87
.kiro/steering/structure.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# Project Structure
|
||||
|
||||
## Backend Architecture
|
||||
|
||||
```
|
||||
app/
|
||||
├── main.py # FastAPI app, lifespan, router registration
|
||||
├── config.py # Pydantic settings from .env
|
||||
├── database.py # Async SQLAlchemy engine + session factory
|
||||
├── dependencies.py # DI: DB session, auth guards (require_access, require_admin)
|
||||
├── exceptions.py # Custom exception hierarchy (ValidationError, NotFoundError, etc.)
|
||||
├── middleware.py # Global error handler → JSON envelope
|
||||
├── cache.py # LRU cache with per-ticker invalidation
|
||||
├── scheduler.py # APScheduler job definitions
|
||||
├── models/ # SQLAlchemy ORM models
|
||||
├── schemas/ # Pydantic request/response schemas
|
||||
├── services/ # Business logic layer
|
||||
├── providers/ # External data provider integrations
|
||||
└── routers/ # FastAPI route handlers
|
||||
```
|
||||
|
||||
## Frontend Architecture
|
||||
|
||||
```
|
||||
frontend/src/
|
||||
├── App.tsx # Route definitions
|
||||
├── main.tsx # React entry point
|
||||
├── api/ # Axios API client modules (one per resource)
|
||||
├── components/
|
||||
│ ├── admin/ # User table, job controls, settings, data cleanup
|
||||
│ ├── auth/ # Protected route wrapper
|
||||
│ ├── charts/ # Canvas candlestick chart
|
||||
│ ├── layout/ # App shell, sidebar, mobile nav
|
||||
│ ├── rankings/ # Rankings table, weights form
|
||||
│ ├── scanner/ # Trade table
|
||||
│ ├── ticker/ # Sentiment panel, fundamentals, indicators, S/R overlay
|
||||
│ ├── ui/ # Badge, toast, skeleton, score card, confirm dialog
|
||||
│ └── watchlist/ # Watchlist table, add ticker form
|
||||
├── hooks/ # React Query hooks (one per resource)
|
||||
├── lib/ # Types, formatting utilities
|
||||
├── pages/ # Page components (Login, Register, Watchlist, Ticker, Scanner, Rankings, Admin)
|
||||
├── stores/ # Zustand auth store
|
||||
└── styles/ # Global CSS with glassmorphism classes
|
||||
```
|
||||
|
||||
## Key Patterns
|
||||
|
||||
### Backend
|
||||
|
||||
- **Layered architecture**: Router → Service → Model
|
||||
- **Dependency injection**: FastAPI Depends() for DB session and auth
|
||||
- **Exception handling**: Custom exceptions caught by global middleware, returned as JSON envelope
|
||||
- **API envelope**: All responses wrapped in `{ status: "success"|"error", data: any, error?: string }`
|
||||
- **Cascade deletes**: Ticker deletion cascades to all related data (OHLCV, sentiment, fundamentals, S/R, scores, trades, watchlist)
|
||||
- **Async everywhere**: All DB operations use async/await with asyncpg
|
||||
|
||||
### Frontend
|
||||
|
||||
- **API client**: Axios interceptors for JWT injection and envelope unwrapping
|
||||
- **Server state**: TanStack React Query with query keys per resource
|
||||
- **Client state**: Zustand for auth (token, user, login/logout)
|
||||
- **Error handling**: ApiError class, toast notifications for mutations
|
||||
- **Protected routes**: ProtectedRoute wrapper checks auth, redirects to /login
|
||||
- **Glassmorphism**: Frosted glass panels, gradient text, ambient glow, mesh gradient background
|
||||
|
||||
## Database Models
|
||||
|
||||
All models inherit from `Base` (SQLAlchemy declarative base):
|
||||
|
||||
- `Ticker`: Registry of tracked symbols (cascade delete parent)
|
||||
- `OHLCVRecord`: Price data (open, high, low, close, volume)
|
||||
- `SentimentScore`: Sentiment analysis results with time-decay
|
||||
- `FundamentalData`: P/E, revenue growth, earnings surprise, market cap
|
||||
- `SRLevel`: Support/Resistance levels with strength scoring
|
||||
- `DimensionScore`: Individual dimension scores (technical, sr_quality, sentiment, fundamental, momentum)
|
||||
- `CompositeScore`: Weighted composite score
|
||||
- `TradeSetup`: Detected R:R setups (long/short, entry, stop, target)
|
||||
- `WatchlistEntry`: User watchlist entries (auto/manual)
|
||||
- `User`: Auth and access control
|
||||
- `Settings`: System-wide configuration
|
||||
|
||||
## Testing
|
||||
|
||||
- Backend tests: `tests/unit/` and `tests/property/`
|
||||
- Frontend tests: `frontend/src/**/*.test.tsx`
|
||||
- Fixtures in `tests/conftest.py`
|
||||
- Hypothesis strategies for property-based testing
|
||||
86
.kiro/steering/tech.md
Normal file
86
.kiro/steering/tech.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# Tech Stack
|
||||
|
||||
## Backend
|
||||
|
||||
- Python 3.12+
|
||||
- FastAPI with Uvicorn
|
||||
- SQLAlchemy 2.0 (async) with asyncpg
|
||||
- PostgreSQL database
|
||||
- Alembic for migrations
|
||||
- APScheduler for scheduled jobs
|
||||
- JWT auth (python-jose, passlib with bcrypt)
|
||||
- Pydantic for validation and settings
|
||||
|
||||
## Frontend
|
||||
|
||||
- React 18 with TypeScript
|
||||
- Vite 5 (build tool)
|
||||
- TanStack React Query v5 (server state)
|
||||
- Zustand (client state, auth)
|
||||
- React Router v6 (SPA routing)
|
||||
- Axios with JWT interceptor
|
||||
- Tailwind CSS 3 with custom glassmorphism design system
|
||||
- Canvas 2D for candlestick charts
|
||||
|
||||
## Testing
|
||||
|
||||
- Backend: pytest, pytest-asyncio, Hypothesis (property-based testing)
|
||||
- Frontend: Vitest
|
||||
- Test database: In-memory SQLite (no PostgreSQL needed for tests)
|
||||
|
||||
## Common Commands
|
||||
|
||||
### Backend
|
||||
|
||||
```bash
|
||||
# Setup
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -e ".[dev]"
|
||||
|
||||
# Database
|
||||
createdb stock_data_backend
|
||||
alembic upgrade head
|
||||
|
||||
# Run
|
||||
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
||||
|
||||
# Test
|
||||
pytest tests/ -v
|
||||
```
|
||||
|
||||
### Frontend
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
|
||||
# Setup
|
||||
npm install
|
||||
|
||||
# Run dev server (proxies /api/v1/ to backend)
|
||||
npm run dev
|
||||
|
||||
# Build
|
||||
npm run build
|
||||
|
||||
# Test
|
||||
npm test # Single run
|
||||
npm run test:watch # Watch mode
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Required in `.env`:
|
||||
- `DATABASE_URL`: PostgreSQL connection string (postgresql+asyncpg://...)
|
||||
- `JWT_SECRET`: Random secret for JWT signing
|
||||
- `ALPACA_API_KEY`, `ALPACA_API_SECRET`: For OHLCV data
|
||||
- `GEMINI_API_KEY`: For sentiment analysis
|
||||
- `FMP_API_KEY`: For fundamental data
|
||||
|
||||
See `.env.example` for full list with defaults.
|
||||
|
||||
## API Documentation
|
||||
|
||||
- Swagger UI: http://localhost:8000/docs
|
||||
- ReDoc: http://localhost:8000/redoc
|
||||
- All endpoints under `/api/v1/`
|
||||
Reference in New Issue
Block a user