Box System Architecture (Audit-Only, Immediate Publish)
1. Overview
The Box System is a high-performance video content and advertisement platform built using a NestJS monorepo. It consists of:
- Management API (box-mgnt-api)
- Application API (box-app-api)
- Stats API (future: box-stats-api)
- Shared libraries: common, core, db
- Datastores: MySQL, MongoDB, Redis
This updated architecture removes Maker–Checker, uses audit-only trails, and adopts immediate publish behavior.
2. RBAC Roles
- SuperAdmin: Full system access, including managing users and roles.
- Manager: Manage content (ads, videos, channels), system params.
- Admin: Similar to Manager with limited permissions.
- Viewer: Read-only access.
Only SuperAdmin can:
- Create users
- Assign roles
- Change roles
- Disable accounts
3. Audit Trail Model
Kept fields:
- createdBy
- createdAt
- updatedBy
- updatedAt
- lastUpdated
These appear in MySQL and MongoDB content models.
4. Data Flow
Mgnt API
User updates → validation → save to DB → update Redis cache → immediate publish.
App API
Requests go to Redis first:
- Ads served from prebuilt pools
- Videos served partly cached
- Fallback to Mongo where applicable (future extension)
Stats API (Upcoming)
Handles:
- Event ingestion
- Redis queue/stream
- Workers writing aggregated stats
5. Modules
Mgnt Modules
- Ads
- Ads Module
- Videos
- Categories
- Channels
- Tags
- System Params
- Upload / File service
App Modules
- Ads placement
- Video listing
- Homepage aggregation
- System params
- Categories