This project demonstrates a real-time notification system implemented in Golang, utilizing Apache Kafka for message processing. The Kafka server is set up using Docker containers for easy deployment.
Before running this project, make sure you have the following installed:
- Go (Golang): Installation Guide
- Docker: Installation Guide
- Apache Kafka: Installation Guide
-
Open a terminal and navigate to the project directory.
-
Start the Kafka server using the provided Docker Compose configuration:
docker-compose up -d
OR
Start your local Kafka server
- Run cmd/consumer/consumer.go - Starts Consumer Server
- Run cmd/producer/producer.go - Starts Producer Server
- 8080: Producer Port
curl -X POST http://localhost:8080/send -d "fromID=2&toID=1&message=your message"
- Response:
{"message":"Notification sent successfully!"}
- 8081: Consumer Port
http://localhost:8081/notifications/{user_id}
Response:
{
"notifications":
[
{
"from": {"id":3,"name":"Eldar"},
"to": {"id":4,"name":"Farid"},
"message": "necesen bratan"
}
]
}
- cmd/
- consumer/
- consumer.go
- producer/
- producer.go
- consumer/
- pkg/
- models/
- models.go
- models/
- docker-compose.yml
- README.md