9
Microservices
7
Databases
40+
API Endpoints
4
Protocols
Project Overview
Purpose
The Budget Management API is a comprehensive backend platform designed to demonstrate modern microservices architecture, showcasing integration of multiple technologies and best practices in building scalable, production-ready applications.
Key Capabilities
- Budget & expense tracking
- User authentication & management
- Real-time notifications
- Advanced search with Elasticsearch
- Asynchronous task processing
- Multi-protocol API support
Why This Project?
Perfect for developers looking to learn or reference modern backend development practices. It demonstrates real-world implementation of microservices, message queuing, caching strategies, container orchestration, and CI/CD pipelines.
System Architecture
The Budget Management API follows a microservices architecture pattern, allowing independent development, deployment, and scaling of services. Each service handles a specific domain and communicates through well-defined interfaces.
Microservices Architecture
Service Communication Flow
Technology Stack
Backend
Databases
Messaging
Protocols
DevOps
Monitoring
Core Features & Integrations
Authentication & Security
JWT-based authentication, bcrypt password hashing, role-based access control, and secure session management.
- User registration & login
- Email verification
- Password reset
- Token-based auth
GraphQL Support
Flexible data queries with GraphQL, allowing clients to request exactly what they need.
- Query budgets & expenses
- GraphiQL interface
- Real-time subscriptions
- Type-safe schema
gRPC Integration
High-performance RPC framework for inter-service communication with protocol buffers.
- Low latency calls
- Binary protocol
- Strong typing
- Bidirectional streaming
WebSocket Real-time
Real-time bidirectional communication for live notifications and updates.
- Live notifications
- Real-time updates
- Chat support
- Event broadcasting
Elasticsearch Search
Advanced full-text search capabilities with filtering, aggregations, and analytics.
- Full-text search
- Fuzzy matching
- Aggregations
- Real-time indexing
Redis Caching
In-memory caching for improved performance and reduced database load.
- Session management
- Data caching
- Rate limiting
- Pub/Sub messaging
Message Queuing
Asynchronous task processing with RabbitMQ and Kafka for reliable message delivery.
- Task queuing
- Event streaming
- Guaranteed delivery
- Load balancing
Containerization
Fully containerized with Docker and orchestrated with Kubernetes for scalability.
- Docker Compose
- Kubernetes manifests
- Auto-scaling
- Health checks
CI/CD Pipeline
Automated testing and deployment with Jenkins and GitHub Actions.
- Automated tests
- Blue-green deployment
- Canary releases
- Rollback support
Project Structure
Directory Organization
Key Directories
API endpoint handlers and business logic
External service integrations (Redis, RabbitMQ, Elasticsearch)
MongoDB/Mongoose schemas for data models
Express route definitions and API routing
Authentication, validation, and error handling
GraphQL schema and resolver definitions
gRPC protocol buffer definitions
K8s deployment manifests and configs
React-based demo UI application
Swagger/OpenAPI documentation
Getting Started
Clone Repository
git clone https://github.com/hoangsonww/Budget-Management-Backend-API.git
cd Budget-Management-Backend-API
Install Dependencies
npm install
Configure Environment
cp .env.example .env
# Edit .env with your configuration
Required Environment Variables:
MONGO_DB_URI- MongoDB connection stringREDIS_URL- Redis connection URLRABBITMQ_URL- RabbitMQ connection stringKAFKA_BROKER- Kafka broker addressJWT_SECRET- Secret key for JWT tokensELASTIC_SEARCH_URL- Elasticsearch endpointPOSTGRES_URL- PostgreSQL connection string
Start with Docker (Recommended)
docker-compose up --build
This starts all services: API, MongoDB, Redis, RabbitMQ, Kafka, Elasticsearch
Or Start Locally
npm start
# API available at http://localhost:3000
# Swagger docs at http://localhost:3000/docs
Alternative Setups
CLI Usage
npm link
budget-manager --help
budget-manager seed
budget-manager list-budgets
Kubernetes Deployment
kubectl apply -f kubernetes/
kubectl get pods
kubectl get services
Frontend Demo
cd frontend
npm install
npm start
API Documentation
The Budget Management API provides 40+ endpoints across multiple services. Full interactive documentation is available via Swagger UI.
Authentication
Budget Management
Expense Tracking
Search & Analytics
Protocol Examples
REST API
curl -X POST https://budget-management-backend-api.onrender.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'
GraphQL
query {
budgets {
id
name
limit
createdAt
}
}
gRPC
const client = new BudgetServiceClient('localhost:50051');
client.getBudget({ id: '123' }, (err, response) => {
console.log(response);
});
WebSocket
const ws = new WebSocket('ws://localhost:3000');
ws.onmessage = (event) => {
console.log('Notification:', event.data);
};
Deployment Strategies
Blue-Green Deployment
Zero-downtime deployment with instant rollback capability. Switch traffic between blue and green environments.
Canary Deployment
Gradual rollout with traffic shifting. Test new version with small percentage of users first.
Rolling Deployment
Gradual update of instances one at a time, ensuring service availability throughout the process.
Testing & Quality Assurance
Test Coverage
Comprehensive test suite with unit tests, integration tests, and end-to-end testing.
npm test # Run all tests
npm test:watch # Watch mode
npm test:coverage # Coverage report
npm run test:mocha # Mocha tests
Security Audits
Regular security scanning and vulnerability checks using npm audit and OWASP tools.
npm audit # Security audit
npm audit fix # Auto-fix vulnerabilities
Code Quality
ESLint and Prettier for code consistency and quality standards enforcement.
npm run format # Format code
npm run lint # Lint code
Additional Resources
Swagger Documentation
Interactive API documentation with try-it-out functionality
Frontend Demo
Live React-based UI demonstrating API integration
GitHub Repository
Source code, issues, and contribution guidelines
Documentation
Comprehensive guides in the /docs directory
CLI Tool
Command-line interface for direct API interaction
Docker Hub
Pre-built Docker images for quick deployment