|
| 1 | +# OVERVIEW |
| 2 | +An AI-powered automated code review system designed to integrate with GitHub Pull Requests. Built with Kotlin and Spring Boot, it utilizes Google Gemini AI to analyze code changes and provide automated feedback directly on GitHub. |
| 3 | + |
| 4 | +# STRUCTURE |
| 5 | +``` |
| 6 | +. |
| 7 | +├── .github/workflows/ # CI/CD pipelines (GitHub Actions) |
| 8 | +├── src/ |
| 9 | +│ ├── main/ |
| 10 | +│ │ ├── kotlin/com/project/codereview/ |
| 11 | +│ │ │ ├── application/ # Configuration and utility classes |
| 12 | +│ │ │ ├── client/ # External API clients (GitHub, Google Gemini) |
| 13 | +│ │ │ ├── core/ # Core business logic, controllers, and services |
| 14 | +│ │ │ ├── domain/ # Domain models and repository interfaces |
| 15 | +│ │ │ └── CodeReviewApplication.kt # Main entry point |
| 16 | +│ │ └── resources/ # Application properties and static assets |
| 17 | +│ └── test/ # Unit and integration tests |
| 18 | +├── build.gradle.kts # Build configuration |
| 19 | +└── Dockerfile # Containerization configuration |
| 20 | +``` |
| 21 | + |
| 22 | +# WHERE TO LOOK |
| 23 | +| Task / Workflow | Exact File Path | |
| 24 | +| :--- | :--- | |
| 25 | +| GitHub Webhook Entry Point | `src/main/kotlin/com/project/codereview/core/controller/CodeReviewController.kt` | |
| 26 | +| Event Handling Orchestration | `src/main/kotlin/com/project/codereview/core/service/CodeReviewFacade.kt` | |
| 27 | +| AI Review Logic | `src/main/kotlin/com/project/codereview/core/service/CodeReviewService.kt` | |
| 28 | +| Gemini API Integration | `src/main/kotlin/com/project/codereview/client/google/GoogleGeminiClient.kt` | |
| 29 | +| GitHub API Integration | `src/main/kotlin/com/project/codereview/client/github/GithubReviewClient.kt` | |
| 30 | +| GitHub Diff Parsing | `src/main/kotlin/com/project/codereview/client/github/GithubDiffUtils.kt` | |
| 31 | +| Domain Models | `src/main/kotlin/com/project/codereview/domain/model/` | |
| 32 | + |
| 33 | +# CODE MAP |
| 34 | +| Symbol | Type | Location | |
| 35 | +| :--- | :--- | :--- | |
| 36 | +| `CodeReviewController` | Class (RestController) | `src/main/kotlin/com/project/codereview/core/controller/CodeReviewController.kt` | |
| 37 | +| `CodeReviewFacade` | Class (Service) | `src/main/kotlin/com/project/codereview/core/service/CodeReviewFacade.kt` | |
| 38 | +| `CodeReviewService` | Class (Service) | `src/main/kotlin/com/project/codereview/core/service/CodeReviewService.kt` | |
| 39 | +| `GoogleGeminiClient` | Class (Service) | `src/main/kotlin/com/project/codereview/client/google/GoogleGeminiClient.kt` | |
| 40 | +| `GithubReviewClient` | Class (Service) | `src/main/kotlin/com/project/codereview/client/github/GithubReviewClient.kt` | |
| 41 | +| `GithubSignature` | Object (Utility) | `src/main/kotlin/com/project/codereview/core/util/GithubSignature.kt` | |
| 42 | + |
| 43 | +# CONVENTIONS (THIS PROJECT) |
| 44 | +- **Kotlin Coroutines**: Extensive use of `suspend` functions and coroutine scopes for non-blocking I/O. |
| 45 | +- **Spring Boot 3.x**: Leverages the latest Spring Boot features and dependencies. |
| 46 | +- **GitHub App Auth**: Uses JWT (JJWT) for authenticating as a GitHub App. |
| 47 | +- **Signature Validation**: All incoming webhooks must be validated using `X-Hub-Signature-256`. |
| 48 | +- **Concurrency Control**: `Semaphore` is used in `CodeReviewService` to limit concurrent AI calls. |
| 49 | +- **Rate Limiting**: Implements a cooldown period (1 minute + jitter) after each Gemini call. |
| 50 | + |
| 51 | +# ANTI-PATTERNS / TECH DEBT |
| 52 | +- **Hardcoded Limits**: Max review counts and concurrency limits are currently hardcoded in `CodeReviewService`. |
| 53 | +- **Error Handling**: Catch-all `Throwable` in some service methods; could be more specific. |
| 54 | +- **Payload Deserialization**: `FAIL_ON_UNKNOWN_PROPERTIES = false` is used, which helps with evolving APIs but might hide breaking changes. |
| 55 | + |
| 56 | +# COMMANDS |
| 57 | +- **Build**: `./gradlew build` |
| 58 | +- **Test**: `./gradlew test` |
| 59 | +- **Run Locally**: `./gradlew bootRun` |
| 60 | + |
| 61 | +# NOTES |
| 62 | +- The project relies on environment variables for GitHub secrets and Gemini API keys (see `application.yaml` for expected keys). |
0 commit comments