# stefan-kolov/smartreview architecture

> Architecture diagram of the GitHub repository stefan-kolov/smartreview, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stefan-kolov/smartreview
- Repository: https://github.com/stefan-kolov/smartreview

## Overview

#### Purpose and Runtime
SmartReview is a Spring Boot backend that accepts repository/code-review requests, runs AI-assisted review jobs, persists results, and exposes authentication, user, and review APIs. The executable entry point is `src/main/java/com/smartreview/smartreview/SmartReviewApplication.java`; Maven builds the service via `pom.xml`. Container deployment is defined by `Dockerfile` and `docker-compose.yml`.

#### HTTP API and Security Boundary
REST controllers form the inbound boundary:
- `src/main/java/com/smartreview/smartreview/web/AuthController.java`
- `src/main/java/com/smartreview/smartreview/web/UserController.java`
- `src/main/java/com/smartreview/smartreview/web/ReviewController.java`

JWT authentication is handled before protected endpoints by `config/JwtFilter.java`, backed by token operations in `config/JwtService.java` and authorization rules in `config/WebSecurityConfig.java`. API documentation is configured in `config/SwaggerConfig.java`.

#### Identity and User Management
Authentication and account lifecycle operations flow from controllers through service interfaces and implementations:
- `service/AuthService.java`, `service/impl/AuthServiceImpl.java`
- `service/UserService.java`, `service/impl/UserServiceImpl.java`
- `repository/UserRepository.java`

The `model/User.java` entity is the durable identity model. Request/response DTOs separate public API payloads from persistence entities, especially under `model/dto/`.

#### Review Job Domain and Persistence
A review is represented as a durable job with associated reviewed files and detected issues:
- `model/ReviewJob.java`
- `model/FileReview.java`
- `model/ReviewIssue.java`

`model/enums/ReviewStatus.java`, `Severity.java`, and `IssueCategory.java` define workflow and result classifications. `repository/ReviewJobRepository.java` is the persistence boundary for review lifecycle state and results.

#### Review Submission and Orchestration Flow
Review requests enter through `web/ReviewController.java`, then pass through `service/ReviewService.java` and `service/impl/ReviewServiceImpl.java`. The orchestration layer coordinates repository retrieval, provider execution, job updates, and result persistence:
- `service/impl/ReviewOrchestrator.java`
- `service/impl/RepoService.java`
- `service/impl/ReviewProgressService.java`

This separates synchronous API submission/status access from potentially long-running review execution. `config/AsyncConfig.java` indicates asynchronous processing infrastructure for review work.

#### AI Provider Abstraction
`service/CodeReviewProvider.java` defines the boundary for external LLM review engines. `service/impl/providers/BaseReviewProvider.java` supplies shared provider behavior, while `ReviewProviderFactory.java` selects an implementation. Supported external services are represented by:
- `AnthropicReviewProvider.java`
- `GeminiReviewProvider.java`
- `GroqReviewProvider.java`
- `OpenAiReviewProvider.java`

Provider-specific API credentials, model selection, and runtime settings are expected to be environment/property-driven through `src/main/resources/application.properties` and `application-prod.properties`.

#### Primary Control Flow
1. A client registers or logs in; authentication returns a JWT.
2. The JWT filter authenticates subsequent user and review API calls.
3. A review request creates or updates a `ReviewJob`.
4. Async orchestration obtains repository/code content, chooses an AI provider, and submits file/code review work.
5. Provider output is normalized into `FileReview` and `ReviewIssue` records, persisted against the job, and exposed through review-job response DTOs.

Main entry points: [`src/main/java/com/smartreview/smartreview/web/ReviewController.java`](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/ReviewController.java) (Review API), [`src/main/java/com/smartreview/smartreview/SmartReviewApplication.java`](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/SmartReviewApplication.java) (SmartReview Application), [`src/main/java/com/smartreview/smartreview/web/AuthController.java`](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/AuthController.java) (Auth API), [`src/main/java/com/smartreview/smartreview/web/UserController.java`](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/UserController.java) (User API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_auth_api["Auth API<br/>REST controller"]
  node_user_api["User API<br/>REST controller"]
  node_review_api["Review API<br/>REST controller"]
  node_dto["API DTOs<br/>request and response models"]
end

subgraph group_security["Security"]
  node_jwt_filter["JWT Filter<br/>authentication filter"]
  node_jwt_service["JWT Service<br/>token service"]
  node_security_config["Security Rules<br/>security configuration"]
  node_identity_services["Auth &amp; User Services<br/>service layer"]
end

subgraph group_review["Review Pipeline"]
  node_review_service["Review Service<br/>service layer"]
  node_orchestrator["Review Orchestrator<br/>async job orchestration"]
  node_repo_service["Repository Content<br/>repository retrieval service"]
  node_progress_service["Review Progress<br/>job progress service"]
  node_async_config["Async Execution<br/>async configuration"]
end

subgraph group_providers["AI Providers"]
  node_provider_factory["Provider Factory<br/>provider selection"]
  node_provider_contract["Code Review Provider<br/>LLM provider interface"]
  node_llm_providers["LLM Providers<br/>Anthropic, Gemini, Groq, OpenAI"]
end

subgraph group_data["Persistence"]
  node_user_store[("Users<br/>identity persistence")]
  node_review_store[("Review Jobs &amp; Results<br/>review persistence")]
  node_review_model["Review Domain Model<br/>entities and classifications"]
end

node_app{{"SmartReview Application<br/>Spring Boot entry point"}}

node_app -->|"boots"| node_security_config
node_app -->|"boots"| node_async_config
node_jwt_filter -->|"validates tokens"| node_jwt_service
node_security_config -->|"installs"| node_jwt_filter
node_auth_api -->|"auth requests"| node_identity_services
node_user_api -->|"account requests"| node_identity_services
node_identity_services -->|"issues tokens"| node_jwt_service
node_identity_services -->|"reads and writes"| node_user_store
node_review_api -->|"submits and queries"| node_review_service
node_review_api -->|"uses"| node_dto
node_review_service -->|"creates and reads jobs"| node_review_store
node_review_service -->|"starts async work"| node_orchestrator
node_async_config -->|"executes"| node_orchestrator
node_orchestrator -->|"retrieves code"| node_repo_service
node_orchestrator -->|"selects provider"| node_provider_factory
node_provider_factory -->|"returns"| node_provider_contract
node_llm_providers -->|"implements"| node_provider_contract
node_orchestrator -->|"updates progress"| node_progress_service
node_progress_service -->|"persists lifecycle"| node_review_store
node_orchestrator -->|"persists results"| node_review_store
node_review_store -->|"stores"| node_review_model

click node_app "https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/SmartReviewApplication.java"
click node_auth_api "https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/AuthController.java"
click node_user_api "https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/UserController.java"
click node_review_api "https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/ReviewController.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_api,node_user_api,node_review_api,node_dto toneBlue
class node_jwt_filter,node_jwt_service,node_security_config,node_identity_services toneAmber
class node_review_service,node_orchestrator,node_repo_service,node_progress_service,node_async_config toneMint
class node_provider_factory,node_provider_contract,node_llm_providers toneRose
class node_user_store,node_review_store,node_review_model toneIndigo
class node_app toneNeutral
```

## Components

### HTTP API

- [Auth API](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/AuthController.java): REST controller · `src/main/java/com/smartreview/smartreview/web/AuthController.java`
- [User API](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/UserController.java): REST controller · `src/main/java/com/smartreview/smartreview/web/UserController.java`
- [Review API](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/web/ReviewController.java): REST controller · Submits jobs and exposes status/results. · `src/main/java/com/smartreview/smartreview/web/ReviewController.java`
- **API DTOs**: request and response models

### Security

- **JWT Filter**: authentication filter
- **JWT Service**: token service
- **Security Rules**: security configuration
- **Auth & User Services**: service layer

### Review Pipeline

- **Review Service**: service layer
- **Review Orchestrator**: async job orchestration · Coordinates repository retrieval, provider execution, and result updates.
- **Repository Content**: repository retrieval service
- **Review Progress**: job progress service
- **Async Execution**: async configuration

### AI Providers

- **Provider Factory**: provider selection
- **Code Review Provider**: LLM provider interface
- **LLM Providers**: Anthropic, Gemini, Groq, OpenAI · Provider implementations share base behavior.

### Persistence

- **Users**: identity persistence · User entity and repository.
- **Review Jobs & Results**: review persistence · Stores jobs, file reviews, and detected issues.
- **Review Domain Model**: entities and classifications · ReviewJob, FileReview, ReviewIssue, status, severity, and category.

### Other components

- [SmartReview Application](https://github.com/stefan-kolov/smartreview/blob/main/src/main/java/com/smartreview/smartreview/SmartReviewApplication.java): Spring Boot entry point · `src/main/java/com/smartreview/smartreview/SmartReviewApplication.java`

## Connections

- SmartReview Application → Security Rules: boots
- SmartReview Application → Async Execution: boots
- JWT Filter → JWT Service: validates tokens
- Security Rules → JWT Filter: installs
- Auth API → Auth & User Services: auth requests
- User API → Auth & User Services: account requests
- Auth & User Services → JWT Service: issues tokens
- Auth & User Services → Users: reads and writes
- Review API → Review Service: submits and queries
- Review API → API DTOs: uses
- Review Service → Review Jobs & Results: creates and reads jobs
- Review Service → Review Orchestrator: starts async work
- Async Execution → Review Orchestrator: executes
- Review Orchestrator → Repository Content: retrieves code
- Review Orchestrator → Provider Factory: selects provider
- Provider Factory → Code Review Provider: returns
- LLM Providers → Code Review Provider: implements
- Review Orchestrator → Review Progress: updates progress
- Review Progress → Review Jobs & Results: persists lifecycle
- Review Orchestrator → Review Jobs & Results: persists results
- Review Jobs & Results → Review Domain Model: stores
