Skip to content

gitnyasha/java-spring-angular-task-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Manager Microservices Application

This is a microservices-based task management system built with Spring Boot and Spring Cloud Gateway. It allows users to register, log in, and manage their tasks securely using JWT authentication.


Services

1. Auth Service (authservice)

  • Handles user registration, login, and JWT authentication.
  • Issues JWT tokens containing the userId upon login.
  • Validates JWT tokens for security.
  • Endpoints:
    • POST /auth/register – Register a new user.
    • POST /auth/login – Authenticate a user and return a JWT.
    • GET /auth/validate – Validate a JWT token.
    • GET /auth/user – Retrieve user information from JWT.

2. Task Service (taskservice)

  • Manages tasks for authenticated users.
  • Supports CRUD operations:
    • POST /tasks – Create a new task.
    • GET /tasks – Get all tasks for the current user.
    • GET /tasks/{id} – Get a specific task by ID.
    • PUT /tasks/{id} – Update an existing task.
    • DELETE /tasks/{id} – Delete a task.
  • Extracts userId from JWT to ensure user-specific task access.

3. API Gateway

  • Routes requests to the appropriate service.
  • Validates JWT tokens before forwarding requests.
  • Handles cross-cutting concerns like CORS and security.
  • Routes configured:
    • /auth/** → Auth Service
    • /api/tasks/** → Task Service

Workflow

  1. User Registration & Login

    • User registers via Auth Service.
    • Logs in to receive a JWT token.
  2. Task Operations

    • All task requests go through the API Gateway.
    • Gateway validates the JWT token.
    • Task Service extracts userId from the token.
    • CRUD operations are performed only for the authenticated user.

Key Features

  • Token-based authentication (JWT)
  • Microservices architecture with API Gateway routing
  • Secure, per-user task access
  • No repeated calls to Auth Service per request

Configuration

API Gateway (application.yml)

server:
  port: 4000

jwt:
  secret: V1JkR2F5bU9XbXhZcVBlTmRWRWl3aXhqY2N0ZkZsU1o=

auth:
  service:
    url: http://localhost:4001

spring:
  cloud:
    gateway:
      server:
        webflux:
          routes:
            - id: auth-service-route
              uri: http://localhost:4001
              predicates:
                - Path=/auth/**
              filters:
                - StripPrefix=1

            - id: task-service-route
              uri: http://localhost:4002
              predicates:
                - Path=/api/tasks/**
              filters:
                - StripPrefix=1
                - JwtValidation

Technology Stack

  • Spring Boot

  • Spring Data JPA (H2)

  • Spring Cloud Gateway

  • JWT (io.jsonwebtoken)

  • Java 21

  • Angular

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published