Skip to content
RfxanPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

CommitIQ

CommitIQ is a repository health intelligence application. It ingests public GitHub repositories, analyzes commit history, computes code health metrics, stores results in SQLite or hosted Postgres, and renders an interactive React dashboard with health timelines, file graphs, bus-factor risk, and optional LLM-generated explanations.

This README reflects the repository state audited on 2026-05-19. For Vercel plus Railway/Render setup, see DEPLOYMENT.md.

Production Readiness Snapshot

Area Score Status
Production readiness 6/10 Deployable for a public demo with Vercel frontend and Railway/Render backend. Auth, rate limiting, and durable workers are still needed before a serious public launch.
Security 5/10 Local secret files exist, public APIs are unauthenticated, and vulnerable frontend packages are present. Clone error output is redacted before persistence.
Code quality 6/10 Architecture is readable, but lint fails and GraphExplorer.tsx carries substantial any usage.
Maintainability 6/10 Clear feature folders and schema, but duplicated requirements files, committed generated artifact history, and missing tests reduce confidence.

What The Project Does

CommitIQ turns Git history into repository health signals:

  • Accepts a GitHub URL or owner/repo shorthand.
  • Clones the repository to local temporary storage.
  • Walks recent commits from oldest to newest.
  • Extracts changed-file metrics using radon for Python and lizard for JavaScript/TypeScript/other supported languages.
  • Computes per-commit health snapshots from complexity, churn, LOC touched, and bus factor.
  • Builds graph nodes for changed files and graph edges from imports and repeated co-changes.
  • Computes bus-factor risk from git blame and fallback commit authorship.
  • Stores repos, commits, snapshots, graph data, jobs, and LLM narratives in SQLite.
  • Exposes FastAPI endpoints consumed by a Vite/React frontend.
  • Streams optional LLM explanations through a server-sent-events style response.

Architecture Overview

Browser
  |
  | React + Vite frontend
  | API base: VITE_API_BASE_URL or http://localhost:8000
  v
FastAPI backend
  |
  | /api/repos/* for ingestion, timeline, graph, bus factor, usage
  | /api/explain, /api/predict, /api/explain/stream for narratives
  v
SQLite or hosted Postgres database
  |
  | commits, snapshots, graph nodes/edges, bus factor, LLM cache
  v
Local Git clone workspace
  |
  | git clone, git checkout, git blame, static analysis
  v
GitHub public repositories and optional GitHub metadata API

The backend is organized by feature:

  • backend/features/repo_ingestion: clone, commit walking, static metrics, health scoring, graph building, bus-factor computation, and repo API routes.
  • backend/features/llm_analysis: LLM prompt generation, cache keys, budget guard, Claude/Gemini client logic, and LLM API routes.
  • backend/shared: SQLAlchemy ORM models and Pydantic response/request schemas.
  • migrations: SQL schema applied by backend.database.init_db().

Tech Stack

Layer Technology
Backend API FastAPI, Starlette, Uvicorn
Backend DB SQLAlchemy async ORM, SQLite via aiosqlite, hosted Postgres via asyncpg
Git analysis GitPython, local git CLI
Static analysis radon, lizard
LLM integration Anthropic SDK, intended Gemini fallback
Frontend React 18, TypeScript, Vite
Frontend data Axios, SWR, native fetch streaming
Routing React Router
Charts/graph Recharts, react-force-graph-2d, D3 force
Styling Tailwind CSS, CSS custom properties
Tooling ESLint, TypeScript compiler, npm

Folder Structure

.
├── APP_FLOW.md                         # Product/demo flow notes
├── CommitIQ_PRD.md                     # Product requirements
├── DESIGN_BRIEF.md                     # UI/design system notes
├── TRD.md                              # Technical requirements/design notes
├── commitiq_backend_schema.md          # Database/API schema reference
├── commitiq_implementation_plan.md     # Historical implementation plan
├── requirements.txt                    # Root Python install file, delegates to backend/requirements.txt
├── backend/
│   ├── config.py                       # Environment loading and constants
│   ├── database.py                     # Async engine, session factory, migration runner
│   ├── main.py                         # FastAPI app, lifespan, CORS, route registration
│   ├── requirements.txt                # Backend pinned dependencies
│   ├── features/
│   │   ├── llm_analysis/
│   │   │   ├── cache.py                # Narrative cache key hashing
│   │   │   ├── claude_client.py        # Claude/Gemini narrative generation
│   │   │   ├── cost_guard.py           # Per-repo LLM call budget
│   │   │   ├── prompt_builder.py       # Structured metric prompts
│   │   │   └── router.py               # /api/explain, /api/predict, /api/explain/stream
│   │   └── repo_ingestion/
│   │       ├── bus_factor.py           # Git blame/fallback ownership concentration
│   │       ├── clone_service.py        # GitHub URL parsing, clone, metadata fetch
│   │       ├── commit_walker.py        # Commit metadata and changed-file extraction
│   │       ├── graph_builder.py        # Import/co-change graph edge generation
│   │       ├── health_scorer.py        # Snapshot payload builder
│   │       ├── metrics_extractor.py    # Commit checkout and file complexity metrics
│   │       └── router.py               # Repo ingestion and read APIs
│   └── shared/
│       ├── models.py                   # SQLAlchemy ORM models
│       └── schemas.py                  # Pydantic schemas/types
├── frontend/
│   ├── package.json                    # Frontend scripts and dependencies
│   ├── vite.config.ts                  # Vite config
│   ├── eslint.config.js                # ESLint flat config
│   ├── tailwind.config.ts              # Tailwind theme tokens
│   ├── src/
│   │   ├── App.tsx                     # Route declarations
│   │   ├── lib/api.ts                  # API client
│   │   ├── pages/                      # Landing, analyze, dashboard, detail, demo, 404
│   │   ├── components/                 # Timeline, graph, cost, bus factor, narrative
│   │   └── types/index.ts              # Frontend types and utility functions
│   └── public/favicon.svg
├── migrations/001_initial_schema.sql   # SQLite schema
└── scripts/seed_demo.py                # Seeds facebook/react demo data

Ignored/generated files found locally:

  • .env and backend/.env exist locally with set GITHUB_TOKEN, ANTHROPIC_API_KEY, and GEMINI_API_KEY values. They are ignored by .gitignore, but their presence is a local secret-handling risk.
  • commitiq.db exists locally with 4 repos, 1124 commits, and 13 analysis jobs.
  • frontend/node_modules, frontend/dist, venv, backend/.venv, and Python __pycache__ directories exist locally and should stay untracked.

Current Implementation State

Working Or Likely Working

Feature Files How it works Status Confidence
Frontend production build frontend/package.json, frontend/src/*, frontend/vite.config.ts npm run build runs tsc -b then vite build. Verified output bundle was generated. Working High
React routing frontend/src/App.tsx Defines /, /analyze, /dashboard/:repoSlug, /dashboard/:repoSlug/commit/:sha, /demo, and fallback routes. Working at compile level High
API client wrapper frontend/src/lib/api.ts Axios client points at ${VITE_API_BASE_URL}/api, normalizes API errors, and exposes repo/graph/LLM helpers. Compiles High
Dashboard data flow frontend/src/pages/DashboardPage.tsx Uses SWR to fetch repo by slug, timeline, graph for selected commit, bus factor, and LLM usage. Compiles Medium
Graph UI frontend/src/components/GraphExplorer.tsx Renders force graph, filters modules/risk, detects cycles client-side, supports focus/zoom/replay. Builds, lint fails Medium
SQLite schema migrations/001_initial_schema.sql Defines repos, commits, health snapshots, graph nodes/edges, bus factor, narratives, and analysis jobs with useful indexes. Present and locally applied High
Migration runner backend/database.py On app lifespan, splits SQL migration file by semicolon and executes statements; enables SQLite WAL and foreign keys. Compiles Medium
GitHub URL parsing backend/features/repo_ingestion/clone_service.py Accepts URLs or owner/repo shorthand and validates owner/repo characters. Compiles High
Commit metric extraction backend/features/repo_ingestion/* Uses GitPython, git CLI, radon, and lizard to derive commit data and file metrics. Compiles Medium
LLM cache and budget guard backend/features/llm_analysis/cache.py, cost_guard.py SHA-256 cache key plus count-based per-repo call budget. Compiles High

Broken Or Incomplete

Severity Issue Location Root cause How to reproduce Impact Suggested fix
High No authentication or authorization backend/main.py, all routers All endpoints are public; there is no user model/session/JWT/API key. Any client can call POST /api/repos/ingest and read all stored repo data. Abuse, cost exhaustion, data exposure for future private repo support. Add auth middleware, tenant scoping, and authorization checks.
High No rate limiting or abuse controls backend/features/repo_ingestion/router.py:345, LLM routes Public clone and LLM endpoints have no request quotas beyond per-repo LLM cache count. Repeatedly call ingestion or explain endpoints. Disk/CPU/network/API-cost denial of service. Add IP/user rate limiting, global queues, per-user quotas, and clone concurrency limits.
High Frontend dependency vulnerabilities frontend/package-lock.json, frontend/package.json npm audit reports 9 vulnerabilities: 4 high, 3 moderate, 2 low. Run npm audit --json. XSS/open redirect/SSRF/DoS risks in dependencies, especially Axios, React Router, Vite. Upgrade axios to 1.16.1, react-router-dom to 6.30.3, vite to 5.4.21, postcss to 8.5.14, eslint to 9.39.4.
Medium Frontend lint fails frontend/src/components/GraphExplorer.tsx 33 explicit any errors and one unnecessary hook dependency warning. Run cd frontend && npm run lint. CI should fail; graph code is harder to maintain safely. Define force-graph node/link types and type callback signatures.
Medium LLM model documentation mismatch backend/features/llm_analysis/claude_client.py:1-7, :138-148, NarrativeCard.tsx Comments/UI mention claude-sonnet-4-20250514, actual call uses claude-3-5-sonnet-20241022. Inspect code or generate a narrative. Misleading cost/model reporting. Align comments/UI/default model strings with actual configured model.
Medium Ingestion work runs in FastAPI background task backend/features/repo_ingestion/router.py:398, run_ingestion Long CPU/Git work runs inside app process, not a durable queue. Ingest a large repo and restart server mid-job. Jobs can be lost, API process can be overloaded. Use Celery/RQ/Arq or a separate worker process with persistent job state.
Medium Import graph is based on current checkout only backend/features/repo_ingestion/router.py:242-285 Each commit checks out changed files for metrics, but import edges are built only from top_files in the current checkout context. Compare graph edges for old commits against actual historical tree. Commit graph can be incomplete or historically inaccurate. Build graph from full file set per commit or store HEAD-only graph explicitly as such.
Low Commit progress counter is off by one during processing backend/features/repo_ingestion/router.py:231-239 processed_commits=idx before processing the current commit. Observe SSE progress during ingestion. UI may show one fewer processed commit until the end. Set processed_commits=idx + 1 after successful commit processing.

Security Audit

Severity Finding Risk Recommendation
Critical Local .env and backend/.env contain set API tokens Even if ignored, local secrets can be accidentally copied, printed, or included in artifacts. Keep a single local .env, verify it is untracked, rotate any tokens that were ever committed or shared, and never duplicate secrets under backend/.
Medium Token embedded in git clone URL Clone authentication still uses a tokenized URL internally, but clone stderr is redacted before being persisted. Prefer GIT_ASKPASS or a credential helper in a future hardening pass.
High No auth or tenant isolation All repo data and actions are public. Add authentication before production; scope repos to users/orgs.
High No rate limiting Clone, static analysis, and LLM endpoints can be abused. Add IP and user quotas, queue backpressure, and global LLM budget limits.
High Vulnerable frontend packages npm audit found high vulnerabilities in Axios and React Router dependency chain. Upgrade packages and rerun audit.
Medium Error text leakage repo.error_message may expose internal paths or dependency errors. Keep detailed traces in server logs; expose generic public errors with correlation IDs.
Medium CORS methods/headers are broad Origins are environment-driven, but methods and headers are still permissive. Review credential usage and narrow methods/headers when auth is added.
Medium SSRF surface via outbound requests Backend calls GitHub API and git clone for user-provided owner/repo. Validation restricts to GitHub owner/repo, which is good, but abuse is still possible. Keep host fixed to GitHub, add rate limits, block excessively large repos, and enforce clone timeouts/depth.
Low No TrustedHostMiddleware or security headers API lacks deployment-level hardening. Add proxy/security middleware or configure these at ingress.
Low No raw code sent to LLM Prompt builder sends structured metrics only. This is a positive control; preserve it if LLM features expand.

Dependency Analysis

Backend Python Dependencies

Authoritative file: backend/requirements.txt.

Pinned packages include FastAPI, Uvicorn, SQLAlchemy, aiosqlite, GitPython, lizard, radon, Anthropic, python-dotenv, Pydantic, and httpx.

Confirmed missing dependency:

  • google-generativeai is required by backend/features/llm_analysis/claude_client.py but is not listed.

Outdated packages verified with backend/.venv/bin/python -m pip list --outdated --format=json:

Package Current Latest observed
fastapi 0.115.0 0.136.1
uvicorn 0.30.0 0.47.0
SQLAlchemy 2.0.35 2.0.49
aiosqlite 0.20.0 0.22.1
GitPython 3.1.43 3.1.50
anthropic 0.34.0 0.102.0
httpx 0.27.0 0.28.1
pydantic 2.9.0 2.13.4
python-dotenv 1.0.1 1.2.2
lizard 1.17.10 1.22.1

pip-audit is not installed in the backend virtualenv, so Python vulnerability auditing was not completed. Install pip-audit in a disposable environment and run it before release.

Frontend npm Dependencies

Verified commands:

  • npm run build: passes.
  • npm run lint: fails.
  • npm audit --json: fails with vulnerability findings.

npm audit summary:

Severity Count
Critical 0
High 4
Moderate 3
Low 2
Total 9

Recommended safe upgrades from audit output:

  • axios: 1.7.9 -> 1.16.1
  • react-router-dom: 6.26.2 -> 6.30.3
  • vite: 5.4.11 -> 5.4.21
  • postcss: 8.4.49 -> 8.5.14
  • eslint: 9.17.0 -> 9.39.4

Frontend Analysis

Pages

Route Component Purpose Status
/ LandingPage.tsx URL input, max commit count, ingestion start, demo link. Builds
/analyze AnalyzePage.tsx SSE-style ingestion progress screen. Builds
/dashboard/:repoSlug DashboardPage.tsx Main dashboard with timeline, graph, bus factor, cost, narrative. Builds
/dashboard/:repoSlug/commit/:sha CommitDetailPage.tsx Commit detail page with metrics, graph, narrative. Builds
/demo DemoPage.tsx Redirects to seeded facebook-react dashboard. Builds, depends on seed data
* NotFoundPage.tsx 404 page. Builds

Strengths

  • Clear route structure and API-client boundary.
  • SWR is used appropriately for dashboard data.
  • UI handles empty states for missing timeline, graph, bus factor, and demo data.
  • GraphExplorer is feature-rich: search, filters, zoom controls, fullscreen, cycle highlighting, stability map, and replay controls.
  • No direct dangerouslySetInnerHTML usage was found.

Frontend Risks

  • GraphExplorer.tsx is too large and currently responsible for layout, graph math, canvas drawing, UI controls, filtering, state, and interaction. It should be split into typed hooks and smaller presentational components.
  • GraphExplorer.tsx uses many explicit any casts, causing lint failure.
  • The built JS bundle is large: 855.29 kB uncompressed, 255.78 kB gzip. Consider code splitting the graph view.
  • The frontend defaults to http://localhost:8000 when VITE_API_BASE_URL is missing. Set VITE_API_BASE_URL in Vercel before production builds.
  • Accessibility is partial. Buttons generally have text or labels, but custom graph interactions need keyboard-accessible alternatives and stronger ARIA semantics.
  • Fonts are pulled from Google Fonts in index.css; offline/private deployments may need self-hosted fonts.

Backend Analysis

API Endpoints

Base API prefix: /api.

Method Path Handler Description
GET /health backend.main.health Health check outside /api.
POST /api/repos/ingest ingest_repo Creates/updates repo record, creates job, starts background ingestion.
GET /api/repos/ingest/progress/{repo_id} ingest_progress Streams job progress as text/event-stream.
GET /api/repos list_repos Lists repos; optional slug query.
GET /api/repos/{repo_id} get_repo Reads one repo.
GET /api/repos/{repo_id}/timeline get_timeline Returns commit health timeline.
GET /api/repos/{repo_id}/commit/{sha} get_commit_detail Returns repo, commit, snapshot, graph, bus factor, and cached narrative if present.
GET /api/repos/{repo_id}/graph get_graph Returns graph for latest or selected commit.
GET /api/repos/{repo_id}/bus-factor get_bus_factor Returns bus-factor module risk.
GET /api/repos/{repo_id}/llm-usage get_llm_usage Returns narrative usage/cost summary.
POST /api/explain explain_commit Generates or reads cached narrative for a commit.
POST /api/predict predict_merge Uses same narrative pipeline with predict_merge prompt type.
POST /api/explain/stream explain_commit_stream Streams generated explanation word by word after full LLM call completes.

Backend Strengths

  • Clear separation between ingestion, LLM, models, and schemas.
  • Pydantic validates ingestion URLs and commit SHA shape.
  • SQLAlchemy unique constraints prevent duplicate commits/narratives.
  • LLM cache is deterministic and budget-gated.
  • Prompt builder avoids sending raw source code to LLMs.
  • Clone and checkout subprocesses have timeouts.

Backend Risks

  • Backend startup is currently blocked by missing Gemini dependency.
  • Long-running ingestion runs inside the API process.
  • No structured logging; errors are stored as raw strings.
  • No tests around clone parsing, metric scoring, API schemas, or ingestion failure paths.
  • No pagination on repo list/timeline endpoints.
  • No authentication, authorization, or tenant model.
  • No production settings object or config validation; invalid integer env values can crash import.

Database Analysis

Schema file: migrations/001_initial_schema.sql.

Tables:

  • repos: repository metadata and ingestion status.
  • commits: commit metadata and diff stats.
  • health_snapshots: computed health metrics per commit.
  • graph_nodes: file-level graph nodes per commit.
  • graph_edges: import/co-change edges per commit.
  • bus_factor: ownership concentration per module.
  • llm_narratives: cached LLM outputs and costs.
  • analysis_jobs: background ingestion job progress.

Useful indexes exist on:

  • commits(repo_id, committed_at DESC)
  • commits(repo_id, sha)
  • health_snapshots(repo_id)
  • health_snapshots(repo_id, full_sha)
  • graph_nodes(repo_id, commit_id)
  • graph_edges(repo_id, commit_id)
  • graph_edges(repo_id, full_sha)
  • graph_edges(repo_id, source_file)
  • bus_factor(repo_id, risk_level)
  • llm_narratives(cache_key)
  • llm_narratives(repo_id, commit_id, prompt_type)
  • analysis_jobs(repo_id, created_at DESC)

Database concerns:

  • Migration runner is simplistic and not a full migration system. Use Alembic before production.
  • SQLite is acceptable for a local demo but not for multi-user production ingestion workloads.
  • Timeline endpoint is unbounded; large repos can return too much data.
  • Graph data is stored per commit and can grow quickly.
  • Local commitiq.db exists and should not be committed or deployed.

DevOps And Deployment

Deployment assets now present:

  • No Dockerfile.
  • No docker-compose.yml.
  • No Kubernetes manifests.
  • No .github/workflows.
  • Vercel config exists at frontend/vercel.json.
  • No Nginx or reverse proxy config.
  • Production process config exists for Railway/Render through Procfile, railway.json, and render.yaml.

Remaining deployment risks:

  1. No authentication/rate limiting.
  2. Long ingestion jobs still run inside the API process instead of a durable queue.
  3. No CI to run build/lint/tests/audit.
  4. Hosted deployments need correct VITE_API_BASE_URL and CORS_ORIGINS values.

Installation

Prerequisites:

  • Python 3.11+ recommended.
  • Node.js 20+ recommended.
  • npm.
  • Git CLI.
  • A Unix-like environment for the current scripts.

Backend Setup

cd /home/kali/CommitIQ
python -m venv backend/.venv
backend/.venv/bin/python -m pip install --upgrade pip
backend/.venv/bin/python -m pip install -r backend/requirements.txt

Current blocker: this is not enough to start the backend because google-generativeai is missing. Until requirements are fixed, install it manually:

backend/.venv/bin/python -m pip install google-generativeai

Frontend Setup

cd /home/kali/CommitIQ/frontend
npm install

Environment Setup

Create a local .env at the repository root. Do not commit it.

DATABASE_URL=sqlite+aiosqlite:///./commitiq.db
ANTHROPIC_API_KEY=
GEMINI_API_KEY=
GITHUB_TOKEN=
LLM_BUDGET_PER_REPO=25
REPO_STORAGE_PATH=/tmp/commitiq_repos
MAX_COMMITS_PER_INGESTION=500
ENVIRONMENT=development
VITE_API_BASE_URL=http://localhost:8000
VITE_APP_NAME=CommitIQ

Notes:

  • ANTHROPIC_API_KEY is needed for real Claude narratives.
  • GEMINI_API_KEY is intended for fallback, but the backend dependency must be added first.
  • GITHUB_TOKEN is optional for public repositories, but current clone error handling can leak it. Avoid setting it until token redaction is fixed.
  • The code also reads legacy LLM_MAX_CALLS_PER_REPO.

Running Locally

Backend:

cd /home/kali/CommitIQ
backend/.venv/bin/uvicorn backend.main:app --reload --host 127.0.0.1 --port 8000

Frontend:

cd /home/kali/CommitIQ/frontend
npm run dev

Open:

  • Frontend: http://localhost:5173
  • API docs: http://127.0.0.1:8000/docs
  • Health check: http://127.0.0.1:8000/health

Build And Validation

Verified commands from the audit:

cd frontend
npm run build

Status: passes.

cd frontend
npm run lint

Status: fails due to GraphExplorer.tsx explicit any errors.

cd /home/kali/CommitIQ
backend/.venv/bin/python -c "from backend.main import app; print(app.title)"

Status: fails with:

ModuleNotFoundError: No module named 'google'
cd frontend
npm audit --json

Status: reports 9 vulnerabilities.

API Documentation

Start Repository Ingestion

curl -X POST http://127.0.0.1:8000/api/repos/ingest \
  -H 'Content-Type: application/json' \
  -d '{"repo_url":"https://github.com/facebook/react","max_commits":100}'

Response:

{
  "repo_id": 1,
  "repo_slug": "facebook-react",
  "status": "processing",
  "job_id": 1,
  "message": "Ingestion started. Poll /api/repos/ingest/progress/1 for updates."
}

Stream Ingestion Progress

curl -N http://127.0.0.1:8000/api/repos/ingest/progress/1

List Repositories

curl http://127.0.0.1:8000/api/repos
curl http://127.0.0.1:8000/api/repos?slug=facebook-react

Get Timeline

curl http://127.0.0.1:8000/api/repos/1/timeline

Get Graph

curl http://127.0.0.1:8000/api/repos/1/graph
curl "http://127.0.0.1:8000/api/repos/1/graph?sha=abc1234"

Get Bus Factor

curl http://127.0.0.1:8000/api/repos/1/bus-factor

Generate Explanation

curl -X POST http://127.0.0.1:8000/api/explain \
  -H 'Content-Type: application/json' \
  -d '{"repo_id":1,"commit_sha":"abc1234","prompt_type":"explain_drop"}'

Stream Explanation

curl -N -X POST http://127.0.0.1:8000/api/explain/stream \
  -H 'Content-Type: application/json' \
  -d '{"repo_id":1,"commit_sha":"abc1234","prompt_type":"explain_drop"}'

LLM Usage

curl http://127.0.0.1:8000/api/repos/1/llm-usage

Demo Data

The frontend /demo route expects a seeded repo slug named facebook-react.

cd /home/kali/CommitIQ
backend/.venv/bin/python scripts/seed_demo.py

This script:

  • Ensures a facebook/react repo row exists.
  • Runs ingestion for 500 commits.
  • Optionally pre-caches LLM narratives if ANTHROPIC_API_KEY is set.

Current caveat: backend import must be fixed first.

Scripts

Command Purpose Current status
backend/.venv/bin/uvicorn backend.main:app --reload Run backend API Blocked until missing dependency is fixed
python scripts/seed_demo.py Seed facebook/react demo data Blocked until backend import works
npm run dev Run Vite dev server Expected working
npm run build TypeScript build and production bundle Verified passing
npm run lint ESLint Verified failing
npm run preview Preview built frontend Not verified

Testing Analysis

No automated test suite was found.

Missing critical tests:

  • Backend unit tests for parse_github_url, make_repo_slug, health scoring, graph edge building, bus factor fallback, and cache key generation.
  • Backend integration tests for every API endpoint.
  • Ingestion failure tests proving secrets are redacted.
  • LLM budget/cache tests.
  • Frontend component tests for landing validation, progress handling, dashboard empty states, and narrative streaming.
  • End-to-end tests for ingesting a small fixture repo.
  • Security regression tests for auth/rate limiting once implemented.

Recommended test stack:

  • Backend: pytest, pytest-asyncio, httpx.AsyncClient, temporary SQLite DB fixtures.
  • Frontend: Vitest, React Testing Library, Playwright.
  • CI: run backend import test, backend unit tests, npm run lint, npm run build, npm audit, and pip-audit.

Performance Notes

Known performance risks:

  • Ingestion checks out every commit and runs static analysis on changed files. This is CPU and disk intensive.
  • Bus factor uses git blame over touched files, which can be slow on large histories.
  • Co-change edge building is quadratic per commit file list.
  • Timeline and repo list endpoints are unpaginated.
  • Graph data is per-commit and can grow quickly.
  • Frontend graph bundle is large and should be code-split.
  • React force graph rendering can become expensive for dense graphs.

Mitigations:

  • Use a worker queue with concurrency limits.
  • Cap file count and commit count per user/plan.
  • Add pagination/windowing to timeline endpoints.
  • Precompute and cache graph JSON payloads.
  • Add indexes if query patterns expand.
  • Lazy-load GraphExplorer route/component.

Troubleshooting

Symptom Likely cause Fix
ModuleNotFoundError: No module named 'git' Backend dependencies are not installed in the active Python environment. Run pip install -r requirements.txt from the repo root.
Frontend cannot reach API Backend not running or wrong VITE_API_BASE_URL. Start backend on port 8000 and set VITE_API_BASE_URL=http://localhost:8000.
/demo shows setup error Demo database not seeded. Run scripts/seed_demo.py with backend dependencies installed.
npm run lint fails GraphExplorer.tsx explicit any usage. Type force graph callbacks and refs.
Clone fails Invalid repo, network issue, private repo, GitHub auth issue. Verify the repo is public or set a valid GITHUB_TOKEN.
LLM returns demo mode API keys missing or provider call failed. Set valid ANTHROPIC_API_KEY or GEMINI_API_KEY.
Production frontend calls localhost VITE_API_BASE_URL omitted at build time. Set production API base before building.

Roadmap

Top priority:

  1. Fix backend startup by adding or lazy-loading google-generativeai.
  2. Redact GITHUB_TOKEN from all subprocess output and stop embedding tokens in clone URLs.
  3. Add authentication, authorization, and rate limiting.
  4. Upgrade vulnerable frontend packages.
  5. Add CI for backend import, tests, lint, build, and audits.
  6. Replace FastAPI background tasks with a durable worker queue.
  7. Add automated backend and frontend tests.
  8. Move CORS, API URL, and production config into validated settings.
  9. Split and type GraphExplorer.tsx.
  10. Add Docker/deployment assets and a real migration workflow.

Contribution Guide

Before opening a PR:

  1. Do not commit .env, local databases, virtualenvs, node_modules, or build outputs.
  2. Run frontend build and lint.
  3. Run backend import/startup checks.
  4. Add or update tests for behavior changes.
  5. Document new environment variables in .env.example.
  6. Redact secrets from logs and errors.
  7. Keep API schema changes reflected in frontend/src/types/index.ts.

Suggested branch naming:

  • fix/backend-startup-google-generativeai
  • security/redact-clone-token
  • test/ingestion-api
  • refactor/typed-graph-explorer

Repository Health Notes

.gitignore covers common generated artifacts: .env, commitiq.db, venvs, node_modules, dist, logs, and Python caches.

Repository health issues:

  • Root requirements.txt delegates to backend/requirements.txt.
  • Local ignored artifacts are present in the working tree.
  • Deployment configuration exists; CI for tests/lint/audit is still missing.
  • Several files are modified in the current working tree at audit time; review git status --short before committing.

License

No explicit license file was found. Add a LICENSE file before publishing or accepting contributions. Without a license, reuse rights are ambiguous.

Final Audit Summary

CommitIQ has a coherent product concept and a meaningful implementation: ingestion, metrics, schema, dashboard, and LLM narrative paths are all represented in code. It is best described as a strong local prototype or hackathon-grade MVP, not a production service.

The immediate blocker is backend startup. The highest security risk is secret exposure through clone error handling combined with local populated .env files. The biggest maintainability issue is the oversized, weakly typed graph component and the absence of tests.

Top 10 Highest Priority Fixes

  1. Add google-generativeai to backend dependencies or lazy-import Gemini.
  2. Remove token-in-URL clone auth and redact all subprocess errors.
  3. Add authentication and authorization.
  4. Add ingestion and LLM rate limits.
  5. Upgrade audited vulnerable frontend packages.
  6. Fix GraphExplorer.tsx lint errors.
  7. Add backend and frontend test suites.
  8. Add CI workflow for build, lint, tests, and audits.
  9. Replace in-process background ingestion with a worker queue.
  10. Add Docker/deployment configuration and validated production settings.

Immediate Next Actions

  1. Fix backend import and confirm uvicorn backend.main:app starts.
  2. Rotate local tokens if there is any chance .env values were shared.
  3. Patch clone secret redaction before running with GITHUB_TOKEN.
  4. Run npm audit fix-style controlled upgrades and retest.
  5. Add a minimal smoke test suite around /health, ingestion request validation, and timeline reads.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages