Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sales Microservices Platform

Este README também está disponível em Português.

A Java 21 Spring Boot microservices platform for managing clients, products, and sales. It integrates MongoDB for persistence, Spring Cloud Config Server for centralized configuration, Feign clients for inter-service communication, and OpenAPI/Swagger for API documentation.

🚀 Features

  • Client, Product, and Sales microservices
  • Centralized configuration via Spring Cloud Config Server
  • MongoDB persistence with repository pattern
  • RESTful APIs documented with OpenAPI/Swagger
  • Inter-service communication using Feign clients and RestTemplate
  • Structured error handling with custom exceptions and validation errors
  • Unit and integration tests across services
  • Detailed Javadocs generated for all classes and enums

🛠️ Tech Stack

  • Java: 21
  • Spring Boot: 3.5.4
  • Spring Cloud: 2025.0.0
  • Spring Cloud Config Server
  • MongoDB
  • Feign Clients
  • Springdoc OpenAPI (Swagger UI)
  • Lombok
  • JUnit + Mockito for testing

🐳 Docker Support (dockerized branch)

  • The dockerized branch contains full Docker support.
  • Each service includes a Dockerfile and .dockerignore.
  • docker-compose.yml orchestrates all services and MongoDB.
  • wait-for-it.sh ensures services start only after dependencies are ready.
  • Centralized configs are fetched from ConfigServer using Docker hostnames.

📂 Project Modules

  • ConfigServer: Centralized configuration management for all microservices
  • ClientService: Manage clients (CRUD, search by ID/CPF, validations)
  • ProductService: Manage products (CRUD, search by code, validations)
  • SalesService: Manage sales, sale status lifecycle, and product associations

📑 Domain Overview

  • Client: Entity with validation, unique indexes, and Swagger annotations
  • Product: Entity with validation, status enum (ACTIVE/INACTIVE), and Lombok support
  • Sales: Entity with product management, total price calculation, and status lifecycle (STARTED, FINISHED, CANCELED)
  • DTOs: Transfer objects for Sales, Product, and Client
  • Status Enum: Shared across domains for consistent lifecycle states

📘 Documentation and Javadocs

Includes full Javadocs for all core classes, including:

  • Main classes (SalesServiceApplication, ClientServiceApplication, ProductServiceApplication, ConfigServerApplication).
  • Configurations (MongoConfig, OpenAPIConfig, RestTemplateConfig)
  • Domain classes (Client, Product, ProductQuantity, Sales)
  • DTOs (ClientDTO, ProductDTO, SalesDTO)
  • Services and Use Cases (RegisterClient, SearchClient, RegisterProduct, SearchProduct, RegisterSale, SearchSale)
  • Controllers (ClientResource, ProductResource, SalesResources)
  • Exception handling (ApiError, ApiValidationError, BadRequestException, EntityNotFoundException, RestExceptionHandler)
  • Utilities (RestRequest, RestUtils)
  • Tests (SalesTest, SalesResourcesTest, ProductResourceTest, ClientResourceTest)

🧪 Tests

  • Unit tests for domains (SalesTest, ProductQuantity logic)
  • REST controller tests (SalesResourcesTest, ProductResourceTest, ClientResourceTest)
  • Mockito integration for CRUD operations and validations
  • Exception handling coverage for BadRequest and EntityNotFound

⚙️ Getting Started

  1. Clone the repository:
    git clone https://github.com/AsrielDreemurrGM/Microservices_Online_Selling.git
  2. Start the ConfigServer service.
  3. Start ClientService, ProductService, and SalesService.
  4. Access API documentation at:
    Client Service: http://localhost:8081/swagger-ui.html
    Product Service: http://localhost:8082/swagger-ui.html
    Sales Service: http://localhost:8083/swagger-ui.html
  5. To run with Docker (branch dockerized):
    git checkout dockerized
    docker-compose up --build

📜 Commit History Summary

  • Initial commit with four microservices, config, and build setup
  • Client domain, DTO, repository, use cases, resources, and tests
  • Product domain, DTO, repository, use cases, resources, configs, and tests
  • Sales domain, DTO, services (RegisterSale, SearchSale), resources, and repository
  • ConfigServer setup and YML corrections for microservices
  • Exception handling standardized across services
  • OpenAPI and Mongo configurations added for all services
  • Unit tests created and improved for Client, Product, and Sales services
  • Detailed Javadocs added across all services, controllers, domains, and configs
  • Refactoring of endpoints for clarity
  • Configured Docker for microservices (branch dockerized)

About

A Java 21 Spring Boot microservices platform for managing clients, products, and sales. It leverages MongoDB for persistence, Spring Cloud Config Server for centralized configuration, OpenAPI/Swagger for API documentation, and Feign clients for inter-service communication.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages