This guide provides instructions for installing and running the Coffee Order System.
Before installing the Coffee Order System, ensure you have the following prerequisites:
- Go: Version 1.22 or higher. Download Go.
- Kafka: A running Kafka instance. Download Kafka.
- Git: For cloning the repository. Download Git.
If you don't have Kafka running, you can set it up using Docker:
# Pull the Kafka image
docker pull bitnami/kafka
# Start Kafka
docker run -d --name kafka \
-p 9092:9092 \
-e KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
bitnami/kafkagit clone https://github.com/yourusername/coffee-order-system.git
cd coffee-order-system# Install Producer dependencies
cd producer
go mod tidy
# Install Consumer dependencies
cd ../consumer
go mod tidycd producer
go run main.goThe Producer service will start an HTTP server on port 3000 (by default).
cd consumer
go run main.goThe Consumer service will start consuming messages from the Kafka topic.
To verify that the system is working correctly, you can place a coffee order using the API:
curl -X POST http://localhost:3000/order \
-H "Content-Type: application/json" \
-d '{"customer_name":"John Doe","coffee_type":"Latte"}'You should see a response like:
{
"success": true,
"msg": "Order for John Doe placed successfully!"
}And in the Consumer service logs, you should see a message like:
Brewing Latte coffee for John Doe
By default, the system uses the following configuration:
- Producer service runs on port 3000
- Kafka broker is at localhost:9092
- Kafka topic is "coffee_orders"
To customize the configuration, see the Configuration document.
If you encounter any issues during installation or running the system, see the Troubleshooting document.
- Configuration: Configure the system.
- API Reference: Explore the API endpoints.
- Development Guide: Learn how to develop the system.