Skip to content

santiago-jv/microservices-architecture-example

Repository files navigation

Microservices Architecture for User Registration and Email Validation

This project demonstrates a microservices-based architecture designed to manage user registration and email validation workflows. The architecture focuses on showcasing knowledge of software architecture, rather than emphasizing clean code or advanced code quality standards.

Features

  • User Registration: A service to register new users.
  • Email Validation: Sending emails to users to validate their email addresses.
  • RabbitMQ: Message broker to manage asynchronous communication between microservices.
  • AWS API Gateway with Lambda Authorizer: Provides centralized API routing and authentication.
  • MySQL: Separate databases for each microservice.
  • AWS SQS: Used to queue email notifications.

Architecture

  • Auth Microservice: Handles user registration and authentication.
  • Notification Microservice: Manages email notifications for user validation.
  • RabbitMQ: Facilitates communication between the auth and notification microservices.
  • MySQL Databases: Each microservice has its own isolated database for modularity and separation of concerns.
  • AWS API Gateway with Lambda Authorizer: Secures API endpoints and delegates requests to the respective microservices.

Prerequisites

  • Docker and Docker Compose installed on your machine.
  • AWS credentials for email queue integration.

Getting Started

Setup Environment Variables

Create a .env file in the root directory with the following content:

# Example of environment variables
NODE_ENV=production

# RabbitMQ
RABBITMQ_DEFAULT_USER=user
RABBITMQ_DEFAULT_PASS=password
RABBITMQ_URL=amqp://user:password@rabbitmq:5672
RABBITMQ_NOTIFICATION_QUEUE=notifications

# Auth Microservice
AUTH_PORT=4000
AUTH_DATABASE_HOST=auth-db
AUTH_DATABASE_USERNAME=root
AUTH_DATABASE_PASSWORD=password
AUTH_DATABASE_NAME=auth
AUTH_DATABASE_PORT=3306

# Notification Microservice
NOTIFICATION_PORT=5000
NOTIFICATION_DATABASE_HOST=notification-db
NOTIFICATION_DATABASE_USERNAME=root
NOTIFICATION_DATABASE_PASSWORD=password
NOTIFICATION_DATABASE_NAME=notification
NOTIFICATION_DATABASE_PORT=3306
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
SQS_EMAIL_QUEUE_URL=https://sqs.us-east-1.amazonaws.com/050451404615/email-notification-queue
WEB_URL=http://localhost:3000

Build and Run

  1. Clone the repository.
  2. Navigate to the project directory.
  3. Run the following command:
    docker-compose up --build
    This will set up the RabbitMQ, MySQL databases, and both microservices.

Access Services

Notes

  • This project is intended as an architectural demonstration and may not include production-ready configurations or optimizations.
  • The focus is on microservices design, asynchronous communication, and modularity.

Folder Structure

  • auth-microservice/: Source code for the Auth Microservice.
  • notification-microservice/: Source code for the Notification Microservice.
  • docker-compose.yml: Orchestrates the microservices and dependencies.
  • .env.example: Example environment variables for the project.

License

This project is open-source and available under the MIT License.

About

Microservices Architecture for User Registration and Email Validation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published