How nightfruit/reflux works
Project Type & Purpose
• This is a backend service built with NestJS (as indicated by files like app.module.ts, nest-cli.json, etc.) that functions as a Stremio addon. The service provides endpoints (catalog, manifest, meta, stream) that interface with the Rede Canais website.
• The purpose is to expose content (movies, shows, etc.) via a well-defined API for Stremio, making the integration seamless.
Analyzing the File Structure
• Top-Level Files: Configuration files (.editorconfig, .env.example, .gitignore, etc.) and NestJS-specific configuration (nest-cli.json, tsconfig.json).
• Public Directory: Contains static assets (e.g. banner image) often used for branding or for hosting non-dynamic assets.
• Scripts Directory: Contains auxiliary scripts (proxy.js, workers.js) possibly for handling proxying and background jobs.
• src Directory: The core of the application, comprising several important subdirectories:
• config: Handles environment configurations and service logic (env.module.ts, env.service.ts, env.ts).
• exceptions: Contains custom exception handling (too-many-requests.exception.ts).
• modules: Contains the “cdn” module responsible for handling data from the content delivery network aspects—the services here (indexing, listing, media, source) suggest integration with external content sources.
• routes: Contains individual directories for API routes/controllers for catalog, manifest, meta, and stream. Each route has its own controller, module, and service for maintaining separation of concerns.
• utils: Provides utility helpers (for encryption, hashing, proxies, string manipulation) that support broader functionality across the application.
a. Main Components:
• API Controllers (Catalog, Manifest, Meta, Stream): These represent the entry points for the addon, handling incoming requests from Stremio.
• Service Layer: Each route has a corresponding service (e.g. catalog.service.ts) that encapsulates the business logic.
• Core Modules: The ‘cdn’ module and its services represent the integration with external content sources (Rede Canais).
• Configuration Module: Centralizes environment and runtime configurations.
• Exception Handling: The custom exception module ensures that special cases (like too many requests) are managed gracefully.
• Utility Functions: Shared logic that supports various parts of the app (e.g., encryption or proxy handling).
b. Relationships & Interactions:
• The Stremio client interacts with the addon endpoints (manifest, catalog, etc.) – incoming HTTP requests hit the corresponding controllers.
• Each controller invokes its associated service which might further delegate tasks to utility functions or CDN services.
• The CDN module (and its array of services) interact with external sources, pulling in content data.
• The configuration service is injected into modules that need access to environment variables, affecting how external APIs are accessed.
• Exception handling is layered across controllers and services to catch issues, such as rate limiting.
c. Architectural Patterns & Design Principles:
• Modular Design: Separation of configuration, exception handling, API routes, and CDN services follows NestJS best practices.
• Layered Architecture: Controllers, services, and utility modules ensure a clear separation between presentation, business logic, and supporting functionalities.
• Dependency Injection: Seen in the core NestJS style, making testing easier and improving maintainability.
• Clear API Gateway/Integration Patterns: Since this is a Stremio addon, treat the endpoints as a gateway into the business logic that fetches and formats data from Rede Canais.
Final Summary
• Lay out the API Routes (catalog, manifest, meta, stream) centrally.
• Routes to underlying services that may call upon the CDN module and utility functions.
• To annotate and label every component and dependency clearly, so the overall data flow and interactions are fully understood.