Skip to content

jaugustodev/flixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

161 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flixer Catalog API

.NET 6 MySQL RabbitMQ Docker

A REST API for video catalog management built with Clean Architecture and Domain-Driven Design (DDD). The project implements a complete catalog system with videos, categories, genres, and cast members, including media upload and video processing.

🎯 Overview

Flixer Catalog API is a video catalog management system that allows:

  • Video Management: Create, update, list, and delete videos with detailed information
  • Category Organization: Categorize videos for better organization
  • Genre Classification: Classify content using multiple genres
  • Cast Management: Register and associate directors and actors with videos
  • Media Upload: Upload videos, trailers, thumbnails, and banners
  • Video Processing: Asynchronous encoding system using messaging
  • Authentication and Authorization: Role-based access control using Keycloak

πŸ— Architecture

The project follows Clean Architecture and Domain-Driven Design (DDD) principles, organizing code into well-defined layers:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Flixer.Catalog.Api             β”‚  ← Controllers, Middlewares
β”‚      (Presentation Layer)                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Flixer.Catalog.Application          β”‚  ← Use Cases, DTOs, Queries
β”‚      (Application Layer)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Flixer.Catalog.Domain              β”‚  ← Entities, Value Objects
β”‚      (Domain Layer)                      β”‚     Business Rules
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Flixer.Catalog.Infra.*                β”‚  ← Repositories, Persistence
β”‚      (Infrastructure Layer)              β”‚     Storage, Messaging
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Layers

  • API: Controllers, configurations, filters, and middlewares
  • Application: Use cases (Commands/Queries), validations, service interfaces
  • Domain: Entities, aggregates, value objects, domain events, and business rules
  • Infrastructure: Repository implementations, data access (Entity Framework), storage (Google Cloud Storage), and messaging (RabbitMQ)

✨ Features

Video Management

  • Create video with metadata (title, description, year, duration, rating)
  • Update video information
  • Upload media files (video, trailer)
  • Upload images (thumbnail, thumbnail half, banner)
  • List videos with pagination and filters
  • Get video by ID
  • Delete video
  • Update video encoding status

Category Management

  • Create categories
  • Update categories
  • Activate/Deactivate categories
  • List categories with pagination and search
  • Get category by ID
  • Delete category

Genre Management

  • Create genres
  • Update genres
  • Associate categories with genres
  • Activate/Deactivate genres
  • List genres with pagination and search
  • Get genre by ID
  • Delete genre

Cast Member Management

  • Create cast members (actor/director)
  • Update cast members
  • List members with pagination and search
  • Get member by ID
  • Delete cast member

Advanced Features

  • JWT Authentication via Keycloak
  • Role-based authorization (admin, catalog-admin)
  • File Upload to Google Cloud Storage
  • Asynchronous processing of videos via RabbitMQ
  • Health Checks for MySQL, RabbitMQ, and Entity Framework
  • Structured logging with Serilog
  • OpenAPI/Swagger documentation

πŸ›  Technologies

Framework and Language

  • .NET 6: Main framework
  • C#: Programming language

Persistence

  • Entity Framework Core 6: ORM for data access
  • Pomelo.EntityFrameworkCore.MySql: MySQL provider for EF Core
  • MySQL 8: Relational database

Authentication and Authorization

  • Keycloak 20.0.3: Identity and access management system
  • Keycloak.AuthServices: Keycloak integration with .NET
  • IdentityModel.AspNetCore: OAuth2/OpenID Connect support

Messaging

  • RabbitMQ 3: Message broker for asynchronous communication
  • RabbitMQ.Client: .NET client for RabbitMQ

Storage

  • Google Cloud Storage: Video and image storage

Patterns and Libraries

  • MediatR: CQRS and mediator pattern implementation
  • FluentValidation: Entity and DTO validation
  • Serilog: Structured logging

Testing

  • xUnit: Testing framework
  • Fluent Assertions: Fluent assertions for tests
  • Moq: Mocking framework
  • Bogus: Fake data generation for tests

DevOps

  • Docker: Containerization
  • Docker Compose: Container orchestration
  • GitHub Actions: CI/CD pipeline

Observability

  • AspNetCore.HealthChecks: Health checks for MySQL, RabbitMQ, and EF Core
  • Serilog.AspNetCore: HTTP request logging

πŸ“¦ Prerequisites

  • Docker and Docker Compose installed
  • .NET 6 SDK (for local development)
  • IDE/Editor: Visual Studio, Visual Studio Code, or JetBrains Rider

πŸš€ Installation and Execution

Using Docker Compose (Recommended)

  1. Clone the repository

    git clone https://github.com/jaugustodev/flixer.git
    cd flixer
  2. Verify Docker is installed

    docker --version
  3. Start the containers

    docker compose -f docker-compose.yml up -d
  4. Check container status

    docker compose ps
  5. Access the application

  6. To stop and remove containers

    docker compose -f docker-compose.yml down

Running Locally (Development)

  1. Start only dependencies (MySQL, RabbitMQ, Keycloak)

    docker compose up flixer_db rabbitmq keycloak -d
  2. Restore dependencies

    dotnet restore
  3. Run database migrations

    dotnet ef database update --project src/Flixer.Catalog.Infra.Data.EF
  4. Run the application

    dotnet run --project src/Flixer.Catalog.Api

πŸ§ͺ Running Tests

The project includes a complete test suite:

Unit Tests

dotnet test tests/Flixer.Catalog.UnitTest

Integration Tests

  1. Start test containers

    docker compose -f docker-compose-integration.yml up -d
  2. Run tests

    dotnet test tests/Flixer.Catalog.IntegrationTests
  3. Stop test containers

    docker compose -f docker-compose-integration.yml down

End-to-End Tests

dotnet test tests/Flixer.Catalog.EndToEndTests

Run all tests

dotnet test

πŸ“ Project Structure

flixer/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Flixer.Catalog.Api/              # Presentation layer (Controllers, Middlewares)
β”‚   β”œβ”€β”€ Flixer.Catalog.Application/       # Use cases and application logic
β”‚   β”œβ”€β”€ Flixer.Catalog.Domain/            # Entities, Value Objects, business rules
β”‚   β”œβ”€β”€ Flixer.Catalog.Infra.Data.EF/     # Repositories and data access (EF Core)
β”‚   β”œβ”€β”€ Flixer.Catalog.Infra.Storage/     # Google Cloud Storage integration
β”‚   └── Flixer.Catalog.Infra.Messaging/   # RabbitMQ integration
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ Flixer.Catalog.UnitTest/          # Unit tests
β”‚   β”œβ”€β”€ Flixer.Catalog.IntegrationTests/  # Integration tests
β”‚   β”œβ”€β”€ Flixer.Catalog.EndToEndTests/     # End-to-end tests
β”‚   └── Flixer.Catalog.Tests.Shared/      # Shared code between tests
β”œβ”€β”€ docker-compose.yml                     # Docker configuration for production
β”œβ”€β”€ docker-compose-integration.yml         # Docker configuration for tests
└── Flixer.Catalog.sln                    # Project solution

Domain - Main Entities

  • Video: Main aggregate representing a video with all its metadata
  • Category: Categories for video organization
  • Genre: Genres that can be associated with videos
  • CastMember: Cast members (actors/directors)
  • Media: Value object representing media files (video/trailer)
  • Image: Value object representing images (thumb/banner)

πŸ”Œ API Endpoints

Videos

  • POST /api/videos - Create new video
  • GET /api/videos - List videos (with pagination)
  • GET /api/videos/{id} - Get video by ID
  • PUT /api/videos/{id} - Update video
  • DELETE /api/videos/{id} - Delete video
  • POST /api/videos/{id}/upload-media - Upload media

Categories

  • POST /api/categories - Create category
  • GET /api/categories - List categories (with pagination)
  • GET /api/categories/{id} - Get category by ID
  • PUT /api/categories/{id} - Update category
  • DELETE /api/categories/{id} - Delete category

Genres

  • POST /api/genres - Create genre
  • GET /api/genres - List genres (with pagination)
  • GET /api/genres/{id} - Get genre by ID
  • PUT /api/genres/{id} - Update genre
  • DELETE /api/genres/{id} - Delete genre

Cast Members

  • POST /api/cast-members - Create cast member
  • GET /api/cast-members - List members (with pagination)
  • GET /api/cast-members/{id} - Get member by ID
  • PUT /api/cast-members/{id} - Update member
  • DELETE /api/cast-members/{id} - Delete member

Health Checks

  • GET /health - Check application and dependencies health

πŸ”„ Continuous Integration

The project uses GitHub Actions for automated CI/CD.

CI Workflow

Triggered on:

  • Push to main branch
  • Pull requests to main branch

Pipeline Steps

  1. Repository Checkout: Clone source code
  2. .NET Core Setup: Prepare environment with .NET 6.x
  3. Start Containers: Bring up test containers via docker-compose-integration.yml
  4. Restore Dependencies: Execute dotnet restore
  5. Build Project: Compile the code
  6. Run Tests: Execute entire test suite and generate reports
  7. DockerHub Login: Authenticate to DockerHub
  8. Build and Push Docker Image: Build and push image to DockerHub

Resources

πŸ›  Development Tools

Recommended IDEs and Editors

Name Type Download
Visual Studio Code Editor Download
Visual Studio Community IDE Download
JetBrains Rider IDE Download

Useful Extensions

Visual Studio Code

  • C# Dev Kit: Complete support for C# and .NET
  • Docker: Container management
  • SonarLint: Real-time bug and code smell detection
  • GitLens: Advanced Git features
  • REST Client: Test APIs directly from VS Code

All IDEs

  • SonarLint: Flags potential bugs and code smells - More info

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Standards

  • Follow SOLID principles
  • Write tests for new features
  • Maintain high test coverage
  • Use descriptive names for variables and methods
  • Document complex code

πŸ“š Additional Documentation

About

REST API for video catalog management built with Clean Architecture and DDD in .NET 6, featuring JWT authentication, Google Cloud Storage media upload, and asynchronous processing with RabbitMQ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors