Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A high-performance, event-driven system for concurrent emoji broadcasting and processing using Kafka and Flask.

Notifications You must be signed in to change notification settings

aryan-212/EmoStream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

EmoStream: Real-time Emoji Processing System ๐Ÿš€

What is this? A fun system that lets you send emojis and broadcast them to multiple people in real-time!

Think of it like: A group chat where everyone can send emojis and see them instantly, but built with enterprise-grade technology.

Perfect for: Learning about distributed systems, real-time messaging, or just having fun with emojis!

Overview

EmoStream is a distributed system that enables real-time emoji broadcasting and processing. It uses an event-driven architecture with Kafka as the message broker to handle concurrent emoji submissions and broadcasting to multiple subscribers.

๐Ÿ—๏ธ What's Happening? (Simple Version)

The Magic: When you send an emoji, it goes through this journey:

  1. ๐Ÿ“ฑ You โ†’ Send emoji via API
  2. ๐Ÿ–ฅ๏ธ Flask App โ†’ Receives emoji and sends it to Kafka
  3. ๐Ÿ“จ Kafka โ†’ Stores and distributes the emoji to all subscribers
  4. ๐Ÿ“ก Subscribers โ†’ Receive emoji and can send it to connected clients
  5. ๐Ÿ‘ฅ Everyone โ†’ Gets the emoji in real-time!

Why Kafka? It's like a super-fast post office that never loses letters and can handle millions of messages per second!

Why Multiple Subscribers? So many people can connect at once without slowing down the system.

Features

  • Real-time emoji broadcasting
  • Concurrent client support
  • Event-driven architecture
  • Scalable subscriber system
  • RESTful API for client management
  • Health monitoring and logging
  • Docker containerization

Prerequisites

  • Docker
  • Docker Compose
  • Python 3.9+
  • Kafka (provided via Docker)

๐Ÿš€ Quick Start (For Anyone!)

Choose your adventure:

โšก Super Quick (3 commands)

See QUICKSTART.md for the fastest way to get running!

๐Ÿ“– Step-by-Step

See INSTALL.md for detailed installation instructions.

๐ŸŽฏ Right Here (Summary)

# 1. Get the code (download ZIP or git clone)
# 2. Start everything
docker-compose up --build -d

# 3. Test it works
curl http://localhost:5000/

# 4. Send your first emoji
curl -X POST http://localhost:5000/emoji \
  -H "Content-Type: application/json" \
  -d '{"emoji_type": "๐Ÿ˜Š", "timestamp": "2025-08-13T20:45:00Z"}'

๐ŸŽ‰ That's it! Your EmoStream is now running!

๐ŸŽฏ Try It Out!

Test the API with Simple Commands

1. Send an Emoji

curl -X POST http://localhost:5000/emoji \
  -H "Content-Type: application/json" \
  -d '{"emoji_type": "๐Ÿ˜Š", "timestamp": "2025-08-13T20:45:00Z"}'

Expected response:

{
  "message": "Emoji sent successfully"
}

2. Register a Client

curl -X POST http://localhost:5000/register_client \
  -H "Content-Type: application/json" \
  -d '{"client_id": "my_first_client"}'

Expected response:

{
  "message": "Client my_first_client successfully registered.",
  "assigned_subscriber": {
    "cluster_id": 1,
    "subscriber_id": 2,
    "port": 6005
  }
}

3. List All Clients

curl http://localhost:5000/list_clients

Expected response:

{
  "my_first_client": {
    "cluster_id": 1,
    "subscriber_id": 2,
    "port": 6005
  }
}

4. Deregister a Client

curl -X POST http://localhost:5000/deregister_client \
  -H "Content-Type: application/json" \
  -d '{"client_id": "my_first_client"}'

Expected response:

{
  "message": "Client my_first_client deregistered successfully"
}

๐ŸŽฎ Interactive Testing

Want to test without command line? Use these tools:

  • Postman - Import the requests above
  • Insomnia - Copy the curl commands
  • Browser - For GET requests like http://localhost:5000/

๐Ÿ“ฑ Test with Different Emojis

Try these emoji types:

  • ๐Ÿ˜Š (smile)
  • ๐Ÿ˜‚ (laugh)
  • โค๏ธ (heart)
  • ๐Ÿ‘ (thumbs up)
  • ๐ŸŽ‰ (party)
  • ๐Ÿš€ (rocket)
  • ๐ŸŒŸ (star)

๐Ÿงช Testing

๐Ÿš€ Quick Demo (Recommended for first-time users)

# Linux/Mac
./demo.sh

# Windows
demo.bat

What the demo does:

  • โœ… Tests health endpoint
  • โœ… Sends a test emoji
  • โœ… Registers a test client
  • โœ… Lists all clients
  • โœ… Shows you everything is working!

๐Ÿ”ฌ Run the Built-in Tests

# Run all tests
docker-compose up test

# Or use the Makefile
make test

What the tests do:

  • โœ… Test client registration
  • โœ… Test emoji submission
  • โœ… Test client deregistration
  • โœ… Simulate 100+ concurrent users
  • โœ… Test message delivery performance

๐Ÿšจ Troubleshooting

"Docker not found" Error

# Install Docker first:
# Windows/Mac: Download from https://docker.com
# Linux: sudo apt install docker.io docker-compose

"Port already in use" Error

# Stop any existing services
docker-compose down

# Or kill processes using ports 5000, 9092, 2181

"Connection refused" Error

# Wait longer for services to start
# Check status:
docker-compose ps

# View logs:
docker-compose logs app

"Permission denied" Error (Linux)

# Add your user to docker group
sudo usermod -aG docker $USER
# Then logout and login again

๐Ÿ“Š Check System Status

# See all running services
docker-compose ps

# View real-time logs
docker-compose logs -f

# Check specific service logs
docker-compose logs app
docker-compose logs kafka

๐Ÿ›‘ Stop Everything

# Stop all services
docker-compose down

# Or use the Makefile
make down

# Remove everything (including data)
docker-compose down -v

โš™๏ธ Configuration

For most people: You don't need to change anything! The defaults work perfectly.

For developers: You can customize these settings:

  • KAFKA_BROKER: Kafka broker address (default: kafka:29092)
  • FLASK_APP: Flask application entry point (default: src/app.py)
  • FLASK_ENV: Environment (default: development)

Monitoring

  • Container health checks
  • Logging to /app/logs
  • Kafka topic monitoring
  • Client connection tracking

๐ŸŽฏ Common Commands (Copy & Paste)

# Start everything
docker-compose up --build -d

# Check if it's working
curl http://localhost:5000/

# Send an emoji
curl -X POST http://localhost:5000/emoji \
  -H "Content-Type: application/json" \
  -d '{"emoji_type": "๐Ÿ˜Š", "timestamp": "2025-08-13T20:45:00Z"}'

# Stop everything
docker-compose down

# View logs
docker-compose logs -f

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Need help? Open an issue or check the troubleshooting section above!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Kafka for message queuing
  • Flask for the web framework
  • Docker for containerization

About

A high-performance, event-driven system for concurrent emoji broadcasting and processing using Kafka and Flask.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published