Thank you for contributing. PlastiTrace is a web-only stack: Next.js frontend + Flask API + PyTorch classifier.
| Tool | Version | Used for |
|---|---|---|
| Python | 3.11+ | API and ML inference |
| Node.js | 20+ | Web frontend (web/) |
| npm | 10+ | Web dependencies |
On macOS, install Xcode Command Line Tools if NumPy or OpenCV fail to build:
xcode-select --installgit clone https://github.com/will702/PlastiTrace.git
cd PlastiTrace
# Python environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Web frontend
cd web
cp .env.example .env.local
npm install
cd ..Place model weights at models/plastitrace.pth if they are not already present.
Terminal 1 - API:
source venv/bin/activate
python api.pyTerminal 2 - Frontend:
cd web && npm run devOpen http://localhost:3000. The frontend reads NEXT_PUBLIC_API_URL from web/.env.local (defaults to http://localhost:5001).
| Path | Purpose |
|---|---|
api.py |
Flask REST API (/api/classify, /api/health) |
ml/ |
ResNet18 classifier, preprocessing, config |
models/ |
Trained weights (plastitrace.pth) |
web/ |
Next.js frontend (deploy to Vercel) |
See architecture diagrams in README.md.
- No secrets - Do not commit
.env,.env.local, API keys, or tokens. - No cache files -
__pycache__/,*.pyc,.DS_Storemust stay out of git. - No agent tooling - Do not commit
.cursor/,.agents/,.claude/,.gemini/, orskills-lock.json. - Web changes - Run
cd web && npm run buildand fix any errors. - Python check - Verify:
python -c "from ml.classifier import PlastiTraceClassifier". - Docs - Update README.md if you change API routes, env vars, or project structure.
| Component | Host | Config |
|---|---|---|
| Frontend | Vercel | Root directory: web, env: NEXT_PUBLIC_API_URL |
| API | Render / Railway / HF Spaces | Gunicorn; debug=False; restrict CORS |
Production API checklist:
- Restrict CORS to your Vercel domain
- Serve over HTTPS (required for mobile camera)
- Add upload size limits and file type validation
Open a GitHub issue if setup steps fail or documentation is out of date.