Skip to content

This project is a Go-based microservice that integrates Kafka messaging and WebSocket support. It provides an infrastructure for real-time data processing, message broadcasting, and external exchange interactions.

Notifications You must be signed in to change notification settings

AlbertKarapetyan/crypto-price-broadcast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Prices Broadcast

Overview

This project is a Go-based microservice that integrates Kafka messaging and WebSocket support. It provides an infrastructure for real-time data processing, message broadcasting, and external exchange interactions.

Features

  • Microservice Architecture: Modular design with clear separation of concerns.
  • Dependency Injection with Wire: Uses Google Wire for dependency injection, improving modularity and testability.
  • Kafka Integration: Supports message production and consumption.
  • WebSocket Support: Connects to external WebSocket services (e.g., Binance API).
  • Automatic Configuration Reload: Monitors changes in configuration files and applies updates without restarting the service.
  • Dockerized Deployment: Comes with Docker and Docker Compose support for easy deployment.

Project Structure

.
├── config.json
├── docker-compose.yml
├── Dockerfile
├── go.mod
├── go.sum
├── main.go
├── README.md
├── internal/
│   ├── app/
│   │   ├── wire.go
│   │   ├── wire_gen.go
│   ├── common/
│   │   ├── log.go
│   ├── config/
│   │   ├── checker.go
│   │   ├── config.go
│   ├── infrastructure/
│   │   ├── message_buss/
│   │   │   ├── kafka_consumer.go
│   │   │   ├── kafka_producer.go
│   │   ├── web_sockets/
│   │       ├── binance_service.go
│   ├── models/
│   │   ├── config.go
│   ├── services/
│   │   ├── broadcast.go
│   │   ├── interfaces/
│   │       ├── broad_cast.go
│   │       ├── consumer.go
│   │       ├── exchange_service.go
│   │       ├── producer.go

Installation

Prerequisites

  • Go 1.XX+
  • Docker & Docker Compose
  • Kafka

Setup

  1. Clone the repository:
    git clone <repository-url>
    cd crypto-price-broadcast
  2. Install dependencies:
    go mod tidy
  3. Generate dependency injection with Wire:
    wire
  4. Start Kafka (if not running):
    docker-compose up -d
  5. Run the service:
    go run main.go

Configuration

Modify config.json to update Kafka settings, WebSocket endpoints, and other parameters.

Automatic Configuration Reload

The service supports automatic reloading of configuration files. When config.json is updated, the changes are applied dynamically without requiring a restart. This feature ensures seamless updates and minimizes downtime.

Dependency Injection with Wire

The project uses Google Wire for dependency injection. Wire helps in managing dependencies efficiently and improves the modularity and testability of the application. To regenerate dependency injection code, run:

wire

Deployment

To build and run the service in Docker:

docker build -t crypto-price-broadcast .
docker run -d --name crypto-price-broadcast crypto-price-broadcast

Or use Docker Compose:

docker-compose up -d

Benefits

  • Scalability: The microservice architecture allows easy scaling of individual components.
  • Modularity: Well-structured codebase ensures better maintainability and extensibility.
  • Real-time Processing: Kafka and WebSocket integration enable efficient real-time message handling.
  • Ease of Deployment: Dockerized setup simplifies deployment across different environments.
  • Automatic Configuration Updates: Reduces downtime by dynamically reloading configuration changes.
  • Improved Testability: Dependency injection with Wire enhances testability by decoupling components.

MIT License. See LICENSE file for details.

About

This project is a Go-based microservice that integrates Kafka messaging and WebSocket support. It provides an infrastructure for real-time data processing, message broadcasting, and external exchange interactions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published