How michaelcaxias/catalogs_api works
Project type and purpose
• This is a backend microservice built with Spring Boot.
• It exposes REST endpoints for managing Categories and Products.
• It also includes an asynchronous consumer that listens to AWS SNS/SQS, composes a catalog per owner, and writes it to AWS S3.
• It persists data in a MongoDB‐compatible store (DocumentDB locally via Docker).
File structure
• Top‐level: pom.xml, docker‐compose.yml (spins up Mongo), README, Postman collection.
• src/main/java/com/michaelcaxias/catalogs/api: Spring Boot Application entry point.
• config: AWS & exception handler & resource configuration.
• controllers: HTTP Controllers for Categories, Products, and a consumer controller.
• domain/services: business logic broken into CategoriesService, ProductsService, CatalogsService, ConsumerService, and related mappers.
• repositories:
• database: Mongo repositories (CategoriesRepository, ProductsRepository)
• aws/sns: SNSService/SNSServiceImpl
• aws/s3: S3Service/S3ServiceImpl
• resources: application.properties/yml for credentials and endpoints.
• tests: unit and integration tests.
README for additional insights
• Confirms the tech stack: Spring Boot, AWS (SNS, SQS, S3, DocumentDB), Docker for Mongo.
• Lists REST endpoints and environment variables.
a. Main components
• API Layer: Spring Boot application
• Data Store: MongoDB/DocumentDB (via Docker or AWS)
• Messaging: AWS SNS topic → AWS SQS queue
• Consumer: inside same Spring Boot app (or could be separate)
• Storage: AWS S3 bucket
• Clients: REST clients (Postman, frontend, other services)
b. Relationships & interactions
1. Client → HTTP REST → API Controllers
2. Controllers → Domain Services → Repositories (Mongo) for CRUD
3. ProductsService or CategoriesService can publish messages via SNSService → SNS topic
4. AWS SNS forwards to SQS
5. ConsumerService polls SQS, receives catalog request messages
6. ConsumerService fetches categories/products from Mongo via Repositories
7. ConsumerService writes generated catalog to S3 via S3Service
8. Optionally notify downstream systems via SNS/SQS
c. Architectural patterns & principles
• Layered architecture: Controllers → Services → Repositories
• Dependency injection via Spring
• Externalized config via application.yml/properties & environment variables
• Asynchronous messaging for heavy catalog generation
• Single microservice deploying both REST API and message consumer (could be split in future)
d. Key technologies
• Spring Boot (Web, Data, AWS integration)
• AWS SDK for Java (SNS, SQS, S3)
• MongoDB driver / Spring Data MongoDB (DocumentDB compatibility)
• Docker Compose for local Mongo
• Maven for build and dependency management