Skip to content

thadeucbr/desafio_btg_microservicos

Repository files navigation

DESAFIO_BTG_MICROSERVICOS-logo

DESAFIO_BTG_MICROSERVICOS

Empowering Scalable Solutions, One Microservice at a Time!

last-commit repo-top-language repo-language-count


Table of Contents

Overview

The desafio_btg_microservicos project is a scalable microservices architecture designed to manage essential business processes such as client management, order processing, product handling, and user authentication. By utilizing technologies like NestJS, PostgreSQL, and RabbitMQ, the project ensures efficient communication and data management across distinct services. Its modular design promotes maintainability, allowing individual services to operate independently while seamlessly integrating to fulfill complex workflows. This architecture enhances operational efficiency and facilitates robust service interactions, ultimately delivering a reliable and high-performance solution for modern application needs.


Features

Feature Description
⚙️ Architecture Microservices architecture powered by NestJS and RabbitMQ, utilizing PostgreSQL for data persistence. Each service encapsulates specific business functionalities, enhancing modularity and scalability.
🔩 Code Quality Code adheres to TypeScript best practices, enhanced by ESLint and Prettier configurations. Unit tests validate functionality, ensuring reliable and maintainable code across modules.
📄 Documentation Documentation is present through code comments and Swagger integration, facilitating API clarity. Config files like .eslintrc.js and docker-compose.yml support setup and deployment.
🔌 Integrations Key integrations include RabbitMQ for messaging, PostgreSQL via TypeORM for data management, and Swagger for API documentation. Utilizes various NestJS modules for added functionality.
🧩 Modularity The codebase is modular, with separate directories for each microservice (e.g., login, product, order). This fosters independent development, testing, and deployment of individual services.
🧪 Testing Utilizes Jest for unit and end-to-end testing, ensuring comprehensive coverage for service functionalities. Individual tests for controllers, services, and integration points are present.
⚡️ Performance Efficient use of resources through microservices that handle specific functions. RabbitMQ provides asynchronous messaging, enhancing responsiveness and throughput.
🛡️ Security Implements JWT for secure user authentication and authorization. Input validation and password hashing (bcrypt) ensure data protection and compliance with security standards.
📦 Dependencies Key dependencies include NestJS modules for core functionalities, RabbitMQ client libraries, TypeORM for database interactions, and various development tools (ESLint, Jest, Prettier).
🚀 Scalability The microservices architecture enables horizontal scaling. Each service can independently scale based on demand, with RabbitMQ facilitating communication between services as load increases.

Repository Structure

└── desafio_btg_microservicos/
    ├── consumer
    │   ├── client
    │   ├── login
    │   ├── mailer
    │   ├── order
    │   └── product
    ├── docker-compose.yml
    ├── init.sql
    └── producer
        ├── .eslintrc.js
        ├── .gitignore
        ├── .prettierrc
        ├── README.md
        ├── nest-cli.json
        ├── package-lock.json
        ├── package.json
        ├── src
        ├── test
        ├── tsconfig.build.json
        └── tsconfig.json

Modules

.
File Summary
init.sql Facilitates the creation of essential databases for the microservices architecture within the repository, specifically establishing client_db, login_db, order_db, and product_db. This foundational setup supports the functionality of various components in the consumer and producer directories, ensuring seamless data management and service interaction.
docker-compose.yml Facilitates container orchestration for the desafio_btg_microservicos repository by defining services for PostgreSQL, RabbitMQ, and multiple consumer applications. Ensures seamless integration and communication between components while managing dependencies and data persistence, vital for the microservices architecture’s functionality and scalability.
producer
File Summary
package.json Defines the configuration for the producer microservice within the repository, establishing essential scripts for building, testing, and running the service. It manages dependencies for NestJS applications, facilitating integration with messaging systems and ensuring a robust development environment to support microservice architecture.
tsconfig.build.json Facilitates the TypeScript build configuration for the producer microservice by extending the base settings while excluding irrelevant directories such as node_modules, test, and distribution files. This enhances the overall architecture by streamlining the build process and ensuring efficiency in compiling the services code.
tsconfig.json Defines TypeScript configuration parameters for the producer component, ensuring compatibility and optimization across the microservices architecture. It enhances code maintainability and facilitates smooth development processes by enabling features like decorator metadata and incremental builds, ultimately contributing to the repositorys robustness and effectiveness.
nest-cli.json Defines configuration settings for the NestJS application, establishing the source directory and compiler options. It facilitates streamlined development by ensuring the output directory is cleaned before each build, aligning with the microservices architecture of the repository to enhance modular and maintainable code practices.
package-lock.json The primary aim of this code file is to implement a specific service within the broader microservices system, contributing to seamless communication between different service components and enhancing operational efficiency.### Critical Features:-**Decoupling of ServicesThe structure allows for individual services (such as login, mailer, order, product) to operate independently while still being part of a cohesive application.-**IntegrationIt ensures that the services can easily interact with each other, supporting key functionalities that are crucial for business processes.-**Configuration and Environment ManagementThe inclusion of configuration files (like .eslintrc.js, .prettierrc) indicates a focus on maintaining code quality and consistent formatting across the project.Overall, this code file encapsulates essential logic that supports the microservices architecture of the repository, enhancing both modularity and maintainability.
.eslintrc.js Facilitates code quality by configuring ESLint for TypeScript within the producer module. Ensures adherence to best practices and integrates seamlessly with Prettier, promoting consistency in coding standards across the repository, thus enhancing maintainability and collaboration among developers.
producer.test
File Summary
app.e2e-spec.ts Facilitates end-to-end testing for the application within the producer module of the repository. It ensures the applications primary route is functional, returning the expected response, thereby contributing to the overall reliability and robustness of the microservices architecture.
jest-e2e.json Facilitating end-to-end testing within the producer module of the repository, this configuration file defines the testing environment and rules. It ensures compatibility with TypeScript and JavaScript tests, promoting a streamlined testing process that enhances code reliability and supports the overall microservices architecture in development.
producer.src
File Summary
app.controller.spec.ts Facilitates unit testing for the AppController within the producer module, ensuring that the controller behaves as expected. By validating its core functionality, it enhances the overall reliability of the microservices architecture, contributing to a robust application design that adheres to best practices in software development.
app.service.ts Facilitates a foundational service within the producer module, offering a simple greeting message that directs users to the API endpoint. This functionality enhances user interaction and establishes a basic entry point for further integrations, aligning seamlessly with the microservices architecture of the repository.
app.module.ts Defines the core application module for the microservices architecture, integrating essential functionalities through imports of various feature modules like Client, Order, Product, and Login. Facilitates organized service management and establishes a cohesive structure that enhances the maintainability and scalability of the overall system.
app.controller.ts Facilitates communication within the producer microservice by defining a central controller that responds to HTTP GET requests. It delegates core functionality to the AppService, enhancing modularity and simplifying the integration of additional routes in line with the repositorys microservices architecture.
main.ts Bootstrapping the NestJS application establishes the foundation for the producer microservice, integrating global validation and enhancing API accessibility through Swagger documentation. This setup fosters efficient communication between services within the broader architecture, aligning with the repositorys focus on modular and scalable microservice design.
producer.src.product
File Summary
product.controller.spec.ts Tests the functionality and integrity of the ProductController within the producer module, ensuring that it is properly defined and integrated with the ProductService. This validation supports the overall architecture by enhancing reliability and maintainability of the product management features in the microservices ecosystem.
product.controller.ts Enables product management within the microservices architecture by providing essential operations such as adding, retrieving, updating, and deleting products. Integrates with the product service to handle business logic and utilizes Swagger for API documentation, ensuring clear communication of functionality and enhancing developer experience.
product.module.ts Defines a ProductModule that establishes the product microservice within the architecture. It integrates with RabbitMQ for message transport and incorporates the ProductController and ProductService, enabling the efficient handling of product-related operations while ensuring scalable communication in the overall microservices ecosystem.
product.service.spec.ts Ensures the robustness of the ProductService by implementing unit tests within the producer module of the microservices architecture. This testing framework promotes reliability and maintainability, aligning with the repositorys objective to deliver a well-structured, high-quality service-oriented application.
product.service.ts Enhancing product management within the microservices architecture, the ProductService facilitates key operations such as adding, retrieving, updating, and deleting products through a RabbitMQ messaging system. It ensures efficient communication with other microservices, thereby contributing to a seamless flow of product-related functionalities in the overall system.
product.dto.ts Defines the ProductDto class to standardize product data representation within the producer microservice. Key attributes include product name, price, description, image URL, and stock quantity, facilitating clear API documentation and communication between services in the overall microservices architecture.
producer.src.client
File Summary
client.module.ts Facilitates the integration of client-related functionalities within the microservices architecture by defining a dedicated module that establishes communication with a RabbitMQ message broker. It encapsulates the ClientController and ClientService, enabling efficient handling of client data and operations within the broader producer service ecosystem.
client.service.ts Facilitates client management within a microservices architecture by providing essential functions to create, retrieve, update, and delete client records. Integrates seamlessly with the event-driven communication model, ensuring efficient data handling and responsiveness while supporting service scalability and maintainability in the overall repository structure.
client.controller.ts Facilitates client management within the microservices architecture by providing endpoints for creating, updating, retrieving, and deleting client information. It enhances the applications API layer, promoting effective communication between services while ensuring a robust and consistent client data handling experience.
client.controller.spec.ts Tests the ClientControllers functionality within the producer module, ensuring its proper instantiation and integration with the ClientService. This contributes to the repositorys architecture by reinforcing the reliability and maintainability of the microservices framework, ultimately supporting robust client interactions across the application.
client.dto.ts Defines a Client Data Transfer Object (DTO) that standardizes client information, ensuring data integrity and validation within the producer component of the desafio_btg_microservicos repository. It facilitates seamless communication between microservices while maintaining compliance with API documentation and user input validation protocols.
client.service.spec.ts Tests the functionality of the ClientService, ensuring that it is properly defined and instantiated within the NestJS testing framework. This validation plays a crucial role in maintaining the integrity of the producer microservice, ensuring reliable communication and client management within the broader architecture of the desafio_btg_microservicos repository.
producer.src.login
File Summary
login.module.ts Facilitates user authentication by defining the LoginModule, which integrates RabbitMQ for message handling. It establishes the foundational structure for login operations within the microservices architecture, linking the LoginService and LoginController to ensure efficient communication and service management in the broader application ecosystem.
login.dto.ts Facilitates user authentication within the producer component by defining a data transfer object for login credentials. It ensures validation of the email format and password as strings, enhancing security and compliance with API standards in the broader microservices architecture of the repository.
login.service.spec.ts Ensures the integrity of the LoginService by establishing foundational tests within the producer module of the repository. It verifies that the service is properly defined, contributing to the overall robustness of the microservices architecture by facilitating reliable user authentication processes.
login.service.ts Facilitates user authentication within the microservices architecture by providing a LoginService that communicates with a messaging client. It sends login credentials to the LOGIN_SERVICE, ensuring timely responses through a defined timeout, thereby enhancing the overall efficiency and responsiveness of the login functionality in the consumer module.
login.controller.ts Facilitates user authentication within the microservices architecture by handling login requests. It defines routes for user credentials submission and delegates the authentication logic to the LoginService, enhancing security and streamlining access management in the producer module. This functionality is essential for maintaining user sessions effectively.
login.controller.spec.ts Tests for the LoginController ensure its proper integration within the microservices architecture of the repository. By validating the controllers instantiation and its reliance on the LoginService, this module enhances the robustness of the authentication feature, contributing to the overall reliability and functionality of the producer service.
producer.src.strategy
File Summary
jwt.strategy.ts Implements JWT authentication strategy within the microservices architecture, ensuring secure user validation by extracting and verifying JWT tokens from authorization headers. Enhances overall security and user management for the producer services, contributing to a robust authentication framework vital for the systems integrity and functionality.
producer.src.order
File Summary
order.dto.ts Facilitates the definition of order-related data structures within the producer microservice. It ensures validation and type safety for order and product details, enhancing the communication between services while adhering to the overall architecture by leveraging NestJSs capabilities for building robust and maintainable applications.
order.service.ts Facilitates order management within the microservices architecture by enabling the placement, retrieval, and deletion of orders through a messaging client. It streamlines communication between services, enhancing the overall functionality and responsiveness of the order-related processes in the system.
order.module.ts Facilitates the order management process within the microservices architecture by integrating authentication and authorization through JWT and Passport. Establishes a communication pathway with other services via RabbitMQ, ensuring durable message handling, thereby promoting scalability and reliability of order-related functionalities in the overall system.
order.controller.ts Facilitates order management within the microservices architecture by providing endpoints for placing, retrieving, and deleting orders. Ensures secure access through JWT authentication and integrates Swagger for API documentation, aligning with the repositorys focus on efficient service interactions and streamlined order processing.
order.service.spec.ts Tests the functionality of the OrderService within the producer module, ensuring that essential components are properly defined and initialized. This unit test reinforces the architectural integrity of the microservices by verifying that the order management functionality operates as expected, contributing to the overall reliability of the system.
order.controller.spec.ts Tests the functionality and integration of the OrderController within the microservices architecture. Validates that the controller is properly defined and operational, ensuring that order management services are reliable and facilitate seamless interactions across the consumer and producer components of the application.
consumer.product
File Summary
package.json Defines the package configuration for the product microservice within the larger architecture, enabling essential functionalities like building, testing, and starting the service. Manages dependencies critical for NestJS operations and microservice communication, ensuring seamless integration and scalability in the broader application ecosystem.
tsconfig.build.json Configures TypeScript build options for the product consumer module, ensuring a streamlined compilation process by extending existing settings. It effectively excludes unnecessary directories and test specifications, promoting efficiency in the development workflow and maintaining focus on essential source files within the larger microservices architecture.
tsconfig.json Configures TypeScript compiler options for the product microservice within the desafio_btg_microservicos repository. It ensures compatibility with modern JavaScript features, maintains declaration files, and optimizes build performance while facilitating smooth integration with other microservices in the architecture.
nest-cli.json Defines configuration settings for the NestJS framework, facilitating the development of the product microservice within the repository. It establishes the source directory and optimizes build processes by automatically deleting previous output directories, thereby enhancing maintainability and streamlining development workflows.
package-lock.json Modular DesignEach microservice, such as login, order, and product, is encapsulated within its own directory, promoting scalability and maintainability.-**Microservice IntercommunicationThe repository likely implements distinct services that communicate over defined protocols, enabling a cohesive system that can handle complex workflows.-**Configuration and InitializationThe presence of configuration files (e.g., docker-compose.yml, init.sql) indicates a structured approach to service deployment and database initialization, essential for efficient setup and development.Overall, this repository structure reflects a well-thought-out architecture aimed at developing a robust, scalable microservices ecosystem.
.eslintrc.js Configures ESLint for the product consumer module, ensuring adherence to TypeScript best practices while supporting code quality and consistency. It integrates with Prettier for style enforcement and specifies environment settings for Node and Jest, fostering a maintainable and efficient development experience within the broader microservices architecture.
consumer.product.test
File Summary
app.e2e-spec.ts Facilitates end-to-end testing for the product service within the consumer module of the desafio_btg_microservicos repository. It verifies the applications HTTP response, ensuring that core functionalities return expected results, thereby contributing to the robustness and reliability of the overall microservices architecture.
jest-e2e.json Facilitates end-to-end testing for the product consumer module within the desafio_btg_microservicos repository. It establishes testing configurations essential for ensuring the reliability and functionality of product-related features, contributing to the overall microservices architecture by promoting code quality and integration validation.
consumer.product.src
File Summary
app.controller.spec.ts Tests for the Product management functionalities validate interactions between the AppController and AppService in the consumer block of the microservices architecture. These ensure the reliability of operations such as handling, updating, retrieving, and deleting products, ultimately supporting the systems integrity and performance.
app.service.spec.ts Facilitates comprehensive testing for product-related functionalities within the consumer microservice. It verifies the AppServices methods for creating, retrieving, updating, and deleting products, ensuring robust interaction with the data repository, and enhancing reliability and performance in the overall microservices architecture of the project.
app.service.ts Facilitates product management within the microservices architecture, providing essential operations such as creating, retrieving, updating, and deleting products. Enhances the repositorys capabilities by ensuring seamless integration with the underlying database through TypeORM, thereby supporting efficient product handling in the overall consumer service.
app.module.ts Establishes the foundational module for the product consumer service within the microservices architecture. It integrates with a PostgreSQL database using TypeORM, defining the necessary entities and services, and facilitating interactions through controllers, thereby enhancing modularity and maintainability of the overall system.
app.controller.ts Facilitates product management within the consumer microservice by handling various product-related events and commands. It interacts with the AppService to manage product data, including addition, retrieval, updating stock, and deletion, ensuring seamless integration within the overall architecture of the desafio_btg_microservicos repository.
main.ts Establishes a microservice within the consumer sector of the repository, focusing on product management. Utilizing RabbitMQ for message transport, it enhances communication and scalability, thereby integrating seamlessly into the broader microservices architecture aimed at delivering efficient, decoupled functionality across various application components.
product.entity.ts Defines the Product entity, which serves as a cornerstone for managing product data within the consumer microservice. Key features include enforced uniqueness for product names, automatic timestamp handling for creation and updates, and attributes for stock, pricing, and status, enhancing the overall product management functionality in the architecture.
product.dto.ts Defines a ProductDto class that encapsulates essential product attributes such as name, price, description, image, and stock. This structure supports the consumer microservice architecture by facilitating data consistency and ease of data transfer across various components, enabling effective communication in the overall system.
consumer.client
File Summary
package.json Defines the client microservices package metadata and dependencies within the desafio_btg_microservicos architecture. It orchestrates the essential scripts for building, testing, and running the service, ensuring seamless integration with NestJS and facilitating effective development workflows across the microservices ecosystem.
tsconfig.build.json Defines TypeScript project configurations for the client component of the consumer service. By extending base settings, it ensures a streamlined build process while excluding unnecessary directories, thereby enhancing clarity and efficiency within the broader microservices architecture of the repository.
tsconfig.json Configures TypeScript compiler options for the client microservice, ensuring compatibility with ES2021 features and CommonJS modules. Enhances development efficiency through incremental builds and source maps, while facilitating accurate type checking and metadata support, thus reinforcing the overall architecture of the consumer services within the repository.
nest-cli.json Enables streamlined configuration and management of the NestJS framework within the consumer/client module. By establishing compiler options and maintaining a structured source root, it enhances development efficiency and supports the overall architecture of the desafio_btg_microservicos repository, promoting modular and scalable microservices.
package-lock.json Microservice FunctionalityEach directory under consumer and producer represents distinct microservices, each handling specific business capabilities such as client management, authentication (login), email notifications (mailer), order processing, and product management. This separation enhances maintainability and allows teams to work on different services concurrently.2. **Inter-Service CommunicationThe architecture is designed to facilitate interactions between various services, ensuring that they can collaborate effectively to fulfill user requests.3.**Configuration and Environment SetupFiles like docker-compose.yml illustrate that the repository supports containerization, enabling easy setup and deployment of services, promoting environment consistency.4. **Initialization and SetupThe presence of init.sql indicates that the setup of databases or initial data is considered, which is essential for service readiness.Overall, the code aims to create a robust and scalable system that can efficiently handle various business processes through a modern microservices approach.
.eslintrc.js Configures ESLint for the client module within the microservices architecture, promoting code quality and consistency in a TypeScript environment. By extending recommended practices and defining specific rules, it enhances collaboration and maintainability across the consumer components of the repository.
consumer.client.test
File Summary
app.e2e-spec.ts Conducts end-to-end testing for the client management functionalities within the consumer module. Validates operations such as client creation, retrieval, and deletion, ensuring the application adheres to expected behaviors and responses, thus enhancing reliability and performance in the overall architecture of the desafio_btg_microservicos repository.
jest-e2e.json Configures end-to-end testing for the client module within the consumer section of the architecture. It establishes the environment and file handling for tests, ensuring that all relevant test files are recognized and processed. This enhances the reliability and maintainability of the microservices by facilitating thorough testing of client functionalities.
consumer.client.src
File Summary
app.controller.spec.ts Facilitates comprehensive testing for the AppController within the consumer module, ensuring reliability and correctness in client-related operations. It defines various scenarios to validate interactions with the AppService, enhancing the robustness of the microservices architecture by confirming expected behaviors across client management functions.
app.service.spec.ts Ensures robust testing for the AppService within the client module of the BTG microservices repository. It verifies client management functionalities, including creation, retrieval, updating, and deletion, which collectively bolster the application’s capability to handle client interactions effectively and maintain data integrity.
app.service.ts Facilitates client management within the consumer microservice, enabling the creation, updating, deletion, and retrieval of client data. Implements password hashing for security and introduces functionality to fetch clients by email, seamlessly integrating with the repositorys architecture to maintain data consistency and integrity.
app.module.ts Defines the core application module for the client microservice within the repository, integrating database connectivity through TypeORM for PostgreSQL. It manages application-level concerns by coordinating controllers and services, while facilitating the use of the Client entity, thereby supporting the overall architecture of microservices in the project.
app.controller.ts Facilitates client management within the consumer microservice by defining a controller that handles client creation, retrieval, updating, and deletion. It integrates with the app service to respond to various events and messages, enhancing communication within the microservice architecture and ensuring efficient client operations.
client.entity.ts Defines the Client entity, serving as a foundational model within the consumer service of the repository. It encapsulates client-related data attributes, including identification, authentication, and role management, thus facilitating interactions across the microservices architecture while ensuring data integrity and compliance with business rules.
main.ts Bootstrap a microservice within the consumer module, leveraging NestJS framework capabilities. Establishes a connection to a RabbitMQ message broker for handling client requests efficiently, thereby enhancing the systems overall architecture by enabling asynchronous communication and service interaction within the microservices ecosystem.
clients.dto.ts Defines the ClientDto class, encapsulating essential client information such as name, email, phone, and password. This data transfer object is crucial for maintaining structured communication within the consumer microservice, supporting seamless client interactions and ensuring data integrity across the application’s architecture.
consumer.login
File Summary
package.json Defines the login microservices package configuration within the desafio_btg_microservicos repository. It establishes dependencies, scripts for development, testing, and formatting, ensuring seamless integration with the broader architecture, while enabling efficient building and management of the services lifecycle within a microservices environment.
tsconfig.build.json Configures TypeScript compilation settings for the login consumer module, ensuring a streamlined build process by excluding unnecessary directories and test files. This enhances the efficiency of the overall microservices architecture by maintaining clarity and focus on essential elements relevant to the login functionality.
tsconfig.json Configures TypeScript compiler options for the login component within the consumer module of the microservices architecture. Enables features like module declaration, metadata emission, and source mapping, enhancing developer experience and ensuring consistent code quality across the project. Supports seamless integration with other services in the repository.
nest-cli.json Defines configuration settings for the NestJS application within the login module of the consumer service. It establishes the project structure, utilizes NestJS schematics for efficient development, and specifies compiler options to manage the build output, ensuring streamlined integration within the overall microservices architecture.
package-lock.json Service Integration:** It enhances interoperability among the microservices by providing defined APIs and communication protocols, allowing them to interact effectively.-Data Management: The code handles the necessary data exchanges, processing, and storage, ensuring that different modules can access and modify shared data as needed.-Error Handling and Resilience: It incorporates mechanisms to gracefully manage failures and ensure robust performance, thereby improving the overall reliability of the system.-Configuration Management: The code is aligned with configuration files (like docker-compose.yml), ensuring that services can be easily deployed and managed in various environments.Overall, this code significantly contributes to the modular design and scalability of the desafio_btg_microservicos architecture, emphasizing maintainability and efficient service-oriented communication.
.eslintrc.js Configuring ESLint for the login consumer enhances code quality and consistency within the desafio_btg_microservicos repository. By enforcing TypeScript-specific rules and integrating with Prettier, it ensures adherence to best practices while maintaining a clean and manageable codebase for improved collaboration and maintainability.
consumer.login.test
File Summary
app.e2e-spec.ts Facilitates end-to-end testing of the login microservice within the broader sistema architecture. It ensures that the application correctly responds to HTTP requests, validating functionality and reliability. This contributes to maintaining high-quality standards across the consumers microservices, reinforcing the overall robustness of the repository.
jest-e2e.json Facilitates end-to-end testing configuration for the login consumer module within a microservices architecture. By defining testing parameters and environments, it ensures robust validation of the login functionalities, ultimately enhancing system reliability and alignment with the overall projects quality assurance strategy.
consumer.login.src
File Summary
app.controller.spec.ts Facilitates unit testing for the login functionality within the application, ensuring that the controller correctly interacts with the service layer. By simulating successful and failed login attempts, it validates the access token generation process and enhances the reliability of the microservices architecture in the consumer module.
app.service.spec.ts Facilitates testing for the AppService within the consumer/login module, ensuring robust verification of user authentication processes. Validates the generation of JWT tokens upon successful credentials verification while testing various scenarios, such as invalid credentials and nonexistent users, thereby reinforcing the repositorys microservices architectures reliability and security.
app.service.ts Facilitates user authentication within the login microservice by validating credentials against stored data and generating JWT access tokens. This functionality is essential for secure access management, enabling seamless communication with other microservices in the challenges distributed architecture while enhancing user experience and security.
app.module.ts Facilitates user authentication and communication within the login microservice by integrating JWT for secure token generation and establishing a RabbitMQ client proxy for efficient message handling. This module enhances collaboration among various components in the architecture, supporting a robust, microservices-based system.
app.controller.ts Facilitates user authentication within the microservices architecture, specifically handling login requests. The AppController listens for login commands and delegates processing to the AppService, ensuring seamless integration with other components in the consumer module while promoting a robust, service-oriented design for user management.
main.ts Establishes a microservice for handling login functionalities within the broader architecture of the desafio_btg_microservicos repository. By utilizing RabbitMQ for message transport, it enables efficient communication and scalability, allowing the application to manage user authentication processes effectively in a distributed environment.
consumer.order
File Summary
package.json Defines the configuration and dependencies for the order microservice within the overarching microservices architecture. Facilitates building, testing, and running the service, ensuring integration with other components through NestJS. Implements best practices for code quality and testing, contributing to the maintainability and scalability of the entire system.
tsconfig.build.json Configures TypeScript settings for the order consumer module, extending base configurations while excluding specific directories such as node_modules and test files. Enhances the overall structure by ensuring a focused build process, contributing to the modular and efficient architecture of the desafio_btg_microservicos repository.
tsconfig.json Defines TypeScript compiler options for the order consumer module within the desafio_btg_microservicos repository. Ensures compatibility and optimizes the build process by enabling features like decorators and source maps, facilitating effective development and seamless integration within the microservices architecture of the project.
nest-cli.json Defines configurations for the NestJS framework within the order consumer of the microservices architecture. It sets the source directory for application code and establishes compiler options, facilitating streamlined development processes and ensuring effective integration with the overall repository’s structure and functionalities.
package-lock.json Service ModularityEach subdirectory under consumer (such as client, login, mailer, order, and product) represents a distinct service responsible for specific functional areas, enabling a clear separation of concerns. This modularity enhances maintainability and scalability.2. **Inter-Service CommunicationThe architecture is designed to support seamless interactions between various services, allowing them to work together effectively to process user requests and manage data flows.3.**Docker SupportThe presence of a docker-compose.yml file indicates an infrastructure setup that allows for containerization of the services, promoting easy deployment and management of the microservices.Overall, this code file aligns with the repositorys objective of creating a robust, scalable, and easily maintainable system tailored to the needs of a modern application landscape.
.eslintrc.js Configures ESLint for the order consumer service within the projeto_btg_microservicos repository, ensuring adherence to TypeScript coding standards. Enhances code quality by applying recommended linting rules, integrating Prettier for formatting, and preparing the environment for both Node.js and Jest testing frameworks.
consumer.order.test
File Summary
app.e2e-spec.ts Facilitates end-to-end testing for the order consumer module within the microservices architecture. By establishing a testing environment, it ensures that the application responds correctly to requests, thereby enhancing reliability and maintainability in the overall systems functionality and user experience.
jest-e2e.json Facilitates end-to-end testing for the order consumer module within the desafio_btg_microservicos repository. By defining test configurations, it ensures compatibility with TypeScript and JavaScript, promoting robust testing practices that enhance the overall reliability and maintainability of the microservices architecture.
consumer.order.src
File Summary
app.controller.spec.ts Facilitates unit testing for the Order controller in the consumer microservice. It ensures the proper interaction between the controller and its service, validating core order functionalities such as handling, retrieval, and deletion. This enhances overall reliability and maintainability within the microservices architecture by promoting robust testing practices.
order.entity.ts Defines the Order entity, encapsulating essential attributes such as client ID, product details in JSON format, and total amount. This structure enhances the consumer modules ability to manage orders effectively within the overall architecture, supporting seamless interactions with clients and integration with other services.
app.service.spec.ts Facilitates unit testing for the order handling functionality within the consumer microservice. It ensures proper interactions with the order repository and the product proxy, validating operations like order saving, retrieval, and deletion. This supports the overarching architecture by promoting reliability and maintainability of the order management process.
app.service.ts Facilitates order management within the consumer microservice, enabling the creation, retrieval, and deletion of orders. Integrates with a product service to fetch product details and updates inventory accordingly, ensuring seamless communication and data integrity across microservices in the architecture.
app.module.ts Defines the core module for the order microservice within the BTG microservices architecture, facilitating database interactions through TypeORM, managing order data, and establishing communication with other services via RabbitMQ. This integration supports a cohesive and efficient order processing system within the broader application ecosystem.
order.dto.ts Facilitates the structure of order-related data within the consumer module of the microservices architecture, defining essential data transfer objects for creating and retrieving orders. This ensures consistent handling of order information across the system, promoting efficient communication between services while enhancing overall functionality.
app.controller.ts Facilitate order management within the microservices architecture by providing a controller that orchestrates events for placing, fetching, and deleting orders. This component interacts seamlessly with the app service, enabling efficient data handling and communication across the consumer services, thus enhancing the overall functionality of the system.
main.ts Establishes a microservice within the order component of the repository, utilizing RabbitMQ for handling messaging. It enables seamless communication for order processing, aligning with the overall architecture designed for scalable and efficient microservices in the BTG project. This enhances modularity and independent service management.

Getting Started

Prerequisites

Docker: version 27.1.1+

Docker Compose: version v2.29.1+

Installation

Build the project from source:

  1. Clone the desafio_btg_microservicos repository:
❯ git clone https://github.com/thadeucbr/desafio_btg_microservicos
  1. Navigate to the project directory:
cd desafio_btg_microservicos

Usage

To run the project, execute the following command:

❯ docker compose up

After Docker finishes building the images (which may take some time), you should access https://localhost:3001/api.


Project Roadmap

  • Task 1: Develop microservices and connect to the database.
  • Task 2: Build an API to consume all microservices.
  • Task 3: Add documentation, Swagger, README, etc.
  • Task 4: Add Docker Compose to facilitate project setup.
  • Task 5: Build the front-end for the project. (not started)
  • Task 6: Host the entire project. (not started)

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.

  2. Clone Locally: Clone the forked repository to your local machine using a git client.

    git clone https://github.com/thadeucbr/desafio_btg_microservicos
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.

    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.

  5. Commit Your Changes: Commit with a clear message describing your updates.

    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.

    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!

Contributor Graph


License

This project is protected under the Creative Commons Attribution-NonCommercial License. This allows others to use the project while attributing the author (me), and if used for commercial purposes, a portion of the profits should be shared with the author. For more details, refer to the LICENSE file.


Acknowledgments

  • I would like to thank the Nest.JS team for their well-written documentation and for developing an excellent framework that made it possible to create my project.
  • The inspiration for this project came from a technical challenge from BTG, which I found interesting and developed further with additional features and increased complexity.
  • Additionally, this README was created with the assistance of AI using the project found at README AI.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published