Skip to content

Commit e10c391

Browse files
committed
Initial commit - Full stack RabbitMQ Kafka demo
1 parent 26a9330 commit e10c391

File tree

150 files changed

+11425
-10629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+11425
-10629
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Default code owners
2+
* @jmrashed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Bug report
2+
about: Create a report to help us improve
3+
title: '[BUG] '
4+
labels: bug
5+
6+
## Describe the bug
7+
A clear and concise description of what the bug is.
8+
9+
## To Reproduce
10+
Steps to reproduce the behavior:
11+
1.
12+
2.
13+
3.
14+
15+
## Expected behavior
16+
What you expected to happen.
17+
18+
## Additional context
19+
Add any other context about the problem here.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Feature request
2+
about: Suggest an idea for this project
3+
title: '[FEATURE] '
4+
labels: enhancement
5+
6+
## Is your feature request related to a problem? Please describe.
7+
8+
## Describe the solution you'd like
9+
10+
## Alternatives considered
11+
12+
## Additional context

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Summary
2+
Provide a short description of the change.
3+
4+
## Changes
5+
- What changed and why.
6+
7+
## Verification
8+
- How was this tested? Include commands and environment.
9+
10+
## Checklist
11+
- [ ] I have read the contributing guidelines
12+
- [ ] Tests added or updated
13+
- [ ] Documentation updated if necessary

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
release:
9+
types: [ published ]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
services:
16+
rabbitmq:
17+
image: rabbitmq:3-management
18+
ports:
19+
- 5672:5672
20+
- 15672:15672
21+
env:
22+
RABBITMQ_DEFAULT_USER: guest
23+
RABBITMQ_DEFAULT_PASS: guest
24+
25+
zookeeper:
26+
image: confluentinc/cp-zookeeper:7.4.0
27+
ports:
28+
- 2181:2181
29+
env:
30+
ZOOKEEPER_CLIENT_PORT: 2181
31+
ZOOKEEPER_TICK_TIME: 2000
32+
33+
kafka:
34+
image: confluentinc/cp-kafka:7.4.0
35+
ports:
36+
- 9092:9092
37+
env:
38+
KAFKA_BROKER_ID: 1
39+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
40+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
41+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
42+
43+
steps:
44+
- uses: actions/checkout@v3
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v3
48+
with:
49+
node-version: '18'
50+
cache: 'npm'
51+
52+
- name: Install dependencies
53+
run: npm ci
54+
55+
- name: Wait for services
56+
run: sleep 30
57+
58+
- name: Run tests
59+
run: npm test
60+
env:
61+
RABBITMQ_URL: amqp://localhost
62+
KAFKA_BROKERS: localhost:9092
63+
64+
docker:
65+
runs-on: ubuntu-latest
66+
needs: test
67+
if: github.event_name == 'release'
68+
69+
steps:
70+
- uses: actions/checkout@v3
71+
72+
- name: Build Docker image
73+
run: docker build -t rabbitmq-kafka-node-demo:${{ github.event.release.tag_name }} .
74+
75+
- name: Test Docker image
76+
run: |
77+
docker-compose up -d
78+
sleep 30
79+
docker-compose ps
80+
docker-compose down

.github/workflows/nodejs.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [16.x, 18.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- name: Install dependencies
24+
run: npm ci
25+
- name: Run tests
26+
run: |
27+
if npm run | grep -q "test"; then npm test; else echo "No tests defined"; fi

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
.report/
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
.nyc_output
24+
/coverage
25+
.coverage
26+
27+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (https://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# Snowpack dependency directory (https://snowpack.dev/)
44+
web_modules/
45+
46+
# TypeScript cache
47+
*.tsbuildinfo
48+
49+
# Optional npm cache directory
50+
.npm
51+
52+
# Optional eslint cache
53+
.eslintcache
54+
55+
# Optional stylelint cache
56+
.stylelintcache
57+
58+
# Microbundle cache
59+
.rpt2_cache/
60+
.microbundle/
61+
62+
# Custom Report Files
63+
.jest-test-results.json
64+
.eslint-report.json
65+
66+
# dotenv environment variables file
67+
.env
68+
.env.development.local
69+
.env.test.local
70+
.env.production.local
71+
.env.local
72+
73+
# next.js build output
74+
.next/
75+
out/
76+
77+
# nuxt.js build output
78+
.nuxt/
79+
dist/
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# sveltekit build output
85+
.svelte-kit/
86+
.svelte-kit-types/
87+
build/
88+
89+
# Serverless directories
90+
.serverless/
91+
92+
# FuseBox cache
93+
.fusebox/
94+
95+
# DynamoDB Local
96+
.dynamodb/
97+
98+
# TernJS port file
99+
.tern-port
100+
101+
# macOS
102+
.DS_Store
103+
104+
# Windows
105+
Thumbs.db
106+
ehthumbs.db

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [1.0.0] - 2024-01-XX
6+
7+
### Added
8+
- Complete Docker Compose setup with RabbitMQ, Kafka, and Zookeeper
9+
- REST API endpoints for message production
10+
- Consumer services for both RabbitMQ and Kafka
11+
- Example scripts for testing and load testing
12+
- Comprehensive documentation and README
13+
- GitHub Actions CI/CD pipeline
14+
- Health checks for all services
15+
- Logging with Winston
16+
- Environment configuration with dotenv
17+
18+
### Features
19+
- **Message Brokers**: RabbitMQ and Apache Kafka integration
20+
- **REST API**: HTTP endpoints for message production
21+
- **Docker Support**: Full containerization with docker-compose
22+
- **Examples**: Ready-to-use demonstration scripts
23+
- **Testing**: Automated test suite and load testing
24+
- **Monitoring**: Service health checks and logging
25+
- **CI/CD**: GitHub Actions workflow
26+
27+
### Technical Stack
28+
- Node.js 18+
29+
- Express.js for REST API
30+
- RabbitMQ with amqplib
31+
- Apache Kafka with kafkajs
32+
- Docker & Docker Compose
33+
- Winston for logging
34+
- Axios for HTTP requests
35+
36+
### Project Structure
37+
```
38+
├── config/ # Configuration files
39+
├── services/ # Core services (producers/consumers)
40+
├── examples/ # Example scripts
41+
├── test/ # Test files
42+
├── scripts/ # Utility scripts
43+
├── .github/workflows/ # CI/CD workflows
44+
├── docker-compose.yml # Docker services
45+
├── Dockerfile # App container
46+
└── README.md # Documentation
47+
```

CODE_OF_CONDUCT.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Contributor Covenant Code of Conduct
2+
Version 2.1
3+
4+
Our pledge
5+
6+
In the interest of fostering an open and welcoming environment, we as contributors
7+
and maintainers pledge to make participation in our project and our community
8+
a harassment-free experience for everyone.
9+
10+
Standards
11+
12+
Examples of behavior that contributes to a positive environment include:
13+
14+
- Using welcoming and inclusive language
15+
- Being respectful of differing viewpoints and experiences
16+
- Gracefully accepting constructive criticism
17+
- Focusing on what is best for the community
18+
- Showing empathy towards other community members
19+
20+
Unacceptable behavior includes harassment, trolling, offensive comments, and
21+
personal attacks. Contributors asked to stop unacceptable behavior are expected
22+
to comply immediately.
23+
24+
Enforcement
25+
26+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
27+
reported by contacting the project maintainers at jmrashed@gmail.com. All
28+
complaints will be reviewed and investigated and will result in a response that
29+
is deemed necessary and appropriate to the circumstances. Maintainers who do
30+
not follow or enforce the Code of Conduct may be temporarily or permanently
31+
removed from the project team.
32+
33+
Attribution
34+
35+
This Code of Conduct is adapted from the Contributor Covenant, available at
36+
https://www.contributor-covenant.org/version/2/1/code_of_conduct/

0 commit comments

Comments
 (0)