How vuongnhattin/kotkit-spring-boot works
Project type and purpose
• This is a monolithic Spring Boot REST API (“Kotkit”) providing user authentication, video management, comments, friendships, likes, notifications, and file storage.
• It’s intended to serve a web/mobile frontend via JSON over HTTP, with Swagger UI for API testing.
File structure
• src/main/java/com/example/kotkit:
• config: Spring Security (JWT), OpenAPI/Swagger, MinIO, ModelMapper, application properties
• controller: REST controllers (AuthController, VideoController, etc.)
• service: business-logic layer (AuthService, VideoService, MinioService, PermissionService, etc.)
• repository: Spring Data JPA interfaces for persistence
• entity: JPA entities and enums
• dto: input/output payload models
• exception: custom exceptions and global handler
• src/main/resources:
• application.yaml: runtime configuration
• db/migration: Flyway SQL migrations for schema initialization and seed data
• docker-compose.yml + init.sql: spins up the database and MinIO storage.
README insights
• Run “docker compose up -d” to start dependent services (PostgreSQL/MySQL + MinIO).
• Swagger UI available at http://localhost:8080/swagger-ui/index.html for testing endpoints.
Main components
a. Client layer
• Web or mobile clients + Swagger UI
b. API layer
• Spring Security filter chain (JwtAuthFilter)
• REST controllers (AuthController, UserController, VideoController, etc.)
c. Service layer
• Business services: AuthService, VideoService, CommentService, FriendshipService, NotificationService, PermissionService, MinioService, JwtService
d. Persistence layer
• Spring Data JPA repositories (UserRepository, VideoRepository, etc.)
• Relational database (PostgreSQL/MySQL) with Flyway-managed schema
e. External storage
• MinIO object storage for video/avatar files
f. Infrastructure/orchestration
• Docker Compose orchestrator starting DB + MinIO
• Application running on embedded Tomcat via Spring Boot
Relationships and interactions
• Client → HTTP Request → SecurityConfig → JwtAuthFilter → Controller
• Controller → delegates to Service → Service performs business logic → Repository → Database
• VideoService & MinioService → upload/download files → MinIO
• Flyway migrations run at startup to prepare the database schema
• ModelMapperConfig used within services to map between entities and DTOs
• GlobalExceptionHandler intercepts errors and returns ApiResponse wrappers
Architectural patterns and design principles
• Layered (Controller → Service → Repository)
• Dependency injection via Spring
• Separation of concerns: security, config, controllers, services, persistence
• Transactional boundaries at service methods
• JWT-based stateless authentication
• Externalized configuration (application.yaml, .env)