# 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/`
