Skip to content

HerrKanin/microservices26

Repository files navigation

Distributed Chat Application

A distributed chat application built with Spring Boot using a microservice architecture.


Features

  • JWT authentication
  • Backend-for-Frontend (BFF)
  • Multiple microservices
  • REST communication between services
  • Event-driven architecture with RabbitMQ
  • Bot service consuming message events

Services

BFF

Handles external REST requests and validates JWT tokens before forwarding requests to internal services.

AuthService

Handles login and JWT generation.

UserService

Handles user data and user endpoints.

MessageService

Handles messages and publishes message-published events to RabbitMQ.

BotService

Consumes events from RabbitMQ.


Architecture


Technologies

  • Java
  • Spring Boot
  • Spring Security
  • RabbitMQ
  • JWT
  • RestClient

Ports

Service Port
BFF 8080
AuthService 9000
UserService 9001
MessageService 9002
BotService 9003
RabbitMQ UI 15672

Running the project

Start RabbitMQ

docker start rabbitmq-chat

Start services

Start the following services in IntelliJ:

  • AuthService
  • UserService
  • MessageService
  • BotService
  • BFF

Demo Requests

Login

POST http://localhost:8080/api/login
Content-Type: application/json

{
  "username": "demo",
  "password": "demo"
}

Get users

GET http://localhost:8080/api/users
Authorization: Bearer TOKEN

Get messages

GET http://localhost:8080/api/messages
Authorization: Bearer TOKEN

Create message

POST http://localhost:8080/api/messages
Authorization: Bearer TOKEN
Content-Type: application/json

{
  "content": "Hello from demo"
}

Event Flow

  1. Client sends request to BFF
  2. BFF validates JWT
  3. BFF forwards request to MessageService
  4. MessageService publishes message-published
  5. RabbitMQ distributes the event
  6. BotService consumes the event

Author

Edvin Karlsson

About

Distributed chat application using Spring Boot, JWT and RabbitMQ.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors