Follow these steps to run the Zappy project locally on your machine.
- Ensure you have Docker installed and running.
- Have Node.js and pnpm installed.
- PostgreSQL database is required.
Create a .env file for each service in your project and include the necessary database connection details (PostgreSQL URL, etc.).
Example .env file:
DATABASE_URL=postgresql://username:password@localhost:5432/zappy- a great article by kafka here
Run the following command to start a Kafka container:
docker run -p 9092:9092 apache/kafka:3.9.0If you already have a Kafka container, use the command below to start it:
docker start <container_id>If Kafka is running, access the container:
docker exec -it <container_id> /bin/bashOnce inside the container, navigate to the Kafka binary directory:
cd /opt/kafka/binCreate a Kafka topic named zap-events by running the following command:
./kafka-topics.sh --create --topic zap-events --bootstrap-server localhost:9092To list all topics:
./kafka-topics.sh --bootstrap-server localhost:9092 --listCreate a consumer for the zap-events topic:
./kafka-console-consumer.sh --topic zap-events --from-beginning --bootstrap-server localhost:9092You can produce messages to the zap-events topic using the CLI:
./kafka-console-producer.sh --bootstrap-server localhost:9092 --topic zap-eventsEnter a message and press Enter to send it.
The project includes a Node.js script to act as a producer. Refer to the relevant script in the codebase to produce events programmatically.
To delete all messages on a topic:
./kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic zap-eventsYour Zappy project should now be ready to run locally. For any issues, refer to the logs or project documentation.