How omkargade04/sentinel-agent works
Project Type & Purpose
• Sentinel is a backend service exposing a REST API (FastAPI) that integrates with GitHub to fetch and review pull requests.
• It persists data in a PostgreSQL database (via Supabase) and likely calls out to an AI model for bug detection.
• There is no user‐facing frontend—only API endpoints and background processing.
File Structure & Map to Layers
• Entry point: src/main.py boots up the FastAPI application.
• API Layer (presentation):
• src/api/fastapi/middlewares/… (authentication, GitHub webhook auth, request logging)
• src/api/fastapi/routes/… (health, user, repository, GitHub, pull‐request endpoints)
• Business Logic Layer (application):
• src/services/… (github_service, installation_service, repository_service, user_service)
• Helpers and domain logic live here.
• Data Layer (infrastructure):
• src/models/db/… (ORM definitions or table schemas for all tables)
• src/models/schemas/… (Pydantic models for request/response validation)
• src/core/database.py (DB session management)
• src/core/supabase_client.py (Supabase wrapper)
• External Integrations:
• GitHub API (via services/github)
• AI code‐review engine (implied)
• Support & Ops:
• SQL migrations (src/migrations/init.sql)
• Docker (Dockerfile, docker-compose.yaml)
• CI/CD (GitHub Actions in .github/workflows/unit-tests.yaml)
README Insights
• Clarifies it tracks PRs, reviews them, detects bugs.
• Installation steps confirm it runs as a standalone Python service.
a. Main Components to Represent
1. GitHub Webhooks & REST calls
• Incoming events (PR opened, PR updated)
2. API Gateway / FastAPI Server
• Middlewares (Auth, Logging)
• Routers (Route handlers)
3. Service Layer
• GitHubService, RepositoryService, UserService
4. External AI Engine
• (If using OpenAI or custom model)
5. Database
• PostgreSQL (Supabase)
6. CI/CD & Deployment
• GitHub Actions
• Docker & Docker Compose
b. Relationships & Data Flows
• Data flows back: Service → Response → Route → GitHub API (e.g., posting review comments).
c. Architectural Patterns
• Layered (Presentation → Application → Infrastructure)
• Hexagonal / Ports & Adapters: abstractions in core/ and services/.
d. Key Technologies
• FastAPI, Pydantic
• SQLAlchemy or Supabase client
• PostgreSQL
• Docker, GitHub Actions