Skip to content

naldmach/taskguard-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TaskGuard Management API

A comprehensive RESTful API for task and project management with authentication and role-based access control.

Java Spring Boot Maven H2 License

πŸš€ Features

  • 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

πŸ“‹ Table of Contents

πŸƒ Quick Start

Prerequisites

  • Java 17 or higher
  • Maven 3.9+
  • MySQL 8.0+ (optional, H2 included for development)

Installation

  1. Clone the repository

    git clone https://github.com/naldmach/taskguard-api.git
    cd taskguard-api
  2. Build the project

    mvn clean install
  3. Run the application

    mvn spring-boot:run
  4. 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

Quick Test

# 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"
  }'

πŸ”Œ API Endpoints

Authentication

  • POST /auth/register - Register a new user
  • POST /auth/login - Login and get JWT token

Users

  • GET /users - Get all users (Admin only)
  • GET /users/{id} - Get user by ID
  • PUT /users/{id} - Update user profile
  • DELETE /users/{id} - Deactivate user

Projects

  • GET /projects - Get user's projects
  • POST /projects - Create new project
  • GET /projects/{id} - Get project by ID
  • PUT /projects/{id} - Update project
  • DELETE /projects/{id} - Delete project
  • POST /projects/{id}/members/{userId} - Add member to project
  • DELETE /projects/{id}/members/{userId} - Remove member from project

Tasks

  • GET /tasks - Get user's tasks
  • POST /tasks - Create new task
  • GET /tasks/{id} - Get task by ID
  • PUT /tasks/{id} - Update task
  • DELETE /tasks/{id} - Delete task
  • GET /tasks/project/{projectId} - Get tasks by project

System

  • GET /test/health - Health check endpoint
  • GET /test/info - Application information

πŸ” Authentication

The API uses JWT (JSON Web Tokens) for authentication. After successful login, include the token in the Authorization header:

Authorization: Bearer <your-jwt-token>

Example Authentication Flow

  1. 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"
      }'
  2. Login to get token

    curl -X POST http://localhost:8080/api/auth/login \
      -H "Content-Type: application/json" \
      -d '{
        "username": "johndoe",
        "password": "securepassword"
      }'
  3. Use token for authenticated requests

    curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
      http://localhost:8080/api/projects

πŸ—„οΈ Database Configuration

H2 Database (Development - Default)

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.Driver

H2 Console: http://localhost:8080/api/h2-console

  • JDBC URL: jdbc:h2:mem:testdb
  • Username: sa
  • Password: (leave empty)

MySQL Database (Production)

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.MySQLDialect

πŸ§ͺ Testing

Quick Test Script

Run the comprehensive test script:

./test-api.sh

Manual Testing

# Unit tests
mvn test

# Integration tests
mvn verify

# Build and test
mvn clean install

Testing with Postman/Insomnia

Import the API collection or use the Swagger UI for interactive testing.

For detailed testing instructions, see TESTING.md.

πŸ“š API Documentation

Swagger UI

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

OpenAPI Specification

Raw OpenAPI spec available at: http://localhost:8080/api/api-docs

πŸ› οΈ Development

Project Structure

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

Key Technologies

  • 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

Development Setup

  1. IDE Setup

    • Import as Maven project
    • Configure Java 17
    • Enable annotation processing
  2. Environment Configuration

    # Copy and modify configuration
    cp src/main/resources/application.yml src/main/resources/application-dev.yml
  3. Database Setup

    # For MySQL (optional)
    mysql -u root -p
    CREATE DATABASE taskguard;

Code Quality

  • 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

πŸ”§ Configuration

Application Properties

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: true

Environment Variables

For 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

πŸš€ Deployment

Docker (Coming Soon)

# Build image
docker build -t taskguard-api .

# Run container
docker run -p 8080:8080 taskguard-api

Production Checklist

  • 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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Java coding conventions
  • Write comprehensive tests
  • Update documentation
  • Ensure all tests pass
  • Follow RESTful API design principles

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

  • Issues: GitHub Issues
  • Documentation: Wiki
  • API Reference: http://localhost:8080/api/swagger-ui.html

🎯 Roadmap

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published