A fully functional Kanban board REST API built with Spring Boot, providing task management capabilities with real-time WebSocket notifications, JWT authentication, and comprehensive API documentation.
- Spring Boot 3.2.0: Modern, production-ready framework with excellent ecosystem support
- Java 17: LTS version providing modern language features and performance improvements
- Spring Data JPA: Simplifies database operations with repository pattern
- Hibernate: Industry-standard ORM for entity management
- PostgreSQL 15: Robust, open-source relational database with excellent performance
- Flyway: Database migration tool ensuring version-controlled schema changes
- Spring Security: Comprehensive security framework
- JWT (JSON Web Tokens): Stateless authentication for scalable API access
- BCrypt: Secure password hashing (for future user management)
- Spring WebSocket: WebSocket support for real-time bidirectional communication
- STOMP: Simple Text Oriented Messaging Protocol for WebSocket messaging
- SockJS: Fallback support for browsers that don't support WebSocket
- SpringDoc OpenAPI 3: Automatic OpenAPI 3 specification generation
- Swagger UI: Interactive API documentation and testing interface
- JUnit 5: Modern testing framework
- Mockito: Mocking framework for unit tests
- Testcontainers: Integration testing with real PostgreSQL containers
- Spring Boot Test: Comprehensive testing support
- Gradle: Modern build tool with excellent dependency management
- Docker: Containerization for consistent deployment
- Docker Compose: Multi-container orchestration
- Spring Boot Actuator: Production-ready monitoring and metrics
- Prometheus: Metrics endpoint for monitoring systems
- ✅ REST CRUD operations for tasks
- ✅ Pagination, filtering, and sorting
- ✅ JWT-based authentication
- ✅ Real-time WebSocket notifications
- ✅ OpenAPI 3 / Swagger UI documentation
- ✅ Bean validation with custom error handling
- ✅ Optimistic locking for concurrent updates
- ✅ JSON Merge Patch support for partial updates
- ✅ Database migrations with Flyway
- ✅ Comprehensive test coverage (≥80%)
- ✅ Dockerized environment
- ✅ Health checks and metrics endpoints
- Java 17 or higher
- Docker and Docker Compose (for containerized deployment)
- PostgreSQL 15 (for local development without Docker)
- Clone the repository:
git clone <repository-url>
cd task- Build and start the application:
docker-compose up --buildThe application will be available at:
- API: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger-ui.html
- GraphiQL: http://localhost:8080/graphiql.html
- WebSocket Test: http://localhost:8080/websocket-test.html
- Health Check: http://localhost:8080/actuator/health
- Start PostgreSQL database:
docker run -d \
--name kanban-postgres \
-e POSTGRES_DB=kanban_db \
-e POSTGRES_USER=kanban_user \
-e POSTGRES_PASSWORD=kanban_pass \
-p 5432:5432 \
postgres:15-alpine- Build the application:
./gradlew build- Run the application:
./gradlew bootRunOr run the JAR:
java -jar build/libs/kanban-api-1.0.0.jar./gradlew bootRunThe application provides interactive HTML pages for testing WebSocket notifications and GraphQL queries:
Access the WebSocket test interface at: http://localhost:8080/websocket-test.html
This page allows you to:
- Connect to the WebSocket endpoint (
/ws) - Subscribe to task notifications (
/topic/tasks) - Create, update, and delete tasks via REST API
- View real-time WebSocket notifications when tasks are modified
- Test the complete WebSocket notification flow
Features:
- Real-time connection status indicator
- JWT token management (get token button)
- Full CRUD operations for tasks
- Live message display showing all WebSocket events
- Event types:
CREATED,UPDATED,DELETED
Access the GraphQL interface at: http://localhost:8080/graphiql.html
This interactive GraphQL playground allows you to:
- Write and execute GraphQL queries and mutations
- Explore the GraphQL schema
- Test all GraphQL operations (queries and mutations)
- View query results in real-time
Example Query:
query {
tasks {
content {
id
title
status
priority
}
totalElements
}
}Example Mutation:
mutation {
createTask(input: {
title: "New Task"
status: TO_DO
priority: MED
}) {
id
title
status
createdAt
}
}Both interfaces are publicly accessible and require no authentication to load, though the GraphQL endpoint and REST API endpoints require JWT tokens for operations.
Application configuration is in src/main/resources/application.yml. Key settings:
- Database: Configured for PostgreSQL
- JWT Secret: Set via
JWT_SECRETenvironment variable (default provided for development) - Server Port: 8080 (configurable)
- Flyway: Enabled for automatic database migrations
First, obtain a JWT token:
POST /api/auth/login
Content-Type: application/json
{
"username": "testuser",
"password": "password"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Use the token in subsequent requests:
Authorization: Bearer <token>
GET /api/tasks?status=TO_DO&page=0&size=20&sort=createdAt,desc
Authorization: Bearer <token>Query Parameters:
status(optional): Filter by status (TO_DO, IN_PROGRESS, DONE)page(optional): Page number (default: 0)size(optional): Page size (default: 20)sort(optional): Sort fields (e.g.,createdAt,descortitle,asc)
GET /api/tasks/{id}
Authorization: Bearer <token>POST /api/tasks
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "Task Title",
"description": "Task description",
"status": "TO_DO",
"priority": "MED"
}PUT /api/tasks/{id}
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "Updated Title",
"description": "Updated description",
"status": "IN_PROGRESS",
"priority": "HIGH"
}PATCH /api/tasks/{id}
Authorization: Bearer <token>
Content-Type: application/merge-patch+json
{
"status": "DONE"
}DELETE /api/tasks/{id}
Authorization: Bearer <token>{
"id": 1,
"title": "Task Title",
"description": "Task description",
"status": "TO_DO",
"priority": "MED",
"version": 0,
"createdAt": "2024-01-01T10:00:00",
"updatedAt": "2024-01-01T10:00:00"
}Status Values: TO_DO, IN_PROGRESS, DONE
Priority Values: LOW, MED, HIGH
The API emits WebSocket events to /topic/tasks when tasks are created, updated, or deleted.
const socket = new SockJS('http://localhost:8080/ws');
const stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
console.log('Connected: ' + frame);
stompClient.subscribe('/topic/tasks', function(message) {
const event = JSON.parse(message.body);
console.log('Event:', event.eventType, event.payload);
});
});CREATED: Task createdUPDATED: Task updatedDELETED: Task deleted
./gradlew test./gradlew test --tests "*Test"./gradlew test --tests "*IntegrationTest"Generate test coverage report:
./gradlew jacocoTestReportView report: build/reports/jacoco/test/html/index.html
GET /actuator/healthGET /actuator/prometheusdocker build -t kanban-api:1.0.0 .docker-compose up -ddocker-compose logs -f appdocker-compose downdocker-compose down -vsrc/
├── main/
│ ├── java/com/kanban/
│ │ ├── config/ # Configuration classes
│ │ ├── controller/ # REST controllers
│ │ ├── dto/ # Data Transfer Objects
│ │ ├── entity/ # JPA entities
│ │ ├── exception/ # Exception handling
│ │ ├── mapper/ # MapStruct mappers
│ │ ├── model/ # Enums and models
│ │ ├── repository/ # JPA repositories
│ │ ├── security/ # Security configuration
│ │ └── service/ # Business logic
│ └── resources/
│ ├── db/migration/ # Flyway migrations
│ └── application.yml # Application configuration
└── test/
└── java/com/kanban/
├── integration/ # Integration tests
├── mapper/ # Mapper tests
└── service/ # Service tests
- All
/api/**endpoints require JWT authentication /swagger-ui.htmland/v3/api-docs/**are publicly accessible- JWT tokens expire after 24 hours (configurable)
- CORS is enabled for cross-origin requests
- Response time for
GET /api/tasks?page=0&size=50is ≤ 150ms on local laptop - Database indexes on
statusandcreated_atcolumns - Pagination implemented for efficient data retrieval
This project is part of a Spring Boot assignment.
This is an assignment project. For questions or issues, please contact the project maintainer.