AI-powered Code Review Platform for GitHub and GitLab
7.0K
AI-powered Code Review Platform for GitHub, GitLab, and Bitbucket.

/metrics endpoint for monitoringcd backend
# Create config file
cp ../config.yaml.example config.yaml
# Edit config.yaml with your settings
# Run
go run ./cmd/server
cd frontend
# Install dependencies
npm install
# Run development server
npm run dev
Access the application at http://localhost:5173
Default credentials: admin / admin
# Pull from Docker Hub
docker pull huangangzhang/codesentry:latest
# Or pull from GitHub Container Registry
docker pull ghcr.io/huangang/codesentry:latest
Choose your database:
# MySQL (default, recommended for production)
docker-compose up -d
# SQLite (simple, single file)
docker-compose -f docker-compose.sqlite.yml up -d
# PostgreSQL
docker-compose -f docker-compose.postgres.yml up -d
Or run directly (SQLite):
docker run -d -p 8080:8080 -v codesentry-data:/app/data huangangzhang/codesentry:latest
For local development (build from source):
docker-compose -f docker-compose.dev.yml up --build
Access the application at http://localhost:8080
# One-command build (frontend + backend combined)
./build.sh
# Run the binary
./codesentry
This builds frontend, embeds it into the Go binary, producing a single executable.
Copy config.yaml.example to config.yaml and update:
server:
port: 8080
mode: release # debug, release, test
database:
driver: sqlite # sqlite, mysql, postgres
dsn: data/codesentry.db
# For MySQL: user:password@tcp(host:port)/dbname?charset=utf8mb4&parseTime=True&loc=Local
# For PostgreSQL: host=localhost user=postgres password=xxx dbname=codesentry port=5432 sslmode=disable
jwt:
secret: your-secret-key-change-in-production
expire_hour: 24
CodeSentry uses a short-lived access token (JWT) plus a long-lived refresh token for silent re-login.
POST /api/auth/login, stored by frontend in localStorage and sent as Authorization: Bearer <token>.POST /api/auth/refresh.Default expirations (configurable via System Config in DB):
auth_access_token_expire_hours (default: 2)auth_refresh_token_expire_hours (default: 720 = 30 days)jwt.expire_hour in config.yaml is used as a fallback default for access token expiration.
Note: When the access token expires, the frontend will automatically call
/api/auth/refreshand retry the original request. Only when refresh fails will it redirect to/login.
The frontend also performs proactive refresh before token expiration (default: refresh 5 minutes before access token expires) to reduce user-visible 401 interruptions.
Because refresh token is stored in a cookie, deployments that serve frontend and backend on different origins must configure CORS correctly:
Access-Control-Allow-Credentials: true is requiredAccess-Control-Allow-Origin cannot be *Note: All business configurations (LLM models, LDAP, prompts, IM bots, Git credentials) are managed via the web UI and stored in the database.
Use a single webhook URL for GitLab, GitHub, and Bitbucket:
https://your-domain/webhook
# or
https://your-domain/review/webhook
The system automatically detects the platform via request headers.
https://your-domain/webhookapplication/jsonhttps://your-domain/webhookhttps://your-domain/webhookPOST /api/auth/login - LoginPOST /api/auth/refresh - Refresh access token (uses httpOnly refresh cookie)GET /api/auth/config - Get auth configGET /api/auth/me - Get current userPOST /api/auth/logout - Logout (revokes refresh token and clears cookie)POST /api/auth/change-password - Change password (local users only)GET /api/system-config/auth-session - Get auth session configPUT /api/system-config/auth-session - Update auth session configGET /api/projects - List projectsPOST /api/projects - Create projectGET /api/projects/:id - Get projectPUT /api/projects/:id - Update projectDELETE /api/projects/:id - Delete projectGET /api/review-logs - List review logsGET /api/review-logs/:id - Get review detailPOST /api/review-logs/:id/retry - Retry failed review (admin only)DELETE /api/review-logs/:id - Delete review log (admin only)GET /api/events/reviews - Stream review status updates (requires token query param)GET /api/users - List users (admin only)PUT /api/users/:id - Update user (admin only)DELETE /api/users/:id - Delete user (admin only)GET /api/dashboard/stats - Get statisticsGET /api/search?q=<query>&limit=<n> - Search across reviews and projectsGET /api/reports?period=weekly|monthly&project_id=N - Period stats with trend and author rankingsGET /api/review-logs - List review logs (supports score range, status, author, date filters)GET /api/review-logs/:id - Get review detailGET /api/review-logs/export - Export review logs as CSV (admin only)POST /api/review-logs/:id/retry - Retry failed review (admin only)POST /api/review-logs/batch-retry - Batch retry (admin only)POST /api/review-logs/batch-delete - Batch delete (admin only)DELETE /api/review-logs/:id - Delete review log (admin only)PUT /api/review-logs/:id/score - Manually override review score (admin only)GET /api/issue-trackers - List issue tracker integrations (admin only)POST /api/issue-trackers - Create integration (admin only)PUT /api/issue-trackers/:id - Update integration (admin only)DELETE /api/issue-trackers/:id - Delete integration (admin only)POST /api/issue-trackers/:id/test - Test connection (admin only)POST /api/review-logs/:id/fix - Request AI-generated fix PR/MR (admin only)GET /api/review-logs/:id/fix-status - Get fix status (admin only)GET /api/review-rules - List review rules (admin only)POST /api/review-rules - Create rule (admin only)PUT /api/review-rules/:id - Update rule (admin only)DELETE /api/review-rules/:id - Delete rule (admin only)POST /api/review-rules/evaluate/:id - Test rules against a review log (admin only)GET /api/members - List member statisticsGET /api/members/detail - Get member detail with trend and project statsGET /api/members/overview - Get team overview (total stats, trend, score distribution, top members)GET /api/llm-configs - List LLM configsGET /api/llm-configs/active - List active LLM configs (for project selection)POST /api/llm-configs - Create LLM configPUT /api/llm-configs/:id - Update LLM configDELETE /api/llm-configs/:id - Delete LLM configGET /api/prompts - List prompt templatesGET /api/prompts/:id - Get prompt template detailGET /api/prompts/default - Get default prompt templateGET /api/prompts/active - List active prompt templatesPOST /api/prompts - Create prompt template (admin only)PUT /api/prompts/:id - Update prompt template (admin only)DELETE /api/prompts/:id - Delete prompt template (admin only)POST /api/prompts/:id/set-default - Set as default template (admin only)GET /api/im-bots - List IM botsPOST /api/im-bots - Create IM botPUT /api/im-bots/:id - Update IM botDELETE /api/im-bots/:id - Delete IM botGET /api/daily-reports - List daily reportsGET /api/daily-reports/:id - Get daily report detailPOST /api/daily-reports/generate - Generate daily report (manual, no notification)POST /api/daily-reports/:id/resend - Send/resend notificationPOST /webhook - Unified webhook (auto-detect GitLab/GitHub/Bitbucket, recommended)POST /review/webhook - Alias for unified webhookPOST /api/webhook - Unified webhook under /api prefixPOST /api/review/webhook - Alias under /api prefixPOST /api/webhook/gitlab - GitLab webhook (auto-detect project by URL)POST /api/webhook/github - GitHub webhook (auto-detect project by URL)POST /api/webhook/gitlab/:project_id - GitLab webhook (with project ID)POST /api/webhook/github/:project_id - GitHub webhook (with project ID)POST /api/webhook/bitbucket - Bitbucket webhook (auto-detect project by URL)POST /api/webhook/bitbucket/:project_id - Bitbucket webhook (with project ID)POST /review/sync - Synchronous code review for pre-receive hooksPOST /api/review/sync - Same endpoint under /api prefixGET /review/score?commit_sha=xxx - Query review status/score by commit SHAGET /api/review/score?commit_sha=xxx - Same endpoint under /api prefixRequest body:
{
"project_url": "https://gitlab.example.com/group/project",
"commit_sha": "abc123...",
"ref": "refs/heads/main",
"author": "John Doe",
"message": "feat: add new feature",
"diffs": "diff --git a/file.go..."
}
Response:
{
"passed": true,
"score": 85,
"min_score": 60,
"message": "Score: 85/100 (min: 60)",
"review_id": 123
}
See scripts/pre-receive-hook.sh for GitLab pre-receive hook example.
GET /api/system-logs - List system logsGET /api/system-logs/modules - Get module listGET /api/system-logs/retention - Get log retention daysPUT /api/system-logs/retention - Set log retention daysPOST /api/system-logs/cleanup - Manually cleanup old logsGET /health - Service health checkGET /metrics - Prometheus metricscodesentry/
├── backend/
│ ├── cmd/server/ # Application entry point
│ ├── internal/
│ │ ├── config/ # Configuration
│ │ ├── handlers/ # HTTP handlers
│ │ ├── middleware/ # Auth, CORS middleware
│ │ ├── models/ # Database models
│ │ ├── services/ # Business logic
│ │ └── utils/ # Utilities
│ └── go.mod
├── frontend/
│ ├── src/
│ │ ├── i18n/ # Internationalization
│ │ ├── layouts/ # Layout components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ ├── stores/ # State management
│ │ └── types/ # TypeScript types
│ └── package.json
├── Dockerfile
├── docker-compose.yml
├── config.yaml.example
├── README.md
└── README_zh.md
MIT
Content type
Image
Digest
sha256:07cdd42cc…
Size
19.2 MB
Last updated
5 months ago
docker pull huangangzhang/codesentry