WatchDog is an autonomous code review agent system using AI to analyze GitHub pull requests. It processes code reviews asynchronously with Celery, interacting with developers through a structured FastAPI-based API.
http://35.244.62.43/docs
- Python 3.8+
- Redis (or PostgreSQL for task/result storage)
- Celery for asynchronous task processing
- FastAPI for building the API
- Any LLM API (e.g., OpenAI, Ollama for local model running I've used cohere)
Clone the repository:
git clone git@github.com:00suryavanshi00/watchdog.git
cd watchdog
sudo apt install docker (your system equivalent of this)
docker compose up --build (for v2 docker compose )/ docker-compose up --build(for v1 docker compose)
This should spin up redis and app instance you should be able to see the {"message": "Welcome to FastAPI!"} on visiting
localhost:8000
Post the application starts visit
locahost:8000/docs
--> NOTE: leave github_token as empty string to pick up the default token (mine in the deployed version) in analyze_pr api
to access local doc api playground for yourself and for the deployed one it's mentioned above.
-
Separation of Concerns:
- Organized into folders:
routers
,services
,tasks
, andutils
. - Each layer has a specific responsibility (e.g., routing, task handling, AI services).
- Organized into folders:
-
Scalability:
- AI-based
CodeAnalyzer
uses the Strategy Pattern, making it easy to add new analysis strategies.
- AI-based
-
Logging:
- Centralized logging with clear messages for task tracking.
-
Celery for Asynchronous Processing:
- Scales task execution and avoids blocking the main thread.
-
Redis for Task Results:
- Efficient and scalable storage for analysis results.
-
Environment Variables:
- Sensitive data like tokens and credentials are securely loaded using
os.getenv
.
- Sensitive data like tokens and credentials are securely loaded using
-
Ai Model:
- Cohere is being used because I'm out of openai credits :)
-
Webhook Support:
- WatchDog also has a webhook api for only pr events which is tested and can be directly added to the repo with the link and secret. Here's an example use case with my personal repo.
-
Rate Limiting:
- WatchDog is also ratelimited by nginx on number of requests per second from a specific IP address. Below is the snippet from nginx config.
http { limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s; server { listen 80; # Apply rate limiting to all requests location / { limit_req zone=mylimit burst=5 nodelay; # rest configs try_files $uri $uri/ =404; } }
} ``` 11. Caching: - WatchDog also caches the requests if everything in the payload is exactly same. It doesn't create a new celery task id for it.