File size: 2,192 Bytes
4655dd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Development Guide

## Prerequisites
- Node 22 + Python 3.12
- `pip` + `npm`

## Setup
```bash
# Clone
git clone https://github.com/your-org/safetensors-studio.git
cd safetensors-studio

# Backend
cd backend
python -m venv .venv && source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp ../.env.example ../backend/.env  # if using env
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

# Frontend (second terminal)
cd ../frontend
npm install
cp ../.env.example .env.local  # edit NEXT_PUBLIC_API_URL if needed
npm run dev
```

## Scripts
| Command | Description |
|---------|-------------|
| `npm run dev` | Next.js dev with HMR |
| `npm run build` | Production build (Turbopack) |
| `npm run lint` | ESLint |
| `uvicorn app.main:app --reload` | FastAPI with auto-reload |
| `python -m pytest` | Backend tests (add) |

## Project Conventions
- **Frontend:** `App Router`, `Tailwind`, `Shadcn/ui`, `Recharts`, `lucide-react`, `clsx/tailwind-merge`
- **Backend:** `FastAPI` + `Pydantic v2`, `Transformers` + `Torch` + `Accelerate`
- **Commits:** Conventional Commits (`feat:`, `fix:`)
- **Branch:** `feat/*`, `fix/*` → PR to `main`

## Testing the Stack
```bash
# Backend health
curl http://localhost:8000/api/health
curl http://localhost:8000/docs  # Swagger

# Frontend
curl http://localhost:3000

# Load demo model (no GPU needed)
mkdir -p /tmp/demo && echo '{"model_type":"llama"}' > /tmp/demo/config.json && touch /tmp/demo/model.safetensors
curl -X POST http://localhost:8000/api/model/load -H "Content-Type: application/json" -d '{"model_path":"/tmp/demo","dtype":"float16"}'
```

## Troubleshooting
- **Port 8000 in use:** `lsof -i :8000` / `netstat -ano | findstr :8000` then `kill`
- **Torch not found:** `pip install torch --index-url https://download.pytorch.org/whl/cpu` (or `cu121` for GPU)
- **WS 404:** `TelemetryCharts` falls back to HTTP polling — safe to ignore in dev
- **PDF Arabic `?`:** Ensure `tahoma.ttf` exists or install `arabic-reshaper` + `python-bidi`

## IDE
- VS Code: recommended extensions `Tailwind CSS IntelliSense`, `Python`, `Pylance`
- Format: `prettier` (frontend), `black`/`ruff` (backend, optional)