{"id":14956655,"url":"https://github.com/hoangsonww/Budget-Management-Backend-API","last_synced_at":"2025-10-24T10:30:53.094Z","repository":{"id":245697023,"uuid":"818992568","full_name":"hoangsonww/Budget-Management-Backend-API","owner":"hoangsonww","description":"🚀 Dive into the world of Node.js, MongoDB, Redis, PostgreSQL, Kafka, RabbitMQ, ELK stack, and more with this comprehensive backend API project! Explore how these powerful technologies can be integrated to build robust, scalable, and efficient backend solutions. Also includes a CLI and a sample React frontend!","archived":false,"fork":false,"pushed_at":"2025-01-28T22:08:59.000Z","size":5806,"stargazers_count":21,"open_issues_count":0,"forks_count":16,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-01-28T23:21:45.003Z","etag":null,"topics":["cli","elasticsearch","elk-stack","express","gprc","grafana","graphql","kibana","logstash","mongo","mongodb","mongodb-database","nginx","nodejs","postgres","postgresql","rabbitmq","redis","redis-cache","rest-api"],"latest_commit_sha":null,"homepage":"https://hoangsonww.github.io/Budget-Management-Backend-API/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoangsonww.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-23T13:18:43.000Z","updated_at":"2025-01-28T22:04:10.000Z","dependencies_parsed_at":"2024-06-23T14:38:39.271Z","dependency_job_id":"86512093-e1cd-45ad-98b9-5a6fae8c20ec","html_url":"https://github.com/hoangsonww/Budget-Management-Backend-API","commit_stats":{"total_commits":1037,"total_committers":1,"mean_commits":1037.0,"dds":0.0,"last_synced_commit":"17fdf8919fa5033bb38764280ac8d0cf1009ccd3"},"previous_names":["hoangsonww/node-mongo-redis-rabbitmq","hoangsonww/mongo-redis-rabbitmq-elk-stack","hoangsonww/budget-management-backend-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FBudget-Management-Backend-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FBudget-Management-Backend-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FBudget-Management-Backend-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FBudget-Management-Backend-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoangsonww","download_url":"https://codeload.github.com/hoangsonww/Budget-Management-Backend-API/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237950780,"owners_count":19392666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","elasticsearch","elk-stack","express","gprc","grafana","graphql","kibana","logstash","mongo","mongodb","mongodb-database","nginx","nodejs","postgres","postgresql","rabbitmq","redis","redis-cache","rest-api"],"created_at":"2024-09-24T13:13:17.711Z","updated_at":"2025-10-24T10:30:53.085Z","avatar_url":"https://github.com/hoangsonww.png","language":"JavaScript","readme":"# **Budget Management API - A Comprehensive, Microservices-Based API for Managing Budgets, Expenses, Users, and More! 💰**\n\n**Welcome to the Budget Management API**, a robust, **microservices** backend platform for managing budgets, expenses, users, orders, and notifications. Built with **Node.js**, **Express**, and **TypeScript**, it supports advanced features like **GraphQL**, **gRPC**, **WebSockets**, and **REST APIs**. The API integrates with **PostgreSQL**, **MongoDB**, **MySQL**, **Redis**, **RabbitMQ**, **Kafka**, and **Elasticsearch**, and is containerized with **Docker** and orchestrated using **Kubernetes**. It also includes a developer-friendly **CLI** tool and interactive **Swagger/OpenAPI** documentation for exploring and testing endpoints.\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://budget-manage-app.vercel.app\" target=\"_blank\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Budget Management API Logo\" style=\"border-radius: 8px;\" width=\"35%\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nBelow is a _very_ _comprehensive_ guide to setting up, running, and utilizing this API. 💸🚀\n\n## **Table of Contents**\n\n1. [Overview](#overview)\n2. [Live Deployment](#live-deployment)\n3. [Technologies Used](#technologies-used)\n   - [Microservices Architecture](#microservices-architecture)\n   - [Microservices Diagram](#microservices-diagram)\n   - [Full Architecture Diagram](#full-architecture-diagram)\n4. [Project Structure](#project-structure)\n5. [Setup Instructions](#setup-instructions)\n6. [Available Endpoints](#available-endpoints)\n7. [Schemas](#schemas)\n8. [Features and Integrations](#features-and-integrations)\n9. [Environment Variables](#environment-variables)\n10. [CLI Usage](#cli-usage)\n11. [Demo Frontend UI](#demo-frontend-ui)\n12. [Swagger Documentation](#swagger-documentation)\n13. [GraphQL Integration](#graphql-integration)\n14. [NGINX Configuration](#nginx-configuration)\n15. [gRPC Integration](#grpc-integration)\n16. [Dockerization](#dockerization)\n17. [Kubernetes Deployment](#kubernetes-deployment)\n18. [Spring Boot Backends with Gradle \u0026 Maven](#spring-boot-backends-with-maven-and-gradle)\n19. [Dotnet Backends with C#](#dotnet-backend-with-c-sharp)\n20. [Continuous Integration and Deployment with Jenkins](#continuous-integration-and-deployment-with-jenkins)\n    - [GitHub Actions](#github-actions)\n21. [Testing](#testing)\n22. [Contributing](#contributing)\n23. [Author](#author)\n\n## **Overview**\n\nThe Budget Management API is designed to handle complex budget management requirements, including:\n\n- Budget and expense tracking.\n- User management and authentication.\n- Real-time notifications via WebSockets.\n- Asynchronous task handling using RabbitMQ and Kafka.\n- Advanced search capabilities with Elasticsearch.\n- CLI operations for direct interaction with the system.\n- Compatibility with modern cloud environments like Docker and Kubernetes.\n- Support for both REST and GraphQL APIs for flexible data access.\n- Sample `dotnet` and `spring-boot` backends to demonstrate integration with other technologies.\n- ...and so much more!\n\nThe purpose of this API is to demonstrate the capabilities of modern backend technologies and provide a foundation for building scalable, real-time applications. It can be used as a reference for developers looking to implement similar features in their projects. Simply clone the repository, set up the environment, and start building the frontend or additional functionality on top of the existing API! \n\n![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge\u0026logo=javascript\u0026logoColor=black)\n![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge\u0026logo=typescript\u0026logoColor=white)\n![Java](https://img.shields.io/badge/Java-007396?style=for-the-badge\u0026logo=openjdk\u0026logoColor=white)\n![C#](https://img.shields.io/badge/C%23-239120?style=for-the-badge\u0026logo=csharp\u0026logoColor=white)\n![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge\u0026logo=nodedotjs\u0026logoColor=white)\n![Express.js](https://img.shields.io/badge/Express.js-000000?style=for-the-badge\u0026logo=express\u0026logoColor=white)\n![Spring Boot](https://img.shields.io/badge/Spring%20Boot-6DB33F?style=for-the-badge\u0026logo=springboot\u0026logoColor=white)\n![ASP.NET Core](https://img.shields.io/badge/ASP.NET%20Core-512BD4?style=for-the-badge\u0026logo=dotnet\u0026logoColor=white)\n![RabbitMQ](https://img.shields.io/badge/RabbitMQ-FF6600?style=for-the-badge\u0026logo=rabbitmq\u0026logoColor=white)\n![Kafka](https://img.shields.io/badge/Kafka-231F20?style=for-the-badge\u0026logo=apachekafka\u0026logoColor=white)\n![MongoDB](https://img.shields.io/badge/MongoDB-47A248?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white)\n![PostgreSQL](https://img.shields.io/badge/PostgreSQL-4169E1?style=for-the-badge\u0026logo=postgresql\u0026logoColor=white)\n![MySQL](https://img.shields.io/badge/MySQL-4479A1?style=for-the-badge\u0026logo=mysql\u0026logoColor=white)\n![Redis](https://img.shields.io/badge/Redis-DC382D?style=for-the-badge\u0026logo=redis\u0026logoColor=white)\n![Elasticsearch](https://img.shields.io/badge/Elasticsearch-005571?style=for-the-badge\u0026logo=elasticsearch\u0026logoColor=white)\n![REST](https://img.shields.io/badge/REST%20API-FF6F00?style=for-the-badge\u0026logo=apachespark\u0026logoColor=white)\n![GraphQL](https://img.shields.io/badge/GraphQL-E10098?style=for-the-badge\u0026logo=graphql\u0026logoColor=white)\n![gRPC](https://img.shields.io/badge/gRPC-4285F4?style=for-the-badge\u0026logo=grpc\u0026logoColor=white)\n![WebSockets](https://img.shields.io/badge/WebSockets-006699?style=for-the-badge\u0026logo=websocket\u0026logoColor=white)\n![Swagger](https://img.shields.io/badge/Swagger-85EA2D?style=for-the-badge\u0026logo=swagger\u0026logoColor=black)\n![OpenAPI](https://img.shields.io/badge/OpenAPI-6BA539?style=for-the-badge\u0026logo=openapiinitiative\u0026logoColor=white)\n![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge\u0026logo=docker\u0026logoColor=white)\n![Kubernetes](https://img.shields.io/badge/Kubernetes-326CE5?style=for-the-badge\u0026logo=kubernetes\u0026logoColor=white)\n![Jenkins](https://img.shields.io/badge/Jenkins-D24939?style=for-the-badge\u0026logo=jenkins\u0026logoColor=white)\n![NGINX](https://img.shields.io/badge/NGINX-009639?style=for-the-badge\u0026logo=nginx\u0026logoColor=white)\n![PM2](https://img.shields.io/badge/PM2-2B037A?style=for-the-badge\u0026logo=pm2\u0026logoColor=white)\n![Render](https://img.shields.io/badge/Render-46E3B7?style=for-the-badge\u0026logo=render\u0026logoColor=black)\n![Vercel](https://img.shields.io/badge/Vercel-000000?style=for-the-badge\u0026logo=vercel\u0026logoColor=white)\n![Netlify](https://img.shields.io/badge/Netlify-00C7B7?style=for-the-badge\u0026logo=netlify\u0026logoColor=white)\n![Prometheus](https://img.shields.io/badge/Prometheus-E6522C?style=for-the-badge\u0026logo=prometheus\u0026logoColor=white)\n![Grafana](https://img.shields.io/badge/Grafana-F46800?style=for-the-badge\u0026logo=grafana\u0026logoColor=white)\n![Maven](https://img.shields.io/badge/Maven-C71A36?style=for-the-badge\u0026logo=apachemaven\u0026logoColor=white)\n![Gradle](https://img.shields.io/badge/Gradle-02303A?style=for-the-badge\u0026logo=gradle\u0026logoColor=white)\n![npm](https://img.shields.io/badge/npm-CB3837?style=for-the-badge\u0026logo=npm\u0026logoColor=white)\n![Git](https://img.shields.io/badge/Git-F05032?style=for-the-badge\u0026logo=git\u0026logoColor=white)\n![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge\u0026logo=github\u0026logoColor=white)\n![GitHub Actions](https://img.shields.io/badge/GitHub%20Actions-2088FF?style=for-the-badge\u0026logo=githubactions\u0026logoColor=white)\n![Node CLI](https://img.shields.io/badge/Node%20CLI-339933?style=for-the-badge\u0026logo=nodedotjs\u0026logoColor=white)\n![ESLint](https://img.shields.io/badge/ESLint-4B32C3?style=for-the-badge\u0026logo=eslint\u0026logoColor=white)\n![Prettier](https://img.shields.io/badge/Prettier-F7B93E?style=for-the-badge\u0026logo=prettier\u0026logoColor=black)\n![Jest](https://img.shields.io/badge/Jest-C21325?style=for-the-badge\u0026logo=jest\u0026logoColor=white)\n![Mocha](https://img.shields.io/badge/Mocha-8D6748?style=for-the-badge\u0026logo=mocha\u0026logoColor=white)\n![Chai](https://img.shields.io/badge/Chai-A30701?style=for-the-badge\u0026logo=chai\u0026logoColor=white)\n![Microservices](https://img.shields.io/badge/Microservices-00BFFF?style=for-the-badge\u0026logo=farcaster\u0026logoColor=white)\n\n## **Live Deployment**\n\nThe Budget Management API is deployed live at **[https://budget-management-backend-api.onrender.com](https://budget-management-backend-api.onrender.com).**\n\nAdditionally, a mock frontend UI is also available, hosted at **[https://budget-manage-app.vercel.app](https://budget-manage-app.vercel.app).**\n\nYou can access the API and test the endpoints directly from the browser. Feel free to use the API for your own projects or applications. Simply add some attribution to the original repository and the creator. Also, be sure that you use your own credentials and tokens, otherwise your data may clash with mine and other users' data!\n\n\u003e [!IMPORTANT]\n\u003e Be mindful of the rate limits and usage policies when testing the live API. Additionally, because the API is hosted on the free plan of Render, it may take a while (1-2 minutes) to wake up if it has been inactive for some time. Kindly be patient during this process!\n\n\u003e [!NOTE]\n\u003e Backup Frontend: https://budget-management-system.netlify.app.\n\n### Deployment and Technology Status\n\n[![API Status](https://img.shields.io/website?label=API%20Status\u0026url=https%3A%2F%2Fbudget-management-backend-api.onrender.com)](https://budget-management-backend-api.onrender.com)\n[![MongoDB](https://img.shields.io/badge/MongoDB-Connected-brightgreen?logo=mongodb\u0026logoColor=white)](https://www.mongodb.com/)\n[![Redis](https://img.shields.io/badge/Redis-Connected-red?logo=redis\u0026logoColor=white)](https://redis.io/)\n[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-Connected-blue?logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/)\n[![RabbitMQ](https://img.shields.io/badge/RabbitMQ-Connected-orange?logo=rabbitmq\u0026logoColor=white)](https://www.rabbitmq.com/)\n[![Kafka](https://img.shields.io/badge/Kafka-Connected-black?logo=apachekafka\u0026logoColor=white)](https://kafka.apache.org/)\n[![Elasticsearch](https://img.shields.io/badge/Elasticsearch-Connected-yellow?logo=elasticsearch\u0026logoColor=white)](https://www.elastic.co/elasticsearch/)\n[![gRPC](https://img.shields.io/badge/gRPC-Operational-purple?logo=grpc\u0026logoColor=white)](https://grpc.io/)\n[![GraphQL](https://img.shields.io/badge/GraphQL-Operational-pink?logo=graphql\u0026logoColor=white)](https://graphql.org/)\n[![Swagger Docs](https://img.shields.io/badge/Swagger%20Docs-Available-brightgreen?logo=swagger\u0026logoColor=white)](https://budget-management-backend-api.onrender.com/docs)\n[![Docker](https://img.shields.io/badge/Docker-Configured-blue?logo=docker\u0026logoColor=white)](https://www.docker.com/)\n[![Kubernetes](https://img.shields.io/badge/Kubernetes-Ready-blue?logo=kubernetes\u0026logoColor=white)](https://kubernetes.io/)\n[![WebSockets](https://img.shields.io/badge/WebSockets-Connected-brightgreen?logo=websocket\u0026logoColor=white)](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)\n[![Nginx](https://img.shields.io/badge/Nginx-Configured-green?logo=nginx\u0026logoColor=white)](https://www.nginx.com/)\n[![OpenAPI](https://img.shields.io/badge/OpenAPI-Active-green?logo=openapiinitiative\u0026logoColor=white)](https://www.openapis.org/)\n[![Jenkins CI/CD](https://img.shields.io/badge/Jenkins%20CI%2FCD-Configured-blue?logo=jenkins\u0026logoColor=white)](https://www.jenkins.io/)\n[![Prometheus](https://img.shields.io/badge/Prometheus-Configured-blue?logo=prometheus\u0026logoColor=white)](https://prometheus.io/)\n[![Grafana](https://img.shields.io/badge/Grafana-Configured-blue?logo=grafana\u0026logoColor=white)](https://grafana.com/)\n[![Maven Package](https://img.shields.io/badge/Maven%20Package-Available-orange?logo=apachemaven\u0026logoColor=white)](https://maven.apache.org/)\n[![Gradle Package](https://img.shields.io/badge/Gradle%20Package-Available-orange?logo=gradle\u0026logoColor=white)](https://gradle.org/)\n[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-Configured-green?logo=spring\u0026logoColor=white)](https://spring.io/projects/spring-boot)\n[![Dotnet](https://img.shields.io/badge/.NET-Configured-blue?logo=.net\u0026logoColor=white)](https://dotnet.microsoft.com/)\n[![Vercel](https://img.shields.io/badge/Vercel-Deployed-green?logo=vercel\u0026logoColor=white)](https://budget-manage-app.vercel.app)\n[![Render](https://img.shields.io/badge/Render-Deployed-green?logo=render\u0026logoColor=white)](https://budget-management-backend-api.onrender.com)\n[![Netlify](https://img.shields.io/badge/Netlify-Deployed-green?logo=netlify\u0026logoColor=white)](https://budget-management-system.netlify.app)\n\n## **Technologies Used**\n\n| **Technology**      | **Purpose**                                               |\n|---------------------|-----------------------------------------------------------|\n| **Node.js**         | Core application framework.                               |\n| **Express.js**      | Web application framework for building APIs.              |\n| **MongoDB**         | Primary NoSQL database for managing budgets and expenses. |\n| **PostgreSQL**      | Relational database for transaction logs.                 |\n| **MySQL**           | Optional relational database support.                     |\n| **Redis**           | In-memory database for caching.                           |\n| **RabbitMQ**        | Message broker for task queuing.                          |\n| **Kafka**           | Distributed event streaming platform.                     |\n| **Elasticsearch**   | Advanced search engine for querying data.                 |\n| **gRPC**            | High-performance remote procedure call framework.         |\n| **GraphQL**         | Query language for fetching and manipulating data.        |\n| **WebSocket**       | Real-time communication for notifications.                |\n| **Swagger/OpenAPI** | API documentation and testing.                            |\n| **Docker**          | Containerization for easy deployment.                     |\n| **Kubernetes**      | Orchestrating containerized applications at scale.        |\n| **Nginx**           | Reverse proxy and load balancer.                          |\n| **Prometheus**      | Monitoring and alerting toolkit.                          |\n| **Grafana**         | Observability and visualization platform.                 |\n| **Jenkins**         | CI/CD pipeline for automated testing and deployment.      |\n\n### Microservices Architecture\n\nThe Budget Management API is designed with a microservices architecture, allowing for modular development and deployment. Each service can be developed, deployed, and scaled independently, providing flexibility and resilience.\n\n1. **Authentication/User Service**: Handles user registration, login, and JWT token management (+ profile management as well).\n2. **Budget Service**: Manages budgets, including creation, updates, and retrieval.\n3. **Expense Service**: Manages expenses associated with budgets, including CRUD operations.\n4. **Customer Service**: Manages customer data, including creation and updates.\n5. **Search Service**: Provides advanced search capabilities using Elasticsearch.\n6. **Order Service**: Manages orders, including creation and updates.\n7. **Transaction Service**: Logs transactions for budgets and expenses.\n8. **Notification Service**: Sends real-time notifications to users via WebSockets.\n9. **Task Management Service**: Handles asynchronous tasks using RabbitMQ and Kafka.\n\nThis architecture allows for easy integration of additional services, such as order management, task management, and notification services, without affecting the core functionality of the API.\n\n#### Communication Between Services\n\nEach service communicates with others using RabbitMQ for asynchronous messaging, gRPC for high-performance remote procedure calls, and REST APIs for standard HTTP communication. This ensures that services can operate independently while still being able to interact with each other as needed.\n\nAlso, the API is designed to be modular, allowing for easy addition of new services or features without disrupting existing functionality. This modularity is achieved through the use of separate directories for each service, with shared utilities and configurations in a common structure.\n\n\u003e [!TIP]\n\u003e Each service does not live in its own directory, but rather is organized within the main project structure. This allows for easier management and deployment of the entire application as a single unit, while still maintaining the modularity of the microservices architecture.\n\n### Microservices Diagram\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.mermaidchart.com/app/projects/ab86aba4-5205-4ad5-bdfc-85dfba04f62f/diagrams/0ecda876-0581-4897-bac3-b6800daa2a14/version/v0.1/edit\" target=\"_blank\"\u003e\n   \u003cimg src=\"images/microservices-diagram.png\" alt=\"Microservices Architecture Diagram\" style=\"border-radius: 8px;\" width=\"100%\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e [!NOTE]\n\u003e This diagram illustrates the microservices architecture of the Budget Management API, showing how different services interact with each other and external clients. Each service can be independently developed and deployed, allowing for scalability and maintainability.\n\n### Full Architecture Diagram\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.mermaidchart.com/app/projects/ab86aba4-5205-4ad5-bdfc-85dfba04f62f/diagrams/b164e25e-68b3-417e-8753-5b718e23d996/version/v0.1/edit\" target=\"_blank\"\u003e\n   \u003cimg src=\"images/architecture-diagram.png\" alt=\"Architecture Diagram\" style=\"border-radius: 8px;\" width=\"100%\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e [!NOTE]\n\u003e This architecture diagram illustrates the modular nature of the Budget Management API, showcasing how different services interact with each other and external clients. It also highlights the use of various technologies such as Docker, Kubernetes, and Nginx for deployment and scaling.\n\n## **Project Structure**\n\n```plaintext\nBudget-Management-Backend-API/\n├── .env                           # Environment variables configuration\n├── .env.example                   # Example environment configuration file\n├── .gitignore                     # Git ignore file\n├── .prettierrc                    # Prettier configuration for code formatting\n├── LICENSE                        # License information\n├── README.md                      # Documentation for the project\n├── __tests__/app.test.js          # Main test file for application\n├── cli.js                         # CLI tool for interacting with the backend\n├── docker-compose.yml             # Docker Compose configuration\n├── Dockerfile                     # Dockerfile for containerizing the application\n├── grpcServer.js                  # gRPC server implementation\n├── index.js                       # Main entry point for the application\n├── nodemon.json                   # Nodemon configuration file\n├── openapi.yaml                   # OpenAPI specification for the API\n├── package.json                   # NPM package configuration file\n├── start.sh                       # Script to start the application\n├── prometheus.yml                 # Prometheus configuration for monitoring\n├── redis-mongo-flow/              # Directory for Redis-Mongo integration flow\n│   ├── app.js                     # Express app for Redis-Mongo flow\n│   ├── config.js                  # Configuration for Redis-Mongo flow\n│   ├── package.json               # NPM configuration for this module\n│   ├── README.md                  # Documentation specific to Redis-Mongo flow\n│   ├── seed.js                    # Data seeder for Redis-Mongo flow\n│   ├── test.js                    # Test file for Redis-Mongo flow\n├── round-robin/                   # Directory for round-robin load balancer\n│   ├── config.js                  # Configuration for round-robin implementation\n│   ├── index.js                   # Main entry point for round-robin logic\n│   ├── README.md                  # Documentation for round-robin functionality\n├── proto/                         # Protocol Buffers directory\n│   ├── budget.proto               # gRPC proto file for budgets\n├── nginx/                         # NGINX configuration directory\n│   ├── docker-compose.yml         # Docker Compose for NGINX\n│   ├── Dockerfile                 # Dockerfile for NGINX\n│   ├── nginx.conf                 # NGINX configuration file\n│   ├── start_nginx.sh             # Script to start NGINX\n│   ├── README.md                  # Documentation for NGINX\n├── docs/                          # Documentation directory\n│   ├── swaggerConfig.js           # Swagger configuration for API docs\n├── graphql/                       # GraphQL-related files\n│   ├── schema.js                  # GraphQL schema definition\n├── services/                      # Services and utilities\n│   ├── dataSeeder.js              # Seeder for MongoDB\n│   ├── elasticService.js          # Elasticsearch client and utility functions\n│   ├── jwtService.js              # JSON Web Token (JWT) utilities\n│   ├── postgresService.js         # PostgreSQL client and utilities\n│   ├── rabbitMQService.js         # RabbitMQ client and utilities\n│   ├── redisService.js            # Redis client and utilities\n│   ├── websocketService.js        # WebSocket server and utilities\n├── controllers/                   # Route controllers for the API\n│   ├── authController.js          # Authentication-related endpoints\n│   ├── budgetController.js        # Budget management endpoints\n│   ├── customerController.js      # Customer management endpoints\n│   ├── expenseController.js       # Expense management endpoints\n│   ├── notificationController.js  # Notification management endpoints\n│   ├── orderController.js         # Order management endpoints\n│   ├── searchController.js        # Search-related endpoints\n│   ├── taskController.js          # Task management endpoints\n│   ├── transactionController.js   # Transaction log endpoints\n│   ├── userController.js          # User profile management endpoints\n├── middleware/                    # Middleware utilities\n│   ├── authMiddleware.js          # JWT authentication middleware\n├── models/                        # Mongoose schemas\n│   ├── budget.js                  # Schema for budgets\n│   ├── customer.js                # Schema for customers\n│   ├── expense.js                 # Schema for expenses\n│   ├── order.js                   # Schema for orders\n│   ├── task.js                    # Schema for tasks\n│   ├── user.js                    # Schema for users\n├── routes/                        # Express router files\n│   ├── authRoutes.js              # Routes for authentication\n│   ├── budgetRoutes.js            # Routes for budgets\n│   ├── customerRoutes.js          # Routes for customers\n│   ├── expenseRoutes.js           # Routes for expenses\n│   ├── graphqlRoutes.js           # Routes for GraphQL\n│   ├── index.js                   # Main router entry point\n│   ├── notificationRoutes.js      # Routes for notifications\n│   ├── orderRoutes.js             # Routes for orders\n│   ├── searchRoutes.js            # Routes for Elasticsearch\n│   ├── taskRoutes.js              # Routes for tasks\n│   ├── transactionRoutes.js       # Routes for transactions\n│   ├── userRoutes.js              # Routes for user profiles\n├── views/                         # Static assets and templates\n│   ├── android-chrome-192x192.png # Android Chrome app icon\n│   ├── android-chrome-512x512.png # Android Chrome high-res icon\n│   ├── apple-touch-icon.png       # Apple Touch icon\n│   ├── favicon.ico                # Favicon\n│   ├── favicon-16x16.png          # 16x16 favicon\n│   ├── favicon-32x32.png          # 32x32 favicon\n│   ├── home.html                  # HTML template for homepage\n│   ├── manifest.json              # Web app manifest\n├── and many more files...         # Additional files and directories\n```\n\n## **Setup Instructions**\n\n### Prerequisites\n\n- Node.js (\u003e= 16)\n- Docker and Docker Compose (if using containerized setup)\n- MongoDB, PostgreSQL, MySQL, RabbitMQ, Redis, and Elasticsearch services.\n\n### Local Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/hoangsonww/Budget-Management-Backend-API.git\n   cd Budget-Management-Backend-API\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. Set up environment variables:\n  - Create a `.env` file in the root directory:\n    ```env\n    MONGO_DB_URI=mongodb://localhost:27017/budget_manager\n    POSTGRES_URI=postgres://user:password@localhost:5432/budget_manager\n    REDIS_URL=redis://localhost:6379\n    RABBITMQ_URL=amqp://localhost\n    KAFKA_BROKER=localhost:9092\n    JWT_SECRET=your_secret_key\n    ```\n  - Replace placeholders with your actual configuration.\n\n4. Start the application:\n   ```bash\n   npm start\n   ```\n\n5. Access the application:\n  - API: `http://localhost:3000`\n  - Swagger: `http://localhost:3000/docs`\n\n## **Available Endpoints**\n\n| **Endpoint**               | **Method** | **Description**                          |\n|----------------------------|------------|------------------------------------------|\n| `/api/auth/register`       | POST       | Register a new user.                     |\n| `/api/auth/login`          | POST       | Login and receive a JWT token.           |\n| `/api/auth/logout`         | POST       | Logout and invalidate the token.         |\n| `/api/auth/verify-email`   | POST       | Verify the user's email address.         |\n| `/api/auth/reset-password` | POST       | Reset the user's password.               |\n| `/api/users/profile`       | GET        | Get the authenticated user's profile.    |\n| `/api/budgets`             | GET        | Get all budgets.                         |\n| `/api/budgets`             | POST       | Create a new budget.                     |\n| `/api/budgets/:id`         | GET        | Get a specific budget.                   |\n| `/api/budgets/:id`         | PUT        | Update a budget.                         |\n| `/api/budgets/:id`         | DELETE     | Delete a budget.                         |\n| `/api/customers`           | GET        | Get all customers.                       |\n| `/api/customers`           | POST       | Create a new customer.                   |\n| `/api/customers/:id`       | GET        | Get a specific customer.                 |\n| `/api/customers/:id`       | PUT        | Update a customer.                       |\n| `/api/customers/:id`       | DELETE     | Delete a customer.                       |\n| `/api/expenses`            | GET        | Get all expenses.                        |\n| `/api/expenses`            | POST       | Add a new expense.                       |\n| `/api/expenses/:budgetId`  | GET        | Get all expenses for a budget.           |\n| `/api/expenses/:id`        | PUT        | Update an expense.                       |\n| `/api/expenses/:id`        | DELETE     | Delete an expense.                       |\n| `/api/orders`              | GET        | Get all orders.                          |\n| `/api/orders`              | POST       | Create a new order.                      |\n| `/api/orders/:id`          | GET        | Get a specific order.                    |\n| `/api/orders/:id`          | PUT        | Update an order.                         |\n| `/api/orders/:id`          | DELETE     | Delete an order.                         |\n| `/api/transactions`        | GET        | Get all transactions.                    |\n| `/api/transactions`        | POST       | Add a new transaction.                   |\n| `/api/transactions/:id`    | GET        | Get a specific transaction.              |\n| `/api/transactions/:id`    | PUT        | Update a transaction.                    |\n| `/api/transactions/:id`    | DELETE     | Delete a transaction.                    |\n| `/api/tasks`               | GET        | Get all tasks.                           |\n| `/api/tasks`               | POST       | Add a new task.                          |\n| `/api/tasks/:id`           | GET        | Get a specific task.                     |\n| `/api/tasks/:id`           | PUT        | Update a task.                           |\n| `/api/tasks/:id`           | DELETE     | Delete a task.                           |\n| `/api/graphql`             | POST       | Perform a GraphQL query.                 |\n| `/api/notifications`       | POST       | Send a real-time notification.           |\n| `/api/search`              | POST       | Search for expenses using Elasticsearch. |\n\nAdditionally, the root `/` endpoint provides a welcome message and information about the API.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/home.png\" alt=\"Available Endpoints\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\nMore endpoints and features are available in the API. Refer to the [Swagger documentation](https://budget-management-backend-api.onrender.com/docs) for detailed information.\n\n## **Schemas**\n\n### **User**\n| **Field**   | **Type** | **Description**             |\n|-------------|----------|-----------------------------|\n| `username`  | String   | Unique username.            |\n| `email`     | String   | Unique email address.       |\n| `password`  | String   | Hashed password.            |\n| `createdAt` | Date     | User creation date.         |\n\n### **Budget**\n| **Field**   | **Type** | **Description**             |\n|-------------|----------|-----------------------------|\n| `name`      | String   | Budget name.                |\n| `limit`     | Number   | Budget limit.               |\n| `createdAt` | Date     | Budget creation date.       |\n\n### **Expense**\n| **Field**     | **Type** | **Description**              |\n|---------------|----------|------------------------------|\n| `budgetId`    | String   | ID of the associated budget. |\n| `description` | String   | Expense description.         |\n| `amount`      | Number   | Expense amount.              |\n| `createdAt`   | Date     | Expense creation date.       |\n\n### **Order**\n| **Field**    | **Type** | **Description**                |\n|--------------|----------|--------------------------------|\n| `customerId` | String   | ID of the associated customer. |\n| `amount`     | Number   | Order amount.                  |\n| `status`     | String   | Order status.                  |\n| `createdAt`  | Date     | Order creation date.           |\n\n### **Customer**\n| **Field**   | **Type** | **Description**              |\n|-------------|----------|------------------------------|\n| `name`      | String   | Customer name.               |\n| `email`     | String   | Customer email address.      |\n| `phone`     | String   | Customer phone number.       |\n\n### **Task**\n\n| **Field**     | **Type** | **Description**              |\n|---------------|----------|------------------------------|\n| `description` | String   | Task description.            |\n| `status`      | String   | Task status.                 |\n| `createdAt`   | Date     | Task creation date.          |\n\n## **Features and Integrations**\n\n### **gRPC**\n- High-performance RPC framework.\n- Start the gRPC server using:\n  ```bash\n  npm start\n  ```\n\n### **GraphQL**\n- Flexible data queries and mutations.\n- Access the GraphQL endpoint at `http://localhost:3000/graphql`.\n\n### **WebSocket**\n- Real-time notifications for clients.\n- Notifications can be sent using the `/api/notifications` endpoint or CLI.\n\n### **Docker**\n- Build and run the app with Docker:\n  ```bash\n  docker-compose up --build\n  ```\n\n### **Elasticsearch**\n- Advanced search for expenses.\n- Search endpoint: `/api/search/expenses`.\n\n### **RabbitMQ**\n- Asynchronous task handling.\n- Use the `budget-manager` CLI to add tasks.\n- Tasks are processed in the background.\n\n### **Kafka**\n- Distributed event streaming platform.\n- Kafka broker URL: `localhost:9092`.\n- Kafka producer and consumer are integrated.\n\n### **Redis**\n- In-memory caching for improved performance.\n- Redis URL: `redis://localhost:6379`.\n- Caching is used for user sessions and other data.\n\n### **PostgreSQL**\n- Relational database for transaction logs.\n- PostgreSQL URL: `postgres://user:password@localhost:5432/budget_manager`.\n- Used for storing transaction logs and other relational data.\n- MySQL is also supported as an alternative.\n\n### **MongoDB**\n- Primary NoSQL database for managing budgets and expenses.\n- MongoDB URL: `mongodb://localhost:27017/budget_manager`.\n- Used for storing budgets, expenses, and user data.\n\n### **Nginx**\n- Reverse proxy and load balancer.\n- Nginx configuration is included in the `nginx` directory.\n- Load balancing can be configured for multiple instances.\n- SSL termination and caching can be added.\n\n### **Kubernetes**\n- Deployment manifests are available in the `kubernetes` directory.\n- Deploy the application to a Kubernetes cluster using:\n  ```bash\n  kubectl apply -f kubernetes/\n  ```\n  \n### **Prometheus and Grafana**\n- Monitoring and observability tools.\n- Prometheus configuration is available in `prometheus.yml`.\n- Grafana can be used for visualization and monitoring.\n- Metrics and dashboards can be configured.\n- Monitor the health and performance of the API.\n\n## **Services Interaction**\n\nThe Budget Management API interacts with various services and databases to provide a comprehensive backend solution. The architecture includes a frontend UI, a CLI tool, an API gateway, a gRPC server, and multiple external services. Here is a high-level overview of the service interaction:\n\n```plaintext\n          +--------------------+               +------------------+\n          |    Frontend UI     |               |                  |\n          |    (not impl.)     |               |  CLI Tool / gRPC |\n          +--------------------+               +------------------+\n                    |                               |\n                    | HTTP/GraphQL Requests         | CLI Commands / gRPC Calls\n                    |                               |\n          +--------------------+                 +------------------+\n          |   API Gateway /    |\u003c---------------\u003e|    gRPC Server   |\n          |    Express.js      |                 +------------------+\n          +--------------------+\n                    |\n                    | RESTful API / WebSocket / GraphQL Responses\n                    |\n          +--------------------+\n          |  Application Core  |\n          |--------------------|\n          |  Controllers /     |\n          |  Services          |\n          +--------------------+\n            |        |         |\n     +------+        |         +-------------+\n     |               |                       |\n+----------+   +-----------+           +----------------+\n| MongoDB  |   | PostgreSQL |          | Elasticsearch  |\n| NoSQL DB |   | Relational |          | Search Engine  |\n+----------+   +-----------+           +----------------+\n     |               |                       |\n     |               |                       |\n+----------+    +-------------+      +----------------+\n|   Redis  |    | RabbitMQ /  |      | Kafka (Event   |\n|   Cache  |    | Kafka Queue |      |   Streaming)   |\n+----------+    +-------------+      +----------------+\n     |              |                        |\n     +--------------|-(Asynchronous Tasks)---+\n                    |\n          +----------------------+\n          |   External Services  |\n          |  (Email, SMS, etc.)  |\n          +----------------------+\n```\n\n## **Environment Variables**\n\nEnsure your `.env` file looks like this before getting started:\n\n```env\n# Server Configuration\nPORT=\n\n# MongoDB Configuration\nMONGO_DB_URI=\nMONGO_DB_USERNAME=\nMONGO_DB_PASSWORD=\n\n# Redis Configuration\nREDIS_HOST=\nREDIS_PORT=\nREDIS_URL=\n\n# RabbitMQ Configuration\nRABBIT_MQ_HOST=\nRABBITMQ_URL=\n\n# Kafka Configuration\nKAFKA_BROKER=\n\n# JWT Secret Key\nJWT_SECRET=\n\n# Elasticsearch Configuration\nELASTIC_SEARCH_URL=\n\n# PostgreSQL Configuration\nPOSTGRES_URL=\n```\n\n## **CLI Usage**\n\nThe `budget-manager` CLI provides a convenient way to interact with the application from the command line.\n\nFollow these steps to use the CLI:\n\n1. Install globally:\n   ```bash\n   npm link\n   ```\n\n2. Use commands:\n   ```bash\n   budget-manager seed\n   budget-manager notify \"Hello!\"\n   budget-manager add-task \"Task description\"\n   ```\n   \n3. View available commands:\n   ```bash\n    budget-manager --help\n    ```\n   \n  This will display a list of available commands and options:\n  ```plaintext\n  budget-manager --help\n  Usage: budget-manager [options] [command]\n  \n  A CLI for managing budgets, tasks, orders, and more.\n  \n  Options:\n    -V, --version                        output the version number\n    -h, --help                           display help for command\n  \n  Commands:\n    seed                                 Seed the MongoDB database with initial data\n    notify \u003cmessage\u003e                     Send a real-time notification to WebSocket clients\n    list-budgets                         List all budgets in the database\n    add-task \u003cdescription\u003e               Add a new task to the task queue\n    list-orders                          List all orders in the database\n    add-order \u003ccustomerId\u003e \u003camount\u003e      Add a new order\n    list-customers                       List all customers in the database\n    add-customer \u003cname\u003e \u003cemail\u003e [phone]  Add a new customer\n    search-expenses \u003cquery\u003e              Search for expenses using a query\n    graphql-query \u003cquery\u003e                Perform a GraphQL query\n    help [command]                       display help for command\n  \n  Examples:\n    $ budget-manager seed\n    $ budget-manager notify \"Hello World!\"\n    $ budget-manager list-budgets\n    $ budget-manager add-task \"New Task Description\"\n  ```\n   \n4. View version information:\n   ```bash\n   budget-manager --version\n   ```\n   \nThe CLI provides a simple way to interact with the backend API and perform various operations. It can be used for testing, debugging, and managing the application without a frontend interface or using the Swagger documentation.\n\n## **Demo Frontend UI**\n\nThe Budget Management API includes a demo frontend UI for interacting with the backend.\n\nIt gives developers an idea of how the API can be used in a real-world application. The frontend UI is built using React, Redux, and Material-UI components.\n\nTo run the frontend UI, follow these steps:\n\n1. Navigate to the `frontend` directory:\n   ```bash\n   cd frontend\n   ```\n   \n2. Install dependencies: (use `npm install --legacy-peer-deps` if you encounter peer dependency issues)\n   ```bash\n    npm install\n    ```\n   \n3. Start the development server:\n   ```bash\n   npm start\n   ```\n   \n4. Access the frontend UI at `http://localhost:3001` (or whichever port is specified in the console).\n\nAlternatively, it is also deployed live at [https://budget-manage-app.vercel.app](https://budget-manage-app.vercel.app). Feel free to use the live version for testing and exploration.\n\nFor more information, refer to the [Frontend README](frontend/README.md) in the `frontend` directory to learn about the frontend UI components, features, and usage.\n\n### **UI Images**\n\nHere are some screenshots of the frontend UI:\n\n**Home:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/home-ui.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Dashboard:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/dashboard.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Budgets:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/budgets.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Expenses:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/expenses.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Profile:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/profile.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Login:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/login.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Register:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/register.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Forgot Password:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/forgot-password.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n**Users:**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/users.png\" alt=\"Frontend UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n## **Swagger Documentation**\n\n- Comprehensive API documentation is available at `/docs`.\n- Includes all endpoints, schemas, and examples.\n- Use Swagger UI to test and interact with the API.\n- The Swagger UI looks like this:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/swagger.png\" alt=\"Swagger UI\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n## **GraphQL Integration**\n\n- The Budget Management API supports GraphQL queries and mutations.\n- Access the GraphQL endpoint at `http://localhost:3000/api/graphql`.\n- Use the GraphiQL interface to interact with the API.\n- The GraphiQL interface looks like this:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/graphiql.png\" alt=\"GraphiQL\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n- Interact with the API using GraphQL queries and mutations. Examples include:\n\n```graphql\nquery {\n  budgets {\n    id\n    name\n    limit\n    createdAt\n  }\n}\n```\n\nOr:\n\n```graphql\nquery {\n  expenses(budgetId: \"64c9f8f2a73c2f001b3c68f4\") {\n    id\n    description\n    amount\n    budgetId\n    createdAt\n  }\n}\n```\n\nWhen you run these queries, you will receive a response with the requested data. GraphQL provides a flexible and efficient way to fetch and manipulate data from the backend. Here is an example:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/graphql.png\" alt=\"GraphQL\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n## **NGINX Configuration**\n\n- The `nginx` directory contains an Nginx configuration for reverse proxy and load balancing.\n- Use Nginx to route requests to multiple instances of the API.\n- Configure SSL termination and caching for improved performance.\n- The Nginx configuration looks like this:\n\n```nginx\nserver {\n    listen 80;\n    server_name localhost;\n\n    location / {\n        proxy_pass http://localhost:3000;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection 'upgrade';\n        proxy_set_header Host $host;\n        proxy_cache_bypass $http_upgrade;\n    }\n}\n```\n\n- For more information, refer to the [Nginx documentation](https://nginx.org/en/docs/) and the [Nginx Directory](nginx/README.md).\n\n## **gRPC Integration**\n\nThe Budget Management API includes support for **gRPC** to enable high-performance remote procedure calls.\n\n### **Getting Started**\n\n1. **Start the gRPC Server**:\n   Run the following command:\n   ```bash\n   node grpcServer.js\n   ```\n\n2. **Use the gRPC Client**:\n   Execute the client to interact with the server:\n   ```bash\n   node grpcClient.js\n   ```\n\n3. **Proto File**:\n   The `.proto` file for defining gRPC services and messages is located in the `protos` directory.\n\nThat's it! Your gRPC server and client should now be operational. 🚀\n\n## **Dockerization**\n\nThe Budget Management API can be run in a Docker container for easy deployment and scaling.\n\nYou can build and run the app using Docker Compose:\n\n```bash\ndocker-compose up --build\n```\n\n## **Kubernetes Deployment**\n\n1. Create Kubernetes manifests for the services.\n2. Deploy to a cluster:\n   ```bash\n   kubectl apply -f kubernetes/\n   ```\n   \n3. Access the application using the service URL.\n\n## **Spring Boot Backends with Maven and Gradle**\n\nThere is also a Spring Boot Java version of the Budget Management API available in the `spring-boot` directory. It is built using Maven and Gradle.\n\nTo run the Spring Boot Maven application, follow these steps:\n\n1. Navigate to the `spring-boot` directory:\n   ```bash\n   cd spring\n   ```\n\n2. Build the application using Maven:\n   ```bash\n    mvn clean install\n    ```\n   \n3. Run the application:\n    ```bash\n    mvn spring-boot:run\n    ```\n   \n4. Access the Spring Boot application at `http://localhost:8080`.\n\nTo run the Spring Boot Gradle application, follow these steps:\n\n1. Navigate to the `spring-boot` directory:\n   ```bash\n   cd gradle\n   ```\n   \n2. Build the application using Gradle:\n   ```bash\n    ./gradlew build\n    ```\n   \n3. Run the application:\n    ```bash\n    ./gradlew bootRun\n    ```\n   \n4. Access the Spring Boot application at `http://localhost:8080`.\n\n## **Dotnet Backend with C Sharp**\n\nThere is also a Dotnet C# version of the Budget Management API available in the `dotnet` directory. It is built using ASP.NET Core.\n\nTo run the Dotnet C# application, follow these steps:\n\n1. Navigate to the `dotnet` directory:\n   ```bash\n   cd dotnet\n   ```\n   \n2. Build the application using the .NET CLI:\n   ```bash\n    dotnet build\n    ```\n   \n3. Run the application:\n    ```bash\n    dotnet run\n    ```\n   \n4. Access the Dotnet C# application at `http://localhost:5000`.\n\n## **Continuous Integration and Deployment with Jenkins**\n\nThe Budget Management API includes a Jenkins pipeline for continuous integration and deployment.\n\n1. **Pipeline Configuration:** The `Jenkinsfile` defines the CI/CD pipeline stages, including code checkout, dependency installation, testing, building, and deployment. Add it to the root of the project.\n\n2. **Job Setup:** Create a pipeline job in Jenkins, point it to the repository, and configure it to use the `Jenkinsfile`.\n\n3. **Automated Testing:** The pipeline runs `npm test` to ensure all tests pass before proceeding to the build or deployment stages.\n\n4. **Environment Variables:** Use Jenkins environment variables to securely manage secrets like API keys and credentials for services such as MongoDB, Redis, or Render.\n\n5. **Deployment:** The pipeline supports deploying the application using Render or directly to a server using SSH and PM2.\n\n6. **Webhooks:** Integrate GitHub/GitLab webhooks to trigger builds automatically on code changes.\n\n7. **Notifications:** Add Slack or email notifications in the pipeline to inform team members about build and deployment statuses.\n\n### **GitHub Actions**\n\nThe Budget Management API also includes a GitHub Actions workflow for continuous integration and deployment.\n\n1. **Workflow Configuration:** The `.github/workflows/ci.yml` file defines the CI/CD workflow, including steps for checking out code, installing dependencies, running tests, and building the application.\n2. **Job Setup:** The workflow is triggered on push and pull request events to the `main` branch.\n3. **Automated Testing:** The workflow runs `npm test` to ensure all tests pass before proceeding to the build or deployment stages.\n4. **Deployment:** The workflow can be configured to deploy the application to Render or other hosting services using GitHub Actions deployment steps.\n5. **Environment Variables:** Use GitHub Secrets to securely manage sensitive information like API keys and database credentials.\n6. **Notifications:** Configure GitHub Actions to send notifications to Slack or email on build and deployment statuses.\n\nThis setup allows for automated testing and deployment, ensuring that the application is always in a deployable state.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/github-actions.png\" alt=\"GitHub Actions\" style=\"border-radius: 8px;\"\u003e\n\u003c/p\u003e\n\n## **Testing**\n\nThe Budget Management API includes unit tests for all endpoints and services.\n\nTo run the tests, use the following command:\n\n```bash\nnpm test\n```\n\nThe test results will be displayed in the console.\n\n**Watch Mode:** To run tests in watch mode, which automatically re-runs tests on file changes, use:\n\n```bash\nnpm test:watch\n```\n\n**Coverage Report:** To generate a code coverage report, use:\n\n```bash\nnpm test:coverage\n```\n\n**Mocha and Chai tests:** In addition to the Jest tests, the project also includes Mocha and Chai tests for the application. These tests can be run using:\n\n```bash\nnpm run test:mocha\n```\n\n## **Contributing**\n\nContributions are welcome! Please fork the repository, create a feature branch, and submit a pull request:\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature-branch`).\n3. Make changes and commit them (`git commit -am 'Add new feature'`).\n4. Push to the branch (`git push origin feature-branch`).\n5. Create a new pull request. We will review your changes and merge them if they look good.\n\n## **Author**\n\nThis project is built with ❤️ by:\n\n- **Son Nguyen** - [hoangsonww](https://github.com/hoangsonww)\n\nFor more information about me, you can visit my personal website or connect with me on LinkedIn:\n\n- **Website:** [https://sonnguyenhoang.com](https://sonnguyenhoang.com)\n- **Email:** [hoangson091104@gmail.com](mailto:hoangson091104@gmail.com)\n- **LinkedIn:** [https://www.linkedin.com/in/hoangsonw](https://www.linkedin.com/in/hoangsonw)\n- **GitHub:** [@hoangsonww](https://github.com/hoangsonww)\n\nFeel free to reach out if you have any questions or feedback! 🚀\n\n---\n\nThank you for using the **Budget Management API**. For questions, feedback, or support, please open an issue or [contact me directly](mailto:hoangson091104@gmail.com).\n\nCreated with ❤️ by [Son Nguyen](https://sonnguyenhoang.com) in 2024. All rights reserved.\n\n---\n\n[⬆️ Back to Top](#budget-management-api---a-comprehensive-microservices-based-api-for-managing-budgets-expenses-users-and-more-)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangsonww%2FBudget-Management-Backend-API","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoangsonww%2FBudget-Management-Backend-API","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangsonww%2FBudget-Management-Backend-API/lists"}