How shaig-mahmudov/rivet-api works
1. What this repo is
- Rivet is a single Spring Boot backend service for engineering workflow management.
- The runtime is a classic layered Java backend: HTTP controllers at the edge, service layer for business rules, JPA repositories for persistence, and Flyway-managed relational schemas underneath.
2. Top-level request flow
- Requests enter Spring MVC controllers under auth, user, project, task, and ai.
- Most endpoints flow through service interfaces/implementations, then into repositories backed by JPA entities.
- Cross-cutting concerns like auth, validation, and exception mapping are centralized rather than duplicated in each module.
3. Security boundary
- Authentication is stateless JWT-based.
- JwtAuthenticationFilter and SecurityConfig enforce protected routes and populate the current user context.
- Passwords are hashed with BCrypt, access tokens are validated by JWT service logic, and logout/refresh flows depend on a token blacklist plus refresh-token persistence.
- Admin-only behavior is enforced at the API/service boundary, especially for hard delete and user-management actions.
4. Auth subsystem
- The auth module handles register, login, refresh, logout, and bootstrap-admin flows.
- Refresh tokens are first-class data: they are issued, rotated, revoked, hashed, and stored via RefreshToken plus RefreshTokenRepository.
- Blacklisted access tokens can be stored in-memory or in Redis, which is an architectural switch controlled by configuration.
5. Core domain modules
- project, task, and user are the main business domains.
- Each follows the same internal pattern: controller → DTOs → service abstraction/implementation → repository → entity/mapper.
- This makes the architecture diagram naturally split into three symmetric business areas, with task being the most complex one.
6. Task is the central aggregate
- The task module contains the richest business logic: status transitions, priority changes, partial updates, soft/hard delete, restore, filtering, and project/user assignment.
- TaskStatusTransitionPolicy and the transition service encode workflow rules, including allowed transitions and reason-required states.
- The task entity also anchors related features: activities, comments, dependencies, and acceptance criteria.
7. Task subdomains
- Activity timeline: task lifecycle events are recorded as read-only TaskActivity entries and surfaced through timeline endpoints.
- Comments: nested comment endpoints support discussion and blocker notes tied to tasks.
- Dependencies: tasks can depend on other tasks, with guards against self-dependency, duplicates, cross-project links, and cycles.
- Acceptance criteria: manual criteria can be created in bulk, completed/reopened, and are enforced before a task can move to DONE.
8. AI integration boundary
- The AI module is isolated from the core persistence workflow.
- AiSuggestionController and AiAcceptanceCriteriaService generate draft acceptance-criteria suggestions for a task but do not persist them.
- AiProvider abstracts the external model provider; a disabled provider exists by default, and a Gemini implementation is available when configured.
- This is a deliberate boundary: AI assists users, but saved criteria still flow through the normal task/criteria APIs.
9. Persistence model
- JPA entities live alongside each domain and map to relational tables created by Flyway.
- BaseEntity suggests common audit fields and shared persistence behavior.
- The repository layer is thin and domain-specific: project/task/user plus child tables for comments, activities, dependencies, criteria, and refresh tokens.
10. Database and migration strategy
- The repo supports MySQL for development, PostgreSQL for production, and H2 for tests.
- Flyway migrations are duplicated per database family under db/migration/mysql and db/migration/postgresql.
- Schema validation tests verify that the SQL migrations and Hibernate mappings stay aligned across both dialects.
11. Configuration and environment boundaries
- Runtime behavior is environment-driven through application.properties, application-dev.properties, and application-prod.properties.
- Important deployment toggles include DB URL/credentials, JWT secrets, refresh-token retention, Redis settings, and AI provider credentials.
- The Docker Compose setup starts the API with MySQL and Redis, matching the production-style token-blacklist architecture more closely than the default in-memory mode.
12. Error handling and API contract
- Domain-specific exceptions are centralized in common/exception, with GlobalExceptionHandler converting them into structured ErrorResponse payloads.
- Validation errors are surfaced at the field level through Bean Validation and the exception layer.
- This keeps controllers thin and ensures consistent failure semantics across auth, project, task, and user operations.
13. Testing and delivery
- The test suite covers controller and service behavior for auth, project, task, and user modules.
- Dedicated migration-validation tests check the SQL schema for both MySQL and PostgreSQL.
- CI is GitHub Actions–based, and the repo includes both a Dockerfile and compose file for containerized execution.
14. How to draw the architecture
- A good diagram would show: clients → Spring MVC controllers → domain services → repositories → relational DB.
- Add a separate security lane for JWT filter, refresh-token service, and blacklist store.
- Add a side integration box for AI provider access, connected only through the AI suggestion service.
- Show Flyway as the schema provisioning path, and Redis as an optional infrastructure dependency used by token blacklisting.
Main entry points: TaskController.java Task API · TaskServiceImpl.java Task service · GlobalExceptionHandler.java Error handler · migration Flyway SQL
Components 27
HTTP API
Spring MVC entrypoints and request/response DTOs
- Auth API · Register, login, refresh, logout, bootstrap admin
src/main/java/com/engine/taskmanagement/auth/controller/AuthController.java - User API · User administration and profile actions
src/main/java/com/engine/taskmanagement/user/controller/UserController.java - Project API · Project CRUD and filtering endpoints
src/main/java/com/engine/taskmanagement/project/controller/ProjectController.java - Task API · Task CRUD, filters, status, and priority changes
src/main/java/com/engine/taskmanagement/task/controller/TaskController.java
Security
JWT auth, current-user context, and token lifecycle
- Security cfg · HTTP security rules and filter wiring
src/main/java/com/engine/taskmanagement/common/config/SecurityConfig.java - JWT filter · Populates authentication from bearer tokens
src/main/java/com/engine/taskmanagement/auth/filter/JwtAuthenticationFilter.java - Auth service · Authentication workflows and credential handling
src/main/java/com/engine/taskmanagement/auth/service/AuthServiceImpl.java - Token service · Refresh tokens, hashing, and blacklist operations
src/main/java/com/engine/taskmanagement/auth/token/service/RefreshTokenService.java - Blacklist store · In-memory or Redis token blacklist backend
src/main/java/com/engine/taskmanagement/auth/token/service/InMemoryTokenBlacklistService.java
Core Domains
Main business areas of projects, tasks, and users
- User service · User lifecycle, profile, and role changes
src/main/java/com/engine/taskmanagement/user/service/implementation/UserServiceImpl.java - Project service · Project rules and persistence orchestration
src/main/java/com/engine/taskmanagement/project/service/implementation/ProjectServiceImpl.java - Task service · Task lifecycle, assignment, and updates
src/main/java/com/engine/taskmanagement/task/service/implementation/TaskServiceImpl.java - Status rules · Allowed transitions and done-state constraints
src/main/java/com/engine/taskmanagement/task/service/implementation/TaskStatusTransitionServiceImpl.java - Activity API · Task timeline and lifecycle event exposure
src/main/java/com/engine/taskmanagement/task/activity/controller/TaskActivityController.java - Comment API · Task discussion and blocker comments
src/main/java/com/engine/taskmanagement/task/comment/controller/TaskCommentController.java - Dependency API · Task dependency management and validation
src/main/java/com/engine/taskmanagement/task/dependency/controller/TaskDependencyController.java - Criteria API · Acceptance criteria CRUD and completion flow
src/main/java/com/engine/taskmanagement/task/criteria/controller/AcceptanceCriteriaController.java
AI Boundary
Draft suggestion integration isolated from persistence
- AI suggestions · Draft acceptance-criteria suggestions for tasks
src/main/java/com/engine/taskmanagement/ai/AiSuggestionController.java - AI service · Builds prompts and adapts provider output
src/main/java/com/engine/taskmanagement/ai/AiAcceptanceCriteriaService.java - Model provider · Disabled default or Gemini-backed model access
src/main/java/com/engine/taskmanagement/ai/AiProvider.java
Persistence
Entities, repositories, and database schema provisioning
- Project repo · Project persistence boundary
src/main/java/com/engine/taskmanagement/project/repository/ProjectRepository.java - Task repo · Task persistence boundary
src/main/java/com/engine/taskmanagement/task/repository/TaskRepository.java - User repo · User persistence boundary
src/main/java/com/engine/taskmanagement/user/repository/UserRepository.java - Refresh repo · Refresh token persistence
src/main/java/com/engine/taskmanagement/auth/token/repository/RefreshTokenRepository.java - Flyway SQL · MySQL and PostgreSQL schema provisioning
src/main/resources/db/migration
Common
Shared configuration and error handling
- Rivet API · Application bootstrap and composition root
src/main/java/com/engine/taskmanagement/RivetApiApplication.java - Error handler · Converts domain and validation failures to API errors
src/main/java/com/engine/taskmanagement/common/exception/GlobalExceptionHandler.java
Connections 30
- Rivet API → Security cfg: configures · Bootstraps the security boundary
- Security cfg → JWT filter: registers · Adds JWT authentication to the filter chain
- JWT filter → Auth service: delegates to · Resolves users and validates bearer tokens
- Auth API → Auth service: calls · Handles register/login/refresh/logout flows
- Auth service → Token service: issues tokens · Creates, rotates, revokes, and hashes refresh tokens
- Token service → Refresh repo: persists · Stores refresh-token records
- Token service → Blacklist store: blacklists · Stores revoked access tokens in memory or Redis
- User API → User service: calls · User management and profile operations
- User service → User repo: persists via · Uses the user repository for account data
- Project API → Project service: calls · Project CRUD and filtering
- Project service → Project repo: persists via · Uses the project repository for project data
- Task API → Task service: calls · Task CRUD, updates, and workflow actions
- Task service → Task repo: persists via · Uses the task repository for task data
- Task service → Status rules: enforces · Applies transition policy and done-state rules
- Task API → Activity API: exposes · Timeline endpoints for task lifecycle events
- Task API → Comment API: exposes · Task comment endpoints
- Task API → Dependency API: exposes · Task dependency endpoints
- Task API → Criteria API: exposes · Acceptance criteria endpoints
- Criteria API → Task service: updates task state · Criteria changes feed into task completion rules
- AI suggestions → AI service: calls · Generates draft acceptance-criteria suggestions
- AI service → Model provider: invokes · Uses configured model provider or disabled fallback
- AI service → Task service: reads task · Builds suggestions from task context only
- Error handler → Auth API: maps errors · Applies consistent API error responses
- Error handler → Project API: maps errors · Applies consistent API error responses
- Error handler → Task API: maps errors · Applies consistent API error responses
- Error handler → User API: maps errors · Applies consistent API error responses
- Project repo → Flyway SQL: schema backed by · Project tables are created by Flyway
- Task repo → Flyway SQL: schema backed by · Task tables are created by Flyway
- User repo → Flyway SQL: schema backed by · User tables are created by Flyway
- Refresh repo → Flyway SQL: schema backed by · Refresh-token table is created by Flyway