How dev-sire/nodestream works
Main Components
• Frontend/UI Layer: Represented by the Next.js app. Key directories include:
– src/app: Contains the route-level files and layouts for different sections ((auth), (home), (studio)).
– src/components and src/modules/*/ui: These hold reusable UI components and feature-specific components.
– Public assets and global styles (public, src/app/globals.css).
• API/Backend Layer:
– src/app/api: Contains RESTful API endpoints (uploadthing, trpc, users, videos webhooks).
– src/trpc: Manages tRPC configuration and routers for server-side procedures and queries.
• Business Logic/Modules:
– src/modules: Divided by domain areas (auth, categories, home, studio, videos), each containing its own server-side (procedures) and UI parts.
• Data & External Integrations:
– Database: src/db (schema definitions and initialization) plus drizzle.config.ts, which indicate a connection configuration.
– External Services: Integration components in src/lib (e.g., mux.ts for video streaming, ratelimit.ts for rate limiting, redis.ts for caching/session management, and uploadthing.ts for file uploads).
Relationships and Data Flows
• The client (browser) interacts with Next.js page routes defined in src/app (e.g., authentication pages, home view, studio).
• These pages load reusable UI components from src/components and feature-specific modules.
• When dynamic data or state changes are necessary, the components invoke APIs:
– tRPC endpoints (via src/app/api/trpc and src/trpc/routers) handle business logic on the server.
– Other API endpoints (uploadthing, webhook routes) interact with external systems.
• The backend communicates with the database (src/db) and leverages utilities in src/lib for integrations with external systems like Mux and Redis.
• The modular directory structure (src/modules) shows a clean separation of concerns, with each domain having both a UI and server logic layer, which simplifies scaling and maintenance.
Important Architectural Patterns
• Next.js App Structure: Emphasizes file-based routing and layout composition.
• Modular Architecture: Domain-specific modules (auth, home, studio, videos) separating concerns across UI, server procedures, and integrations.
• API Layer with tRPC: Provides typesafe communication between client and server.
• Integration with External Services: Use of dedicated libraries (for uploads, rate limiting, video streaming) isolates external dependencies.
Technologies, Frameworks, and Libraries
• Next.js: For both rendering pages and handling API routes.
• tRPC: For typesafe API calls and server procedures.
• Tailwind CSS: Configured through tailwind.config.ts for UI styling.
• Uploadthing: For file uploads within the API.
• Additional libraries/utilities in src/lib (mux, redis, etc.) that interact with external systems.