/authentication-microservice-with-domain-driven-design

Microservice for authentication with Domain Driven Design and CQRS

Primary LanguageJavaMIT LicenseMIT

Microservice for authentication with Domain-Driven Design

Full Spring Boot authentication microservice with Domain-Driven Design approach.

1. Introduction

1.1. Purpose of this Repository

This is a list of the main goals of this repository:

  • Showing how you can implement a Domain-Drive design
  • Showing how you can implement a CQRS
  • Presentation of the full implementation of an application
    • This is not another proof of concept (PoC)
    • The goal is to present the implementation of an application that would be ready to run in production
  • Showing the application of best practices and object-oriented programming principles
  • Presentation of the use of design patterns. When, how and why they can be used
  • Presentation of the implementation using Domain-Driven Design approach (tactical patterns)
  • Presentation of the implementation of Unit Tests for Domain Model (Testable Design in mind)
  • Presentation of the implementation of Integration Tests
  • Presentation of the implementation of testing Web-Layer only

1.2 Your contribution

  • Give it a star
  • Share it
  • Become a contributor

2. Domain

2.1. Business logic of the repository

The main idea of this repository is to create small microservice for authentication that provides next functionalities:

  • Form Registration
  • Form Login, Google Login, Facebook Login
  • Password recovery
  • Email notifications
  • Session identification and authentication

2.2. How to run

  • Run database docker container first: docker-compose up -d
  • Run application locally with local profile
  • Plan is to dockerize the application in order to run it easy

2.3. How to run tests

  • Run database docker container first: docker-compose up -d. Plan is to add testdb for testing purposes.
  • Run Integration test separately
  • Run Unit test separately
  • Run Web-Layer (tests that are testing Spring Boot implementation and Rest Controller) tests separately

3. Desired TODO List to complete the application:

  • Clean the code from inconsistencies
  • Add more session details
  • Implement a tool like ELK
  • Caching if/when needed
  • More tests
  • CI
  • Pull out 'ddd' folder and create a library
  • Pull out 'CQRS' folders (contracts and configuration) and create a library
  • Finish SpringBoot security and CSFR token
  • Dockerize

4. The main idea is to create a reusable microservice network that consists of the next microservices:

  • Service discovery (probably with K8s).
  • Create a microservice for authentication (current repository).
  • Create a microservice for authorization - simple implementation of RBAC.
  • Create a microservice for sending emails.
  • Create a microservice for localization - the idea is to provide UI for translating the application to various languages as a common part of most applications.
  • Create a microservice for asynchronous communication (AC) - the idea is to create a microservice that distributes the messages between microservices. The microservice should work over DB (e.g. Redis) and RMQ to provide asynchrony. The microservice should provide the REST API for accessing it. In this way, we should have RMQ in only one place and communication with this microservice should go over REST API. The microservice should provide these routes:
    • route for registering messages by other microservices. E.g. Email-Microservice could register message send-email with required properties, endpoint, and version. That configuration should be saved into a DB.
    • sending messages - E.g. Authentication microservice should send a message after registering a user with the name send-email and required properties. The AC microservice will receive that message, validate the required properties, enrich the message body with an endpoint (which is saved in DB) and publish a message to RMQ. The RMQ consumer will consume the message and distribute it to the endpoint.

5. License

The project is under MIT license.

6. Inspiration

6.1. Domain-Driven Design

6.2 Application Architecture

6.2. System Architecture

6.3. Design