This guide is for contributors who want a reliable, repeatable local setup for development and testing.
It covers both runtime modes used in this repo:
- Local contributor mode: Docker for Redis, Node processes on your machine.
- Production-style local mode: no Docker, run each service in separate terminals (frontend, backend API, worker).
Install these before starting:
- Node.js 20+ and npm 10+
- Git
- PostgreSQL database (local or managed, e.g. Neon)
- Redis (local, managed, or Docker)
- GitHub OAuth App
- Optional: Gemini API key (AI features fall back when missing)
Required OAuth callback URL for local:
Important project note:
- This repository does not use Python and does not require a requirements.txt file.
- Fork this repository on GitHub.
- Clone your fork and enter the project.
- Install dependencies in backend and frontend.
git clone https://github.com/<your-username>/GitVital.git
cd GitVital
cd backend
npm install
cd ../frontend
npm installCreate backend environment file from template:
PowerShell:
Copy-Item .\backend\.env.example .\backend\.envmacOS/Linux:
cp backend/.env.example backend/.envUpdate backend/.env values.
Minimum required for stable local runtime:
- PORT=8080
- NODE_ENV=development
- FRONTEND_URL=http://localhost:3000
- DATABASE_URL=
- REDIS_URL=
- ENCRYPTION_KEY=<64-char hex>
- SESSION_SECRET=<64-char hex>
Used for OAuth login:
- GITHUB_CLIENT_ID
- GITHUB_CLIENT_SECRET
- GITHUB_CALLBACK_URL=http://localhost:8080/auth/github/callback
Optional but recommended:
- GEMINI_API_KEY
- GITHUB_TOKEN (or GITHUB_ACCESS_TOKEN) for worker fallback when user token is unavailable
- MONTHLY_COST_TARGET_USD, FREE_TIER_ONLY, DEGRADE_GRACEFULLY_ON_LIMIT
Generate secure keys:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Run SQL scripts in order against your target database:
- backend/sql/001_refined_schema.sql
- backend/sql/003_score_updated_at.sql
Optional maintenance script (not bootstrap):
- backend/sql/002_maintenance.sql
Example using psql:
psql "$DATABASE_URL" -f backend/sql/001_refined_schema.sql
psql "$DATABASE_URL" -f backend/sql/003_score_updated_at.sqlUse this when developing locally and you want Redis to be one command away.
- Start Redis container:
docker compose up -d redis- Set REDIS_URL in backend/.env for local docker redis:
REDIS_URL=redis://localhost:6379- Start app services in separate terminals.
Terminal 1 (Backend API):
cd backend
npm run devTerminal 2 (Repo Worker):
cd backend
npm run workerTerminal 3 (Frontend):
cd frontend
npm run devOptional Terminal 4 (User Worker):
cd backend
npm run worker:userOptional Terminal 5 (Cron refresher/recompute):
cd backend
npm run cron:refreshUse this when validating behavior closer to deployment.
- Point backend/.env to managed/local infra (no Docker):
- REDIS_URL=rediss://... (or redis://...)
- DATABASE_URL=postgresql://...
- Build both apps:
cd backend
npm run build
cd ../frontend
npm run build- Run services in separate terminals.
Terminal 1 (Backend API, production runtime):
cd backend
npm run startTerminal 2 (Repo Worker, built JS runtime):
cd backend
node -r dotenv/config dist/workers/repoAnalyzer.jsTerminal 3 (Frontend, production runtime):
cd frontend
npm run startOptional Terminal 4 (User Worker, built JS runtime):
cd backend
node -r dotenv/config dist/workers/userAnalyzer.jsOptional Terminal 5 (Cron, built JS runtime):
cd backend
node -r dotenv/config dist/cron/refreshRepos.js- Standard run pattern is 3 terminals: backend API + repo worker + frontend.
- Do not run dedicated workers and inline workers together.
- Inline workers are only enabled when EMBED_WORKERS_IN_API=true.
- If EMBED_WORKERS_IN_API=true for API process, do not run npm run worker and npm run worker:user separately.
- Frontend opens at http://localhost:3000
- Backend responds at http://localhost:8080
- OAuth entrypoint loads: http://localhost:8080/auth/github
- Worker terminal shows Redis connection and job processing logs
- Analyze a repo from UI and verify status transitions queued -> processing -> done
- Create a branch from latest main.
git checkout main
git pull upstream main
git checkout -b feat/<short-topic>- Make changes.
- Validate before opening PR:
cd backend
npm run build
cd ../frontend
npm run lint
npm run build- Commit with clear message.
- Push branch and open PR to main.
- In PR description include:
- What changed
- Why it changed
- How you tested (commands + screenshots/logs)
- Any env vars or migration impact
- Backend fails early with missing env var:
- Check backend/.env, especially REDIS_URL, ENCRYPTION_KEY, SESSION_SECRET.
- Worker errors with GitHub token unavailable:
- Add GITHUB_TOKEN (or re-authenticate and ensure user OAuth token exists).
- Redis connection refused:
- If Docker mode, run docker compose ps and ensure redis container is up.
- If no Docker, verify REDIS_URL and network access.
- OAuth loops or callback mismatch:
- Ensure GitHub app callback exactly matches backend env callback URL.
- Never commit backend/.env or any real credentials.
- Rotate secrets immediately if leaked.
- Use backend/.env.example as the safe source-of-truth template for contributors.