1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# 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 <your-repo-url>
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.
|