A production-ready Twitter clone demonstrating modern cloud-native architecture with Go microservices, HTTP/3 support, and operator-managed infrastructure on Kubernetes.
- 7 Microservices - User, Tweet, Timeline, Search, Media, Notification, and Fanout services
- HTTP/3 (QUIC) - Ultra-fast communication with quic-go
- Smart Algorithms - Intelligent fanout strategy based on follower count
- Enterprise Security - Zero-trust networking, seccomp profiles, pod security
- Cloud-Native - Kubernetes operators for PostgreSQL, Redis, Elasticsearch, RabbitMQ, MinIO
- Production Ready - Auto-scaling, health checks, graceful shutdown, monitoring
graph TB
subgraph "API Gateway Layer"
GW[Envoy Gateway<br/>HTTP/3 + HTTP/2]
end
subgraph "Microservices Layer"
US[User Service<br/>Go + HTTP/3]
TS[Tweet Service<br/>Go + HTTP/3]
TL[Timeline Service<br/>Go + HTTP/3]
SS[Search Service<br/>Go + HTTP/3]
MS[Media Service<br/>Go + HTTP/3]
NS[Notification Service<br/>Go + HTTP/3]
end
subgraph "Worker Layer"
FW[Fanout Worker<br/>RabbitMQ Consumer]
end
subgraph "Data Layer"
PG[(PostgreSQL<br/>3 Databases)]
RD[(Redis Sentinel<br/>Caching + Timelines)]
ES[(Elasticsearch<br/>Search + Trending)]
RQ[RabbitMQ<br/>Job Queue]
MN[(MinIO<br/>Object Storage)]
end
GW --> US & TS & TL & SS & MS & NS
US & TS & NS --> PG
TL --> RD
SS --> ES
TS & US --> RQ
FW --> RQ & RD
MS --> MN
# 1. Clone repository
git clone https://github.com/yourusername/app-in-k8s.git
cd app-in-k8s/twitter-clone
# 2. Create local Kubernetes cluster
k3d cluster create twitter --agents 3
# 3. Install operators
./helm/twitter-stack/scripts/install-operators.sh
# 4. Deploy application
helm install twitter ./helm/twitter-stack -n twitter --create-namespace
# 5. Access the API
kubectl port-forward -n twitter svc/envoy-gateway 8080:80- π€ User Management - Profiles, avatars, follow/unfollow
- π Tweets - Create, delete, threading, 280-char limit
- β€οΈ Engagement - Likes, retweets, replies
- π± Timelines - Home feed, user profiles, pagination
- π Search - Full-text search, trending hashtags
- πΌοΈ Media - Image/video uploads (10MB limit)
- π Notifications - Real-time activity notifications
- Smart Fanout Algorithm
- < 10K followers: Push to all
- 10K-1M followers: Push to active users
-
1M followers: Pull-based model
- HTTP/3 Support - All services use QUIC protocol
- Microservices Architecture - Domain-driven design
- Event-Driven - Async processing with RabbitMQ
- CQRS Pattern - Separate read/write paths
- Multi-layer Caching - Redis for hot data
- Network Policies - Zero-trust service mesh
- Pod Security - Non-root containers, read-only filesystem
- Seccomp Profiles - Syscall filtering
- Service Accounts - Minimal permissions
- Rate Limiting - API throttling
- CORS Protection - Cross-origin security
- Handles 100K+ concurrent users
- < 50ms p99 latency for timeline queries
- Auto-scaling based on CPU/memory
- Efficient batch operations
- Connection pooling
- Smart caching strategies
# Run unit tests
make test
# Run integration tests
make test-integration
# Run security audit
./helm/twitter-stack/scripts/run-security-audit.sh
# Load testing
k6 run scripts/load-test.js- Health Checks - Liveness and readiness probes
- Structured Logging - JSON formatted logs
- Metrics - Prometheus-compatible endpoints
- Tracing Ready - OpenTelemetry support
- Graceful Degradation - Circuit breakers
| Component | Technology | Purpose |
|---|---|---|
| Language | Go 1.22 | All microservices |
| Protocol | HTTP/3 (QUIC) | Service communication |
| Container | Docker | Containerization |
| Orchestration | Kubernetes | Container orchestration |
| Package Manager | Helm 3 | Kubernetes deployments |
| API Gateway | Envoy Gateway | Traffic management |
| Databases | PostgreSQL (CloudNativePG) | Transactional data |
| Cache | Redis Sentinel | Timelines, caching |
| Search | Elasticsearch | Full-text search |
| Queue | RabbitMQ | Async jobs |
| Storage | MinIO | Object storage |
twitter-clone/
βββ services/ # Microservices
β βββ user-service/ # User management
β βββ tweet-service/ # Tweet operations
β βββ timeline-service/ # Feed generation
β βββ search-service/ # Search & trending
β βββ media-service/ # Media handling
β βββ notification-service/ # Notifications
β βββ fanout-service/ # Timeline distribution
βββ pkg/ # Shared packages
β βββ models/ # Data models
β βββ middleware/ # HTTP middleware
β βββ clients/ # Service clients
β βββ ... # Database, cache, queue clients
βββ helm/ # Kubernetes deployment
βββ twitter-stack/ # Helm chart
βββ templates/ # K8s manifests
βββ scripts/ # Operational scripts
βββ tests/ # Helm tests
- User management
- Tweet operations
- Timeline generation
- Search functionality
- JWT Authentication
- Direct Messages
- WebSocket support
- Bookmarks
- Lists
- Video streaming
- Spaces (audio rooms)
- Advanced analytics
- AI recommendations
- Admin dashboard
We welcome contributions! Please see CONTRIBUTING.md for details.
- Fork the project
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
MIT License - see LICENSE for details
- Built with Go and modern cloud-native technologies
- Inspired by Twitter's original architecture
- Uses best practices from CNCF projects
Note: This is an educational project demonstrating microservices architecture, Kubernetes deployment, and modern DevOps practices. Not affiliated with Twitter/X.