Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

327 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FlixTube

MIT License GitHub stars TypeScript Next JS NestJS Nx Docker Kubernetes Terraform MongoDB RabbitMQ Azure

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.

πŸš€ Architecture Overview

I organized the system as several specialized microservices in an Nx monorepo:

Core Services

  • 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.

Shared Libraries

  • 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.

Communication Flow

  1. Synchronous: Services communicate via REST APIs (orchestrated primarily by the gateway).
  2. Asynchronous: Event-driven communication via RabbitMQ for decoupling (e.g., VIDEO_UPLOADED and VIEWED events).

πŸ›  Tech Stack


πŸƒ Getting Started

Prerequisites

Development with Docker

I included a robust utility script for managing the Docker environment.

  1. Load utility functions:

    source dev_utility_functions.sh
  2. Start all services in development mode:

    up dev

    This will spin up all microservices, MongoDB instances, and RabbitMQ using docker-compose-all-dev.yml.

  3. Shut down the environment:

    down dev

Deployment with Kubernetes

I keep Kubernetes manifests in infra/k8s and deployment scripts in the scripts/ directory.

  1. Build images:
    ./scripts/build_all_images.sh <platform> <env>
  2. Deploy to cluster:
    ./scripts/deploy.sh <deployment_env>

πŸ”‘ Environment Variables

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.

Common Variables

  • 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 (development or production).

gateway (Frontend)

  • 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.

video-streaming

  • 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-upload

  • VIDEO_STORAGE_HOST: Hostname and port of the video storage service.

metadata

  • METADATA_DBHOST: MongoDB connection string.
  • METADATA_DBNAME: Name of the metadata database.

history

  • HISTORY_DBHOST: MongoDB connection string.
  • HISTORY_DBNAME: Name of the history database.

azure-storage

  • 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 to videos).

mock-storage

  • ABSOLUTE_PROJECT_PATH: The absolute path to the project root on your local machine (used for mapping file paths).

db-fixture-rest-api

  • DB_FIXTURES_HOST: MongoDB connection string.
  • FIXTURES_DIR: Directory where database fixtures are stored.

πŸ“Έ Screenshots

Here is FlixTube running locally, demonstrating the core features I built β€” from video listing to playback and history tracking.

1. Video Upload

Video Upload

2. Video Selection

Video Selection

3. Video List

Video List

4. Video Playback

Video Playback

5. Video History

Video History


πŸ—Ί Roadmap

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.

πŸ“– Learning Journey

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.

πŸ‘ Acknowledgements

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.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

β€” James Njuguna

About

A cloud-native video streaming application built from the ground up to explore microservices architecture.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages