josephnhtam / vsp-youtube-clone-microservices

A YouTube Clone microservices application built with .NET 7 and Angular 14.
Apache License 2.0
37 stars 6 forks source link
angular asp-net-core docker dotnet elasticsearch elk-stack eventbus ffmpeg jaeger micorservices mongodb opentelemetry postgres rabbitmq redis signalr spa transactional transactional-outbox-pattern youtube

Video Sharing Platform - YouTube Clone

This repository contains a YouTube Clone microservices application built with .NET 7 and Angular 14.

Screenshot

Table of Contents

Microservices Application (.NET)
SPA Application (Angular)
Screenshots
Demo Video
Running with Docker
Kubernetes

Architecture

Architecture

Overview of Technologies Used

Features

Microservices Application (.NET)

The microservices architecture of the application is based on ASP.NET Core 7, providing a scalable and flexible solution. Each microservice is designed to be horizontally scalable, allowing for granular resource allocation and efficient use of computing resources.

Building Blocks

Video Manager Service

The Video Manager Service plays a crucial role in the video sharing platform, managing the videos and their metadata.

Video Manager SignalR Hub Service

The Video Manager SignalR Hub Service enhances the Video Manager Service by delivering real-time notifications to users regarding the processing status of the videos.

Video Processor Service

The Video Processor Service is responsible for processing the video files. This service utilizes the power of FFmpeg for video processing and generates different resolutions and thumbnails of the uploaded video. For this service to run correctly, FFmpeg must be installed in advance, which will be done by the Dockerfile automatically.

Video Store Service

The Video Store Service is responsible for storing and serving the video metadata to the users. This service controls the publication of videos and ensures that the video metadata is replicated with other microservices, such as the Library Service.

Storage Service

The Storage Service is responsible for storing and serving the video and image files. Both the users and other services can upload files to the Storage Service. This service integrates with Entity Framework Core to store the metadata of the uploaded files.

Identity Provider Service

The Identity Provider Service is a microservice that is responsible for user authentication and authorization. This service integrates with Duende Identity Server, which is a comprehensive solution for identity management and security.

Users Service

The Users Service is responsible for managing and storing the user profiles and channel data.

Subscriptions Service

The Subscriptions Service is responsible for managing user subscriptions and storing user notifications.

Library Service

The Library Service is responsible for managing playlists and serving both the playlists and basic video metadata to users, as well as enabling video voting functionality.

Community Service

The Community Service is responsible for providing a platform for users to engage in discussions.

History Service

The History Service is responsible for managing and storing the user watch history, as well as counting the number of views for each video. The watch history records are efficiently stored in an Elasticsearch database, enabling search functionality and the ability to analyze users' favorite video tags.

Search Service

The Search Service is integrated with Elasticsearch to deliver full-text search capabilities for videos. With its integration, users can find trending and relevant tags, search videos based on tags, creators, and full-text queries.

API Gateway Service

The API Gateway Service,integrated with YARP, provides a centralized entry point for all client requests and distributing them to the appropriate backend services, except for the Storage and Identity Provider Services. Additionally, it enables rate limiting functionality to protect the underlying backend services from excessive traffic.

Web Status Service

The Web Status Service provides a web user interface for health checks. For automatic Kubernetes services discovery, please refer to Health Checks UI automatic Kubernetes services discovery.

Distributed Logging

The logs are sent to the ELK Stack (Elasticsearch, Logstash, and Kibana) by Serilog for storage, processing, and analysis. All the log data is collected and stored in a centralized Elasticsearch database, making it easy to search and analyze log data across all components of the system.

Distributed Tracing

OpenTelemetry is used to instrument the microservices, generate tracing data, and export it to Jaeger to gain visibility into the performance and behavior of the application.

Dependencies

Requirements

Pending Improvement

SPA Application (Angular)

The SPA (Single Page Application) is built using Angular, Angular Material, Ngrx, and Videogular. These technologies enable the creation of responsive user interfaces, providing a smooth user experience.

Dependencies

Screenshots

Screenshot Screenshot Screenshot

MORE SCREENSHOTS

Demo Video

YouTube Clone Application Demo

YouTube Clone Application Demo Video

Running with Docker

To run the application and its necessary infrastructure, make sure that you have Docker and Docker Compose installed on your machine.

Navigate to the Scripts directory and use the following commands:

Windows
backend_build.bat
backend_up.bat

front_build.bat
front_up.bat
Linux
./backend_build.sh
./backend_up.sh

./front_build.sh
./front_up.sh

The scripts will launch 26 containers, including the web client, microservices and infrastructure.

After the application is completely launched, you should able to browse the different components by visiting

Web SPA : http://localhost:4200/
Web Status : http://localhost:16050/
Kibana : http://localhost:5601/
Jaeger UI : http://localhost:16686/
This application use the following ports:

    PostgreSQL: 5432
    Adminer: 8080
    PgAdmin: 8081
    RabbitMQ: 5672
    RabbitMQ Management: 15672
    MongoDB: 27017
    MongoExpress: 8082
    Elasticsearch: 9200
    Logstash: 9600, 9250
    Kibana: 5601
    Redis: 6379
    RedisCommander: 8083
    Jaeger: 5565/udp, 6831/udp, 6832/udp, 5778, 14268, 14250, 9411
    Jaeger UI: 16686

    Storage: 14200
    VideoManager: 15000
    VideoManagerSignalRHub: 15050
    IdentityProvider: 15100
    VideoProcessor: 15200
    VideoStore: 15300
    Users: 15400
    Community: 15500
    Library: 15600
    Search: 15700
    Subscriptions: 15800
    History: 15900
    APIGateway: 16000
    WebStatus: 16050

    WebClient: 4200

Kubernetes

This repository includes sample kubernetes manifests for deploying the application to Minikube and Azure Kubernetes Service (AKS).

Deploying to Minikube

To deploy the application to Minikube, you will need to have Docker, Kubectl, and Minikube installed on your machine. Here are the steps to get started:

  1. Start the Minikube by running the following command:
minikube start
  1. Build the required Docker images by navigating to the Deploy/scripts directory and running the following command:
build_images.bat
  1. Navigate to the Deploy/scripts/minikube directory and run the following commands using PowerShell:
./0_enable_metrics_server.ps1
./1_minikube_load_images.ps1
./2_install_prometheus.ps1
./3_bake.ps1
./4_apply.ps1
./5_minikube_tunnel.ps1

These commands enable the metrics server, load Docker images into Minikube, install Prometheus, bake the Kubernetes manifests with Kustomize, deploy the application, and start a tunnel to the Minikube cluster.

Once the application is fully launched, the services will be exposed by the following ports

    Storage: 14200
    IdentityProvider: 15100
    APIGateway: 16000

Deploying to Azure Kubernetes Service

To deploy the application to Azure Kubernetes Service, you'll need to have the following set up:

The DNS zone and domain name are required for domain-name-based routing. The Kubernetes cluster is also integrated with ingress-nginx, external-dns and cert-manager which automatically manage the DNS records and TLS certificates for the services.

This repository contains

Terraform manifests for deploying infrastructure ( Deploy/terraform/aks )
Terraform manifests for deploying the Azure DevOps project ( Deploy/terraform/ado )
Terraform manifests for deploying the Azure DevOps service connections ( Deploy/terraform/ado-svc-conn )
Azure pipelines YAML files ( AzurePipelines )
Kubernetes manifests for deploying the application to the AKS cluster ( Deploy/kubernetes )