# stefanycos/spring-boot-microservices architecture

> Architecture diagram of the GitHub repository stefanycos/spring-boot-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stefanycos/spring-boot-microservices
- Repository: https://github.com/stefanycos/spring-boot-microservices

## Overview

##### Main Components
- API-Gateway – Serves as a centralized access point. It is implemented with Netflix Zuul, and it routes incoming requests to the respective microservices after retrieving available services from Service Discovery.
- Service-Discovery – Implemented with Netflix Eureka. This service manages and registers the instances of all the microservices, enabling dynamic discovery.
- Auth-Server – Handles user authentication, token issuance (via Spring OAuth2), and user/client registration. This service secures the ecosystem.
- AWS-S3-Service – Manages all communication with Amazon S3 for file operations. It includes controllers, exception handling, and S3 configuration.
- Product-Service – Manages products and their associated images. It uses fault tolerance patterns (via Netflix Hystrix) and integrates with the AWS-S3-Service for image handling. The service also leverages MongoDB for data storage.
- External Clients – Represented by end users, mobile apps, or integrated systems (such as the provided Postman Collection) that make API calls to the system.

##### Relationships and Interactions
- External Clients → API-Gateway: All external incoming requests pass through the API Gateway.
- API-Gateway → Service-Discovery: The gateway dynamically fetches the list of active services from the Service Discovery.
- API-Gateway → Auth-Server, Product-Service, AWS-S3-Service: Once discovered, the API Gateway routes requests accordingly.
- Auth-Server ↔ Other Microservices: Other services (like Product-Service) may communicate with the Auth-Server to validate access tokens and retrieve user roles/permissions.
- Product-Service → AWS-S3-Service: The Product-Service communicates with the S3-Service to manage product images.
- Product-Service → MongoDB (implicit): Although not shown explicitly in the file tree, MongoDB is mentioned in the README as the datastore for product information.

##### Architectural Patterns and Design Principles
- Microservices Architecture: Each service is independently deployable with its own Maven build (as seen in the separate directories and Maven wrapper files) and has a clear separation of concerns.
- API Gateway and Service Discovery patterns: The use of Zuul and Eureka demonstrates standard patterns to manage request routing and dynamic service registration.
- Fault Tolerance: Netflix Hystrix is integrated into the Product-Service to provide fallback methods and ensure resilience.
- Security: The Auth-Server uses Spring Security and OAuth2 to secure the ecosystem.
- Configuration and Environment Separation: Each service has its dedicated application.yml for configuration, underscoring the microservices principle of independent configuration management.

##### Relevant Technologies, Frameworks, and Libraries
- Spring Boot (the backbone framework for all services).
- Netflix OSS:
– Zuul for API Gateway.
– Eureka for Service Discovery.
– Hystrix for circuit breaker/fault tolerance (in Product-Service).
- Spring Security & Spring OAuth2 (in Auth-Server).
- Amazon S3 and AWS SDK (in AWS-S3-Service).
- MongoDB (for data storage in Product-Service).

##### Elements
- Clear labels for each component (API-Gateway, Service-Discovery, Auth-Server, AWS-S3-Service, Product-Service, and External Clients).

## Diagram (Mermaid)

```mermaid
flowchart TD
    E["External Clients"]:::external
    A["API-Gateway"]:::service
    D["Service Discovery"]:::service
    U["Auth-Server"]:::service
    P["Product-Service"]:::service
    S["AWS-S3-Service"]:::service
    M["MongoDB"]:::db

    E -->|"request"| A
    A -->|"fetchServices"| D
    A -->|"routesTo"| U
    A -->|"routesTo"| P
    A -->|"routesTo"| S
    P -->|"S3Operations"| S
    P -->|"dataStorage"| M
    P <-->|"authValidation"| U

    click E "https://github.com/stefanycos/spring-boot-microservices/blob/master/Postman Collection.json"
    click A "https://github.com/stefanycos/spring-boot-microservices/blob/master/api-gateway/src/main/java/br/com/springboot/demo/gateway/ApiGatewayApplication.java"
    click D "https://github.com/stefanycos/spring-boot-microservices/blob/master/service-discovery/src/main/java/br/com/springboot/demo/service/discovery/ServiceDiscoveryApplication.java"
    click U "https://github.com/stefanycos/spring-boot-microservices/blob/master/auth-server/src/main/java/br/com/springboot/demo/auth/server/AuthServerApplication.java"
    click P "https://github.com/stefanycos/spring-boot-microservices/blob/master/product-service/src/main/java/br/com/springboot/demo/product/service/ProductServiceApplication.java"
    click S "https://github.com/stefanycos/spring-boot-microservices/blob/master/aws-s3-service/src/main/java/br/com/springboot/demo/s3/service/AwsS3ServiceApplication.java"

    classDef external fill:#FFD700,stroke:#333,stroke-width:2px,color:#000;
    classDef service fill:#87CEEB,stroke:#333,stroke-width:2px,color:#000;
    classDef db fill:#90EE90,stroke:#333,stroke-width:2px,color:#000;
```
