# Prism v2 Financial overview app with a FastAPI backend and a Next.js frontend. ## Stack - Backend: Python 3.14+, FastAPI, uvicorn, yfinance, SQLite - Frontend: Node 20+, Next.js App Router, TypeScript ## Layout - `backend/app/` — FastAPI app, services, SQLite watchlist - `backend/tests/` — pytest suite - `frontend/app/` — Next.js App Router; shared types in `frontend/types/api.ts` - `scripts/deploy.sh` — installs dependencies and builds the app for running - `scripts/stack.sh` — local dev start/stop/restart/status helper - `systemd/`, `nginx/` — optional reference templates if you want to wire the app into your own server setup - `design-system/` — brand tokens + Prism UI kit (mirrored to `frontend/public/design-system/`) ## Quick Start ### 1. Clone the repo ```bash git clone cd prism-v2 ``` ### 2. Optional environment setup ```bash cp .env.example .env ``` Current features work without API keys. - `NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8001` for local frontend-to-backend requests - `FMP_API_KEY` and `FINNHUB_API_KEY` are optional ### 3. Run the backend ```bash python -m venv backend/.venv backend/.venv/bin/pip install -r backend/requirements.txt backend/.venv/bin/uvicorn app.main:app --reload --host 127.0.0.1 --port 8001 --app-dir backend ``` Backend health check: ```bash curl http://127.0.0.1:8001/health ``` ### 4. Run the frontend ```bash cd frontend npm install NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8001 npm run dev -- --hostname 127.0.0.1 --port 3001 ``` Open `http://127.0.0.1:3001`. ### 5. Optional one-command build prep If you want the repo to prepare dependencies and build artifacts for you: ```bash ./scripts/deploy.sh ``` This script: - creates `backend/.venv` if needed - installs backend requirements - runs `npm ci` in `frontend/` - runs `npm run build` in `frontend/` It does not start services, install `systemd`, configure `nginx`, or manage deployment hooks. ## Running The Stack ### Development mode Run these in separate terminals: ```bash backend/.venv/bin/uvicorn app.main:app --reload --host 127.0.0.1 --port 8001 --app-dir backend NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8001 npm --prefix frontend run dev -- --hostname 127.0.0.1 --port 3001 ``` Or use: ```bash ./scripts/stack.sh start ``` ### Production-style local run Build first, then run: ```bash ./scripts/deploy.sh backend/.venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8001 --app-dir backend NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8001 npm --prefix frontend run start -- --hostname 127.0.0.1 --port 3001 ``` If you put Prism behind a reverse proxy, leave `NEXT_PUBLIC_API_BASE_URL` empty so browser requests use same-origin `/api/*`. ## API - `GET /health` - `GET /api/search?q=` - `GET /api/market/indices` - `GET /api/tickers/{symbol}/overview` - `GET /api/tickers/{symbol}/history?period=1m|3m|6m|1y|5y` - `GET|POST|DELETE /api/watchlist[/{symbol}]` SQLite lives at `backend/data/prism.db`. The backend seeds a `default` profile on startup. ## Verification ```bash backend/.venv/bin/pytest npm --prefix frontend run lint npm --prefix frontend run build ``` ## Notes - Browser code should not hardcode a localhost API base. `frontend/lib/api.ts` should default to empty so browser requests can use same-origin `/api/*` when you deploy behind your own proxy. - Never commit `.env`, `node_modules/`, `backend/.venv/`, or `backend/data/prism.db`. - Watchlist symbols are normalized to uppercase and capped at 10.