Skip to content

middleware-labs/social-feed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Feed - Multi-Language Microservices Demo

A social media feed application built as a polyglot microservices system. Each service is written in a different language with zero pre-baked instrumentation -- designed to be a clean target for external observability tools (OTel Operator, sidecars, eBPF, etc.).

Architecture

                         ┌──────────────┐
                         │   data-gen   │ (Python)
                         │  generates   │
                         │   traffic    │
                         └──────┬───────┘
                                │ HTTP calls to all services
        ┌───────────┬───────────┼───────────┬───────────┬───────────┐
        ▼           ▼           ▼           ▼           ▼           ▼
  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
  │  user    │ │  post    │ │ comment  │ │  like    │ │  feed    │ │  notif   │
  │  (Go)    │ │ (Python) │ │(Node.js) │ │  (Rust)  │ │  (Java)  │ │  (.NET)  │
  │  :8081   │ │  :8082   │ │  :8083   │ │  :8084   │ │  :8085   │ │  :8086   │
  └────┬─────┘ └────┬─────┘ └────┬─────┘ └──────────┘ └────┬─────┘ └──────────┘
       │            │            │                          │
       ▼            ▼            ▼                          │
  ┌─────────────────────────────────┐         ┌─────────────┘
  │         PostgreSQL              │         │  calls post, comment,
  │         :5432                   │         │  like services to
  └─────────────────────────────────┘         │  assemble feed
  ┌──────────┐  ┌──────────┐                  │
  │  Redis   │  │  Kafka   │                  │
  │  :6379   │  │  :9092   │◄─────────────────┘
  └──────────┘  └──────────┘

Services

Service Language Port Description
user-service Go 8081 User registration and profiles (CRUD)
post-service Python (FastAPI) 8082 Create and read posts
comment-service Node.js (Express) 8083 Comments on posts
like-service Rust (Axum) 8084 Like/unlike posts, like counts
feed-service Java (Spring Boot) 8085 Aggregates posts + comments + likes into a feed
notification-service .NET 8 (Minimal API) 8086 User notifications
data-generator Python - Continuously generates traffic across all services

Infrastructure

Component Image Port
PostgreSQL postgres:16-alpine 5432
Redis redis:7-alpine 6379
Kafka bitnami/kafka:3.8 9092

Quick Start

Docker Compose (local)

cd social-feed
docker compose up --build

Services will be available at http://localhost:8081 through http://localhost:8086.

Kubernetes

1. Build and push images to GHCR:

# Login to GHCR
echo $GITHUB_TOKEN | docker login ghcr.io -u <username> --password-stdin

# Build and push all 7 service images
./build-and-push.sh

# Or with a specific tag
./build-and-push.sh v1.0.0

2. Deploy (public images):

kubectl apply -f k8s/all-in-one-no-secret.yaml

3. Deploy (private images -- requires pull secret):

# Create the namespace first
kubectl create namespace social-feed

# Create GHCR pull secret
kubectl create secret docker-registry ghcr-secret \
  --namespace social-feed \
  --docker-server=ghcr.io \
  --docker-username=<github-username> \
  --docker-password=<github-pat-token>

# Deploy
kubectl apply -f k8s/all-in-one.yaml

Container Images

Image Language
ghcr.io/middleware-labs/social-feed-user-service Go
ghcr.io/middleware-labs/social-feed-post-service Python
ghcr.io/middleware-labs/social-feed-comment-service Node.js
ghcr.io/middleware-labs/social-feed-like-service Rust
ghcr.io/middleware-labs/social-feed-feed-service Java
ghcr.io/middleware-labs/social-feed-notification-service .NET
ghcr.io/middleware-labs/social-feed-data-generator Python

API Endpoints

Every service exposes a GET /health endpoint returning {"status": "ok"}.

user-service (Go, :8081)

  • GET /users -- list all users
  • POST /users -- create user {"username", "email", "bio"}
  • GET /users/{id} -- get user by ID

post-service (Python, :8082)

  • GET /posts -- list posts (optional ?user_id=)
  • POST /posts -- create post {"user_id", "content"}
  • GET /posts/{id} -- get post by ID

comment-service (Node.js, :8083)

  • GET /comments -- list comments (optional ?post_id=)
  • POST /comments -- create comment {"post_id", "user_id", "content"}
  • GET /comments/{id} -- get comment by ID

like-service (Rust, :8084)

  • POST /likes -- like a post {"post_id", "user_id"}
  • GET /likes/{post_id} -- get like count for a post

feed-service (Java, :8085)

  • GET /feed -- aggregated feed with posts, comments, and like counts (optional ?user_id=)

notification-service (.NET, :8086)

  • GET /notifications/{userId} -- get notifications for user
  • POST /notifications -- create notification {"UserId", "Type", "Message"}
  • POST /notifications/{id}/read -- mark notification as read

Data Generator

The data-generator service automatically:

  1. Waits for all services to be healthy
  2. Seeds 5 users and 5 posts on startup
  3. Continuously generates random traffic every ~5 seconds:
    • Creates users (15%), posts (30%), comments (25%), likes (20%)
    • Fetches the aggregated feed (5%)
    • Sends notifications (5%)

Configure the interval with GENERATOR_INTERVAL_SEC env var (default: 5).

Project Structure

social-feed/
├── docker-compose.yml
├── build-and-push.sh
├── README.md
├── services/
│   ├── user-service/          # Go
│   │   ├── main.go
│   │   ├── go.mod / go.sum
│   │   └── Dockerfile
│   ├── post-service/          # Python
│   │   ├── main.py
│   │   ├── requirements.txt
│   │   └── Dockerfile
│   ├── comment-service/       # Node.js
│   │   ├── server.js
│   │   ├── package.json
│   │   └── Dockerfile
│   ├── like-service/          # Rust
│   │   ├── src/main.rs
│   │   ├── Cargo.toml
│   │   └── Dockerfile
│   ├── feed-service/          # Java
│   │   ├── src/.../FeedService.java
│   │   ├── pom.xml
│   │   └── Dockerfile
│   ├── notification-service/  # .NET
│   │   ├── Program.cs
│   │   ├── notification-service.csproj
│   │   └── Dockerfile
│   └── data-generator/        # Python
│       ├── generator.py
│       ├── requirements.txt
│       └── Dockerfile
└── k8s/
    ├── all-in-one.yaml              # Everything (with imagePullSecrets)
    ├── all-in-one-no-secret.yaml    # Everything (no secrets)
    ├── namespace.yaml
    ├── configmap.yaml
    ├── ghcr-secret.yaml
    ├── infrastructure/
    │   ├── postgres.yaml
    │   ├── redis.yaml
    │   └── kafka.yaml
    └── services/
        ├── user-service.yaml
        ├── post-service.yaml
        ├── comment-service.yaml
        ├── like-service.yaml
        ├── feed-service.yaml
        ├── notification-service.yaml
        └── data-generator.yaml

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors