|
3 | 3 | [](https://github.com/daretechie/CommitVigil/actions/workflows/ci.yml) |
4 | 4 |  |
5 | 5 |
|
6 | | -> GitHub webhook listener that monitors commits and pull requests for risky patterns, |
7 | | -> evaluates developer commitments against actual delivery, and sends Slack alerts on violations. |
| 6 | +> FastAPI lab for extracting commitments from chat and Git commit text, with Slack/reporting components, PostgreSQL, Redis, background workers, and Prometheus metrics. |
8 | 7 |
|
9 | | ---- |
| 8 | +## Problem |
10 | 9 |
|
11 | | -## What It Does |
| 10 | +Teams often make commitments in chat, commit messages, or review comments, but those commitments are hard to track later. This project explores a small service that extracts structured commitment records and connects them to reporting and feedback workflows. |
12 | 11 |
|
13 | | -CommitVigil sits between your GitHub repository and your team's Slack channel. It: |
| 12 | +This is an application/backend lab, not a lead DevOps portfolio project. |
14 | 13 |
|
15 | | -1. **Receives GitHub webhook events** — push, pull_request, commit comment |
16 | | -2. **Scans for risky patterns**: |
17 | | - - Direct pushes to `main`/`master` without a PR |
18 | | - - Unusually large diffs (configurable threshold) |
19 | | - - Commit messages containing secret-like strings |
20 | | - - Soft commitments ("I'll fix this later", "TODO: refactor") tracked against follow-through |
21 | | -3. **Scores and classifies** the event using structured LLM extraction (Instructor + Pydantic) |
22 | | -4. **Sends a Slack alert** with the violation type, commit author, and diff link |
| 14 | +## Current Scope |
23 | 15 |
|
24 | | ---- |
| 16 | +Implemented or represented in the repo: |
25 | 17 |
|
26 | | -## Architecture |
| 18 | +- FastAPI app with versioned API routing. |
| 19 | +- `/ingest/raw` endpoint for extracting commitments from raw text. |
| 20 | +- `/ingest/git` endpoint for extracting commitments from Git commit messages. |
| 21 | +- API-key protection and request rate limiting. |
| 22 | +- PostgreSQL, Redis, worker, and Prometheus services in Docker Compose. |
| 23 | +- Structured logging and basic health checks. |
| 24 | +- Tests for API, worker, database, Slack, reports, safety, and performance paths. |
27 | 25 |
|
28 | | -``` |
29 | | -GitHub Repository |
30 | | - └── Webhook (push / pull_request events) |
31 | | - └── CommitVigil API (FastAPI) |
32 | | - ├── Ingest: validates HMAC signature → queues job (ARQ + Redis) |
33 | | - ├── Worker: pattern scan → LLM evaluation → risk score |
34 | | - │ ├── Direct-push detector |
35 | | - │ ├── Large-diff detector (threshold: configurable) |
36 | | - │ └── Secret-pattern regex scan |
37 | | - └── Alert dispatcher → Slack Incoming Webhook |
38 | | -``` |
| 26 | +Not currently proven in this README: |
| 27 | + |
| 28 | +- GitHub webhook HMAC validation. |
| 29 | +- Direct-push detection. |
| 30 | +- Large-diff analysis from real GitHub payloads. |
| 31 | +- Production Slack alert screenshots. |
| 32 | +- End-to-end deployment evidence. |
39 | 33 |
|
40 | | -**Async processing:** Events are acknowledged immediately (200 OK) and processed by an ARQ background worker — GitHub's 10-second timeout is never a concern. |
| 34 | +Those should be added before presenting this as a GitHub security or DevOps control. |
41 | 35 |
|
42 | | ---- |
| 36 | +## Architecture |
| 37 | + |
| 38 | +```text |
| 39 | +Client / script |
| 40 | + -> CommitVigil API (FastAPI) |
| 41 | + -> ingestion endpoint |
| 42 | + -> commitment extraction |
| 43 | + -> database / reporting paths |
| 44 | + -> optional Slack or report output |
| 45 | +
|
| 46 | +Docker Compose |
| 47 | + -> api |
| 48 | + -> worker |
| 49 | + -> redis |
| 50 | + -> postgres |
| 51 | + -> prometheus |
| 52 | +``` |
43 | 53 |
|
44 | 54 | ## Tech Stack |
45 | 55 |
|
46 | 56 | | Layer | Technology | |
47 | 57 | |---|---| |
48 | | -| API | FastAPI (Python 3.12+) | |
49 | | -| Background jobs | ARQ (async Redis queue) | |
50 | | -| LLM extraction | Instructor + Pydantic | |
51 | | -| Database | PostgreSQL | |
52 | | -| Cache / queue | Redis | |
53 | | -| Observability | Prometheus + Structlog | |
54 | | - |
55 | | ---- |
| 58 | +| API | FastAPI, Python 3.12 | |
| 59 | +| Background jobs | ARQ, Redis | |
| 60 | +| Database | PostgreSQL, SQLModel/Alembic | |
| 61 | +| Reporting / templates | Jinja2 | |
| 62 | +| Observability | Prometheus, structured logging | |
| 63 | +| Testing | pytest, pytest-asyncio, httpx | |
56 | 64 |
|
57 | 65 | ## Quick Start |
58 | 66 |
|
59 | 67 | ```bash |
60 | 68 | git clone https://github.com/darestack/CommitVigil.git |
61 | 69 | cd CommitVigil |
62 | | -cp .env.example .env # add GITHUB_WEBHOOK_SECRET and SLACK_WEBHOOK_URL |
| 70 | +cp .env.example .env |
63 | 71 | docker compose up -d |
64 | 72 | ``` |
65 | 73 |
|
66 | | -**Configure GitHub webhook:** |
67 | | -1. Repo → Settings → Webhooks → Add webhook |
68 | | -2. Payload URL: `https://your-domain/api/v1/ingest/raw` |
69 | | -3. Content type: `application/json` |
70 | | -4. Secret: the value from your `.env` |
71 | | -5. Events: Push + Pull requests |
72 | | - |
73 | | ---- |
74 | | - |
75 | | -## Example Alert |
| 74 | +API: |
76 | 75 |
|
77 | | -``` |
78 | | -⚠️ CommitVigil Alert |
79 | | -Repo: darestack/my-service |
80 | | -Author: daretechie |
81 | | -Event: Direct push to main (no PR) |
82 | | -Commit: a3f9c12 — "hotfix: temp disable auth check" |
83 | | -Risk: HIGH — bypassed code review + suspicious message pattern |
84 | | -Link: https://github.com/darestack/my-service/commit/a3f9c12 |
| 76 | +```text |
| 77 | +http://localhost:8000 |
| 78 | +http://localhost:8000/docs |
| 79 | +http://localhost:8000/health |
85 | 80 | ``` |
86 | 81 |
|
87 | | ---- |
| 82 | +## Main Endpoints |
88 | 83 |
|
89 | | -## Configuration |
| 84 | +| Endpoint | Purpose | |
| 85 | +|---|---| |
| 86 | +| `POST /api/v1/ingest/raw` | Extract a structured commitment from raw chat-style text | |
| 87 | +| `POST /api/v1/ingest/git` | Extract a structured commitment from a Git commit message | |
| 88 | +| `GET /health` | Check API, database, and Redis status | |
| 89 | +| `GET /metrics` | Prometheus metrics, protected by API key | |
90 | 90 |
|
91 | | -| Variable | Purpose | |
| 91 | +## Evidence To Add |
| 92 | + |
| 93 | +| Evidence | Status | |
92 | 94 | |---|---| |
93 | | -| `GITHUB_WEBHOOK_SECRET` | HMAC secret for validating GitHub payloads | |
94 | | -| `SLACK_WEBHOOK_URL` | Incoming webhook URL for Slack alerts | |
95 | | -| `LARGE_DIFF_THRESHOLD` | Line count triggering large-diff alert (default: 500) | |
96 | | -| `DATABASE_URL` | PostgreSQL connection string | |
97 | | -| `REDIS_URL` | Redis connection string | |
98 | | -| `GROQ_API_KEY` / `OPENAI_API_KEY` | LLM provider key | |
| 95 | +| CI run screenshot | Needed | |
| 96 | +| Example request and response | Needed | |
| 97 | +| Prometheus metrics screenshot | Needed | |
| 98 | +| Worker log showing async processing | Needed | |
| 99 | +| Slack/report output screenshot | Needed before alerting claims | |
| 100 | +| GitHub webhook fixture and HMAC test | Needed before webhook/security claims | |
| 101 | + |
| 102 | +## Portfolio Note |
| 103 | + |
| 104 | +This repo should stay unpinned until the README, product scope, and proof artifacts are tighter. If it is kept public, frame it as a backend/automation lab rather than a production DevOps security system. |
0 commit comments