FlixTube is a distributed, cloud-native video streaming application I built from the ground up to explore microservices architecture. I designed this project as a comprehensive playground for building, deploying, and scaling modern web applications using a variety of technologies and architectural patterns.
I organized the system as several specialized microservices in an Nx monorepo:
gateway(Next.js): The central web frontend and API gateway I built to orchestrate requests to the underlying microservices and provide a unified user experience.video-upload(NestJS): Manages video file uploads and initiates the storage process.video-streaming(NestJS): Handles efficient video streaming by interfacing with the storage backend.metadata(NestJS): Manages video metadata (titles, descriptions, URLs) stored in MongoDB.history(NestJS): Tracks user viewing history through event-driven updates.azure-storage(NestJS): A wrapper service I wrote for interacting with Azure Blob Storage.mock-storage(NestJS): A local filesystem-based storage alternative I use during development.db-fixture-rest-api(NestJS): A utility service I built for seeding and managing database fixtures across the ecosystem.
rmq-broker: Standardized RabbitMQ messaging logic I wrote for event-driven communication.dynamic-db: Common MongoDB utilities and abstraction layers I extracted for reuse.mongodb-fixtures: Shared logic I built for managing test and development data.
- Synchronous: Services communicate via REST APIs (orchestrated primarily by the
gateway). - Asynchronous: Event-driven communication via RabbitMQ for decoupling (e.g.,
VIDEO_UPLOADEDandVIEWEDevents).
- Frameworks: Next.js, NestJS
- Language: TypeScript
- Monorepo Management: Nx
- Database: MongoDB (Mongoose)
- Messaging: RabbitMQ
- Storage: Azure Blob Storage
- DevOps: Docker, Kubernetes, Terraform, GitHub Actions
- Docker & Docker Compose
- Node.js (v20+)
- Nx CLI
I included a robust utility script for managing the Docker environment.
-
Load utility functions:
source dev_utility_functions.sh -
Start all services in development mode:
up dev
This will spin up all microservices, MongoDB instances, and RabbitMQ using
docker-compose-all-dev.yml. -
Shut down the environment:
down dev
I keep Kubernetes manifests in infra/k8s and deployment scripts in the scripts/ directory.
- Build images:
./scripts/build_all_images.sh <platform> <env>
- Deploy to cluster:
./scripts/deploy.sh <deployment_env>
To run the services successfully, the following environment variables need to be configured. I've included example values in the *.env files in the root directory.
PORT: The port number for the HTTP server (required for all microservices).RABBIT: The connection string for RabbitMQ (e.g.,amqp://guest:guest@localhost:5672).NODE_ENV: The environment mode (developmentorproduction).
NEXT_PUBLIC_HISTORY_HOST: URL of the history microservice.NEXT_PUBLIC_METADATA_HOST: URL of the metadata microservice.NEXT_PUBLIC_VIDEO_STREAMING_HOST: URL of the video-streaming microservice.NEXT_PUBLIC_VIDEO_UPLOAD_HOST: URL of the video-upload microservice.
DBHOST: MongoDB connection string.DBNAME: Name of the streaming database.VIDEO_STORAGE_HOST: Hostname and port of the video storage service (Azure or Mock).
VIDEO_STORAGE_HOST: Hostname and port of the video storage service.
METADATA_DBHOST: MongoDB connection string.METADATA_DBNAME: Name of the metadata database.
HISTORY_DBHOST: MongoDB connection string.HISTORY_DBNAME: Name of the history database.
STORAGE_ACCOUNT_NAME: Your Azure Storage account name.STORAGE_ACCESS_KEY: Your Azure Storage access key.STORAGE_CONTAINER_NAME: The name of the blob container (defaults tovideos).
ABSOLUTE_PROJECT_PATH: The absolute path to the project root on your local machine (used for mapping file paths).
DB_FIXTURES_HOST: MongoDB connection string.FIXTURES_DIR: Directory where database fixtures are stored.
Here is FlixTube running locally, demonstrating the core features I built β from video listing to playback and history tracking.
I'm continuously evolving this project. Key areas I plan to tackle next:
- Observability: Implement ELK stack, Prometheus, Grafana, and OpenTelemetry.
- Auth: Add Authentication & Authorization (RBAC).
- SQL Integration: Introduce Postgres with Drizzle ORM.
- Security: Static Analysis Security Testing (SAST) with Sonarqube.
- Scaling: Implement elastic scaling for microservices and K8s clusters.
- Messaging: Evaluate replacing RabbitMQ with Kafka.
- Mobile: Develop a mobile gateway and GraphQL support.
- Performance: Integrate Redis for caching.
I built this project to gain hands-on experience with:
- Designing microservice boundaries.
- Implementing event-driven architectures.
- Managing a monorepo with Nx.
- Orchestrating deployments with Kubernetes and Terraform.
- Handling cloud-native storage and streaming.
Inspired by the book Bootstrapping Microservices by Ashley Davis, I built this to demonstrate a wholistic view of a microservices ecosystem β from frontend development to event-driven communication and cloud-native orchestration.
This project is licensed under the MIT License - see the LICENSE file for details.
β James Njuguna
.png)
.png)
.png)
.png)
.png)