A comprehensive RESTful API for task and project management with authentication and role-based access control.
- User Management: Registration, authentication, and profile management
- Project Management: Create, update, and manage projects with team collaboration
- Task Management: Comprehensive task tracking with priorities, due dates, and assignments
- Role-Based Access Control: Admin, Manager, and User roles with appropriate permissions
- JWT Authentication: Secure token-based authentication
- RESTful API: Clean, well-documented REST endpoints
- Database Support: H2 (development) and MySQL (production) support
- API Documentation: Interactive Swagger UI documentation
- Comprehensive Testing: Unit tests, integration tests, and API testing scripts
- Quick Start
- API Endpoints
- Authentication
- Database Configuration
- Testing
- API Documentation
- Development
- Contributing
- License
- Java 17 or higher
- Maven 3.9+
- MySQL 8.0+ (optional, H2 included for development)
-
Clone the repository
git clone https://github.com/naldmach/taskguard-api.git cd taskguard-api -
Build the project
mvn clean install
-
Run the application
mvn spring-boot:run
-
Access the application
- API Base URL:
http://localhost:8080/api - Swagger UI:
http://localhost:8080/api/swagger-ui.html - H2 Console:
http://localhost:8080/api/h2-console
- API Base URL:
# Check if the API is running
curl http://localhost:8080/api/test/health
# Register a new user
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"email": "[email protected]",
"password": "password123",
"firstName": "Test",
"lastName": "User"
}'POST /auth/register- Register a new userPOST /auth/login- Login and get JWT token
GET /users- Get all users (Admin only)GET /users/{id}- Get user by IDPUT /users/{id}- Update user profileDELETE /users/{id}- Deactivate user
GET /projects- Get user's projectsPOST /projects- Create new projectGET /projects/{id}- Get project by IDPUT /projects/{id}- Update projectDELETE /projects/{id}- Delete projectPOST /projects/{id}/members/{userId}- Add member to projectDELETE /projects/{id}/members/{userId}- Remove member from project
GET /tasks- Get user's tasksPOST /tasks- Create new taskGET /tasks/{id}- Get task by IDPUT /tasks/{id}- Update taskDELETE /tasks/{id}- Delete taskGET /tasks/project/{projectId}- Get tasks by project
GET /test/health- Health check endpointGET /test/info- Application information
The API uses JWT (JSON Web Tokens) for authentication. After successful login, include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>-
Register a user
curl -X POST http://localhost:8080/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "username": "johndoe", "email": "[email protected]", "password": "securepassword", "firstName": "John", "lastName": "Doe" }'
-
Login to get token
curl -X POST http://localhost:8080/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "username": "johndoe", "password": "securepassword" }'
-
Use token for authenticated requests
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \ http://localhost:8080/api/projects
The application uses H2 in-memory database by default for easy development:
spring:
datasource:
url: jdbc:h2:mem:testdb
username: sa
password:
driver-class-name: org.h2.DriverH2 Console: http://localhost:8080/api/h2-console
- JDBC URL:
jdbc:h2:mem:testdb - Username:
sa - Password: (leave empty)
To use MySQL, update application.yml:
spring:
datasource:
url: jdbc:mysql://localhost:3306/taskguard?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
username: your_username
password: your_password
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialectRun the comprehensive test script:
./test-api.sh# Unit tests
mvn test
# Integration tests
mvn verify
# Build and test
mvn clean installImport the API collection or use the Swagger UI for interactive testing.
For detailed testing instructions, see TESTING.md.
Interactive API documentation is available at:
http://localhost:8080/api/swagger-ui.html
Features:
- Try out API endpoints directly
- View request/response schemas
- Test authentication flows
- Download OpenAPI specification
Raw OpenAPI spec available at: http://localhost:8080/api/api-docs
src/
βββ main/
β βββ java/com/taskguard/
β β βββ config/ # Configuration classes
β β βββ controller/ # REST controllers
β β βββ dto/ # Data Transfer Objects
β β βββ entity/ # JPA entities
β β βββ repository/ # Data repositories
β β βββ security/ # Security configuration
β β βββ service/ # Business logic services
β βββ resources/
β βββ application.yml # Configuration
β βββ application-test.yml
βββ test/ # Test classes
- Spring Boot 3.2.0 - Application framework
- Spring Security 6.2.0 - Authentication and authorization
- Spring Data JPA - Data persistence
- JWT (JJWT 0.12.3) - Token-based authentication
- H2/MySQL - Database support
- Swagger/OpenAPI 3 - API documentation
- Maven - Build and dependency management
-
IDE Setup
- Import as Maven project
- Configure Java 17
- Enable annotation processing
-
Environment Configuration
# Copy and modify configuration cp src/main/resources/application.yml src/main/resources/application-dev.yml -
Database Setup
# For MySQL (optional) mysql -u root -p CREATE DATABASE taskguard;
- Linting: All code follows Java conventions
- Testing: Comprehensive unit and integration tests
- Security: JWT-based authentication with role-based access control
- Documentation: Swagger/OpenAPI documentation
Key configuration options in application.yml:
# Server configuration
server:
port: 8080
servlet:
context-path: /api
# JWT configuration
jwt:
secret: your-secret-key-here-make-it-very-long-and-secure-in-production
expiration: 86400000 # 24 hours
# Database configuration
spring:
datasource:
url: jdbc:h2:mem:testdb
username: sa
password:
jpa:
hibernate:
ddl-auto: update
show-sql: trueFor production, use environment variables:
export JWT_SECRET=your-very-secure-secret-key
export DB_URL=jdbc:mysql://localhost:3306/taskguard
export DB_USERNAME=taskguard_user
export DB_PASSWORD=secure_password# Build image
docker build -t taskguard-api .
# Run container
docker run -p 8080:8080 taskguard-api- Update JWT secret key
- Configure production database
- Set up HTTPS/SSL
- Configure logging levels
- Set up monitoring and health checks
- Configure CORS for production domains
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Java coding conventions
- Write comprehensive tests
- Update documentation
- Ensure all tests pass
- Follow RESTful API design principles
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: Wiki
- API Reference:
http://localhost:8080/api/swagger-ui.html
- Docker containerization
- CI/CD pipeline setup
- Email notifications
- File upload support
- Advanced reporting features
- Mobile API optimizations
- GraphQL support
- Real-time updates with WebSockets
Made with β€οΈ using Spring Boot