Skip to content

huseyinbabal/sse-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

SSE Dashboard - Real-Time Stock Price Tracker

A minimal demonstration of Server-Sent Events (SSE) using Go and vanilla JavaScript. The server simulates live stock ticker updates for AAPL, GOOG, MSFT, AMZN, and TSLA, streaming them to a browser-based dashboard in real time.

Prerequisites

No external dependencies — the project uses only the Go standard library.

Run the Server

go run server.go

Open the Dashboard

Once the server is running, open your browser and navigate to:

http://localhost:8080/

The dashboard connects automatically and starts displaying live stock price updates every second.

Project Structure

.
├── go.mod          # Go module definition (zero external deps)
├── server.go       # Go server with SSE broker and HTTP handlers
└── static/
    └── index.html  # Self-contained frontend dashboard

How It Works

  1. Broker — A pub/sub fan-out broker manages connected SSE clients using Go channels.
  2. Ticker — A goroutine fires every second, picks a random stock symbol, generates a random price, and publishes a stock-update event.
  3. SSE Endpoint (/events) — Streams events to each connected client using the text/event-stream content type.
  4. Dashboard (/) — Uses the native EventSource API to receive events and render a live-updating price table with an event log.

API

Endpoint Description
GET / Serves the dashboard UI
GET /events SSE stream of stock price updates

About

SSE Demo in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors