https://github.com/hassonor/microservices-jobber
microservices-jobber using: Node, TS, ES, Kibana,Postgresql,mysql,MongoDB, Cloudinary, RabbitMQ
https://github.com/hassonor/microservices-jobber
cloudinary elasticsearch hearbeat kibana microservices mongodb nodejs postgresql rabbitmq typescript
Last synced: 3 months ago
JSON representation
microservices-jobber using: Node, TS, ES, Kibana,Postgresql,mysql,MongoDB, Cloudinary, RabbitMQ
- Host: GitHub
- URL: https://github.com/hassonor/microservices-jobber
- Owner: hassonor
- License: mit
- Created: 2024-12-20T14:34:41.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-24T17:13:19.000Z (over 1 year ago)
- Last Synced: 2025-05-19T21:09:38.619Z (about 1 year ago)
- Topics: cloudinary, elasticsearch, hearbeat, kibana, microservices, mongodb, nodejs, postgresql, rabbitmq, typescript
- Language: TypeScript
- Homepage:
- Size: 313 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π Microservices Jobber Platform




**A production-ready freelance marketplace built with microservices architecture**
[Features](#-features) β’ [Quick Start](#-quick-start) β’ [Architecture](#-architecture) β’ [Documentation](#-documentation) β’ [Contributing](#-contributing)
---
## π Table of Contents
- [Overview](#-overview)
- [Features](#-features)
- [Tech Stack](#-tech-stack)
- [Architecture](#-architecture)
- [Quick Start](#-quick-start)
- [Project Structure](#-project-structure)
- [Services](#-services)
- [Development](#-development)
- [Testing](#-testing)
- [Deployment](#-deployment)
- [CI/CD](#-cicd)
- [Contributing](#-contributing)
- [License](#-license)
---
## π Overview
**Microservices Jobber** is a full-featured freelance marketplace platform demonstrating **production-grade microservices architecture**. Built with TypeScript, Node.js, and modern cloud-native technologies, this project serves as both a learning resource and a foundation for building scalable SaaS applications.
### Why This Project?
- β
**Production-Ready**: Real-world patterns, error handling, monitoring
- β
**Event-Driven**: RabbitMQ message queuing between services
- β
**Cloud-Native**: Docker, Kubernetes, horizontal scaling
- β
**Full Observability**: Elasticsearch, Kibana, Heartbeat monitoring
- β
**Educational**: Clear code, comprehensive documentation, best practices
---
## β¨ Features
### Core Functionality
- π **Authentication & Authorization**: JWT tokens, refresh tokens, 2FA support
- π₯ **User Management**: Profiles, roles, permissions, email verification
- πΌ **Gig Management**: Create, browse, search, filter freelance services
- π¬ **Real-time Chat**: WebSocket-based messaging between users
- π¦ **Order Management**: Complete order lifecycle with payment integration
- β **Review System**: Ratings, reviews, reputation scores
- π§ **Notifications**: Email, in-app, push notifications
- π **Full-text Search**: Elasticsearch-powered gig and user search
### Technical Features
- π― **API Gateway**: Centralized entry point with rate limiting
- π **Event-Driven Communication**: Async messaging with RabbitMQ
- πΎ **Polyglot Persistence**: MongoDB, MySQL, PostgreSQL, Redis
- π **Monitoring**: Elasticsearch, Kibana, Heartbeat, APM
- π **Horizontal Scaling**: Stateless services, Redis sessions
- π³ **Containerized**: Docker Compose for local, Kubernetes for production
---
## π Tech Stack
### Backend Services (8 Microservices)
| Service | Technology | Database | Description |
|---------|-----------|----------|-------------|
| **Gateway** | Express.js, TypeScript | Redis | API Gateway with rate limiting |
| **Notification** | Express.js, TypeScript | MongoDB | Email and push notifications |
| **Auth** | Express.js, TypeScript | PostgreSQL | Authentication & authorization |
| **Users** | Express.js, TypeScript | MongoDB | User profiles and management |
| **Gig** | Express.js, TypeScript | MongoDB | Freelance service listings |
| **Chat** | Express.js, TypeScript | MongoDB | Real-time messaging |
| **Order** | Express.js, TypeScript | MySQL | Order processing & payments |
| **Review** | Express.js, TypeScript | PostgreSQL | Ratings and reviews |
### Infrastructure
- **Message Queue**: RabbitMQ
- **Cache**: Redis 7
- **Search**: Elasticsearch 8
- **Monitoring**: Kibana, Heartbeat
- **Containerization**: Docker, Docker Compose
- **Orchestration**: Kubernetes (production)
### Shared Libraries
- **@ohjobber/shared**: Common utilities, types, middlewares
---
## π Architecture
### High-Level Architecture Diagram
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Layer β
β (Web App, Mobile App, Third-party) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β HTTPS
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway β
β βββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
β βRate Limit βββΆβAuthenticationβββΆβRequest Routing β β
β βββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββΌββββββββββββββββ¬βββββββββββββββ
βΌ βΌ βΌ βΌ
βββββββββββ βββββββββββ βββββββββββ ββββββββββββ
β Auth β β User β β Gig β β Chat β
β Service β β Service β β Service β β Service β
ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬ββββββ
β β β β
βββββββββββ βββββββββββ βββββββββββ ββββββββββββ
β Order β β Review β β Notif β β Gateway β
β Service β β Service β β Service β β API β
ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββββββββ
β β β
βββββββββββββββββ΄βββββββββββββββ
β
ββββββββββββ΄βββββββββββ
βΌ βΌ
βββββββββββββ ββββββββββββββ
β RabbitMQ β β Redis β
β (Events) β β (Cache) β
βββββββββββββ ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Data Layer (Polyglot) β
βββββββββββββββ¬ββββββββββββββββ€
β MongoDB β PostgreSQL β
β MySQL β Elasticsearch β
βββββββββββββββ΄ββββββββββββββββ
```
### Service Communication Patterns
1. **Synchronous**: HTTP/REST for request-response operations
2. **Asynchronous**: RabbitMQ events for fire-and-forget operations
3. **Caching**: Redis for sessions, rate limiting, frequently accessed data
4. **Search**: Elasticsearch for full-text search with denormalized data
---
## π Quick Start
Get the entire platform running locally in **10 minutes**:
### Prerequisites
- **Node.js** >= 20.x
- **Docker** & **Docker Compose** >= 20.x
- **Git**
### Installation
```bash
# 1. Clone the repository
git clone https://github.com/hassonor/microservices-jobber.git
cd microservices-jobber
# 2. Start infrastructure services (takes 5-10 min for Elasticsearch)
cd volumes
docker-compose up -d redis mongodb mysql postgres rabbitmq elasticsearch
# 3. Create Kibana service token
docker exec -it bash
bin/elasticsearch-service-tokens create elastic/kibana jobber-kibana
# Copy the token and add to ELASTICSEARCH_SERVICEACCOUNT_TOKEN in docker-compose.yml
# 4. Start Kibana
docker-compose up -d kibana
# 5. Update heartbeat.yml with your IP address
# Replace in volumes/heartbeat.yml
# 6. Install dependencies for all services
npm install --workspaces
# 7. Start services (recommended order)
cd ../2-notification-service && npm run dev &
cd ../3-auth-service && npm run dev &
cd ../4-users-service && npm run dev &
cd ../5-gig-service && npm run dev &
cd ../6-chat-service && npm run dev &
cd ../7-order-service && npm run dev &
cd ../8-review-service && npm run dev &
cd ../1-gateway-service && npm run dev # Start gateway last
```
### Access Points
| Service | URL | Description |
|---------|-----|-------------|
| **API Gateway** | http://localhost:4000 | Main entry point |
| **Elasticsearch** | http://localhost:9200 | Search engine |
| **Kibana** | http://localhost:5601 | Monitoring dashboard |
| **RabbitMQ** | http://localhost:15672 | Message queue UI (guest/guest) |
---
## π Project Structure
```
microservices-jobber/
βββ 1-gateway-service/ # API Gateway (port 4000)
β βββ src/
β β βββ controllers/ # Route handlers
β β βββ middleware/ # Auth, rate limiting, validation
β β βββ routes/ # API routes
β β βββ server.ts # Express app setup
β βββ package.json
β βββ tsconfig.json
β
βββ 2-notification-service/ # Email & push notifications
β βββ src/
β β βββ queues/ # RabbitMQ consumers
β β βββ templates/ # Email templates
β β βββ server.ts
β βββ package.json
β
βββ 3-auth-service/ # Authentication (port 4002)
β βββ src/
β β βββ controllers/ # Login, signup, refresh
β β βββ models/ # User model
β β βββ services/ # JWT, bcrypt logic
β β βββ server.ts
β βββ package.json
β
βββ 4-users-service/ # User profiles (port 4003)
βββ 5-gig-service/ # Gig listings (port 4004)
βββ 6-chat-service/ # Messaging (port 4005)
βββ 7-order-service/ # Orders & payments (port 4006)
βββ 8-review-service/ # Ratings & reviews (port 4007)
β
βββ volumes/ # Docker infrastructure
β βββ docker-compose.yaml # All infrastructure services
β βββ heartbeat.yml # Elasticsearch monitoring
β
βββ .cursorrules # AI coding assistant configuration
βββ .github/
β βββ dependabot.yml # Automated dependency updates
β βββ workflows/ # CI/CD pipelines
βββ README.md
```
---
## π§ Services
### 1. Gateway Service (Port 4000)
**Entry point for all client requests**
- Rate limiting (100 req/15min per IP)
- Authentication middleware
- Request validation
- Service routing
- CORS configuration
**Key Endpoints**:
```
POST /api/v1/auth/signup
POST /api/v1/auth/login
GET /api/v1/gigs/search
POST /api/v1/orders
```
### 2. Notification Service
**Async email and push notifications**
- Email templates (signup, order confirmation, etc.)
- SendGrid/Mailgun integration
- RabbitMQ consumer for notification events
- Notification history tracking
### 3. Auth Service (Port 4002)
**JWT-based authentication**
- User registration with email verification
- Login with refresh token rotation
- Password reset flow
- 2FA support (optional)
### 4. Users Service (Port 4003)
**User profile management**
- Profile CRUD operations
- Seller/buyer profiles
- Avatar upload (Cloudinary)
- Activity history
### 5. Gig Service (Port 4004)
**Freelance service listings**
- Create/update/delete gigs
- Full-text search (Elasticsearch)
- Category filtering
- Image uploads (Cloudinary)
### 6. Chat Service (Port 4005)
**Real-time messaging**
- WebSocket connections
- Message persistence (MongoDB)
- Conversation history
- Typing indicators
### 7. Order Service (Port 4006)
**Order processing & payments**
- Order lifecycle management
- Stripe/PayPal integration
- Order status updates via events
- Refund handling
### 8. Review Service (Port 4007)
**Ratings and reviews**
- Create/update reviews
- Seller rating calculation
- Review moderation
- Aggregate statistics
---
## π» Development
### Environment Setup
Each service requires a `.env` file:
```bash
# Example for auth-service/.env
NODE_ENV=development
PORT=4002
DATABASE_URL=postgresql://user:pass@localhost:5432/jobber_auth
JWT_SECRET=your-secret-key-change-in-production
JWT_EXPIRES_IN=1h
REFRESH_TOKEN_SECRET=your-refresh-secret
RABBITMQ_URL=amqp://localhost:5672
REDIS_URL=redis://localhost:6379
```
### Running Individual Services
```bash
# Development mode with hot reload
cd 3-auth-service
npm run dev
# Production mode
npm run build
npm start
# Lint & format
npm run lint
npm run lint:fix
```
### Code Quality
This project follows strict TypeScript and ESLint rules:
```bash
# Run linting
npm run lint
# Fix auto-fixable issues
npm run lint:fix
# Type checking
npm run type-check
```
### Shared Package
Common utilities are in `@ohjobber/shared`:
```typescript
import { BadRequestError, NotFoundError } from '@ohjobber/shared';
import { CustomResponse, IAuthPayload } from '@ohjobber/shared';
```
---
## π§ͺ Testing
### Unit Tests
```bash
# Run tests for a service
cd 3-auth-service
npm test
# Watch mode
npm run test:watch
# Coverage report
npm run test:coverage
```
### Integration Tests
```bash
# Run integration tests (requires Docker)
npm run test:integration
```
### E2E Tests
```bash
# Start all services first
npm run dev:all
# Run E2E tests
npm run test:e2e
```
---
## π’ Deployment
### Docker Compose (Development)
```bash
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f gateway
# Stop all services
docker-compose down
```
### Kubernetes (Production)
```bash
# Apply Kubernetes manifests
kubectl apply -f k8s/
# Check deployment status
kubectl get pods
kubectl get services
# Scale a service
kubectl scale deployment gig-service --replicas=3
```
### Environment Variables (Production)
Required secrets for production:
```bash
JWT_SECRET=
REFRESH_TOKEN_SECRET=
DATABASE_URL=
REDIS_URL=
RABBITMQ_URL=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
STRIPE_SECRET_KEY=
SENDGRID_API_KEY=
```
---
## π CI/CD
### GitHub Actions
Automated workflows for:
- **Linting**: ESLint on every push
- **Testing**: Unit + integration tests
- **Security**: Dependabot for vulnerabilities
- **Build**: Docker image builds
- **Deploy**: Automatic deployment to staging on PR merge
### Jenkins (Alternative)
Jenkins pipeline configuration included in `Jenkinsfile`:
```groovy
pipeline {
stages {
stage('Test') { ... }
stage('Build') { ... }
stage('Deploy') { ... }
}
}
```
---
## π€ Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
### Quick Contribution Guide
1. **Fork** the repository
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
3. **Commit** your changes following [Conventional Commits](https://www.conventionalcommits.org/)
4. **Push** to the branch (`git push origin feature/amazing-feature`)
5. **Open** a Pull Request
### Code Standards
- Follow the existing `.cursorrules` configuration
- Write unit tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
---
## π License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
---
## π Acknowledgments
- Inspired by production freelance platforms like Upwork and Fiverr
- Built for educational purposes to demonstrate microservices architecture
- Special thanks to the open-source community for the amazing tools
---
## π Support
- **Issues**: [GitHub Issues](https://github.com/hassonor/microservices-jobber/issues)
- **Discussions**: [GitHub Discussions](https://github.com/hassonor/microservices-jobber/discussions)
---
**Made with β€οΈ by [Or Hasson](https://github.com/hassonor)**
β Star this repo if you find it helpful!