/spring-cloud-example

This repository demonstrates a Spring Cloud Microservice Architecture with components including a Discovery Server, Config Server, API Gateway, Auth Server (OAuth2), Sample Services, Monitoring System (Zipkin, Prometheus, Grafana) and Logging System (ELK).

Primary LanguageJava

Spring Cloud Microservice Example

This project is a sample microservice architecture using Spring Cloud. It demonstrates how to build, deploy, and manage a scalable and maintainable microservice system. The example includes several components such as a discovery server, config server, API gateway, auth server, multiple sample services, and an observability stack.

  1. Discovery Server
  2. Config Server
  3. API Gateway
  4. Auth Server
  5. Observability
  6. Sample Service 1
  7. Sample Service 1 Client
  8. Sample Service 2
  9. Sample Service 2 Client

Discovery Server

The Discovery Server is responsible for service registration and discovery, allowing microservices to locate and communicate with each other in a distributed system. Learn more

Config Server

The Config Server serves as a centralized configuration service for all microservices in your system, providing versioned configuration data for applications. Learn more

API Gateway

The API Gateway acts as a single entry point for all microservices within the system, providing load balancing, routing, and other features to improve the system's scalability and maintainability. Learn more

Auth Server

The Auth Server is responsible for handling authentication and authorization of users, providing secure access to protected resources across microservices. Learn more

Observability

The observability module contains monitoring and logging systems that provide insights into the microservices behavior and performance in real-time. It includes Elasticsearch, Logstash, and Kibana (ELK Stack) for log aggregation, search, and visualization. Additionally, it uses Grafana, Prometheus, and Zipkin for real-time monitoring and tracing of the microservices.

  • Logging System

    The logging system is based on ELK Stack which collects, processes, and visualizes microservices' logs. Learn more

  • Monitoring System

    The monitoring system uses Grafana and Prometheus for real-time monitoring, and Zipkin for distributed tracing. Learn more

Sample Service 1

Sample Service 1 is a microservice within the project that demonstrates the capabilities of a Spring Boot-based microservice. Learn more

Sample Service 1 Client

Sample Service 1 Client is a library within the project that provides an easy-to-use client for the Sample Service 1 microservice. It includes a Feign client, OAuth2 support, and Spring Boot auto-configuration. Learn more

Sample Service 2

Sample Service 2 is a microservice within the project that demonstrates the capabilities of a Spring Boot-based microservice. Learn more

Sample Service 2 Client

Sample Service 2 Client is a library within the project that provides an easy-to-use client for the Sample Service 2 microservice. It includes a Feign client, OAuth2 support, and Spring Boot auto-configuration. Learn more

Getting Started

Please refer to the README files of each individual component for instructions on how to build, configure, and run them.

Endpoints

Sample Service 1 Endpoints

  1. Endpoint:

    GET http://127.0.0.1:4000/service-1/echo

    Curl:

    curl --location 'http://127.0.0.1:4000/service-1/echo' \
    --header 'Authorization: Bearer {authorization token}'

    Response:

    {
      "echo": "[sample-service-1] : echo"
    }
  2. Endpoint:

    GET http://127.0.0.1:4000/service-1/echo/service-1-to-service-2

    Curl:

    curl --location 'http://127.0.0.1:4000/service-1/echo/service-1-to-service-2' \
    --header 'Authorization: Bearer {authorization token}'

    Response:

    {
      "echo": "[sample-service-2] echo"
    }

Sample Service 2 Endpoints

  1. Endpoint:

    GET http://127.0.0.1:4000/service-2/echo

    Curl:

    curl --location 'http://127.0.0.1:4000/service-2/echo' \
    --header 'Authorization: Bearer {authorization token}'

    Respose:

    {
      "echo": "[sample-service-2] : echo"
    }
  2. Endpoint:

    GET http://127.0.0.1:4000/service-2/echo/service-2-to-service-1

    Curl:

    curl --location 'http://127.0.0.1:4000/service-2/echo/service-1-to-service-2' \
    --header 'Authorization: Bearer {authorization token}'

    Respose:

    {
      "echo": "[sample-service-1] : echo"
    }

Contributing

Please feel free to submit issues, fork the repository, and send pull requests to contribute to the project.

License

This project is licensed under the terms of the MIT License.