Nextube is a protocol-first multimedia platform foundation for cloud-native cards, streams, live rooms, and future interface layers.
The protocol layer lives in src/protocol and defines:
- a fixed protocol identity and version
- a closed set of content kinds for cards and streams, including native game cards
- immutable envelope shapes for cards, collections, and streams
- room for metadata, relations, and future delivery layers without breaking the core
The storage backbone lives in src/store and uses a local, service-free layout:
- append-only segment records for protocol envelopes and metadata
- content-addressed blob shards for large media payloads
- lightweight reference files for fast lookup without an external database
- one workspace-wide disk root so all data stays native and unified
The store module includes a native runtime infrastructure layer in src/store/runtime-infrastructure.ts with local in-process execution:
- native mode (default): in-process cache, message bus, and queue
Runtime selection:
- no external service configuration is required
Native cache and queue tuning (optional):
NEXTUBE_NATIVE_CACHE_MAX_ENTRIES(default50000)NEXTUBE_NATIVE_CACHE_DEFAULT_TTL_SECONDS(default15)NEXTUBE_NATIVE_CACHE_JANITOR_MS(default5000)NEXTUBE_NATIVE_QUEUE_MAX_SIZE(default20000)
Fallback behavior:
- native runtime starts with no network dependency and serves traffic locally
Hot-path upgrades currently wired:
- envelope/list APIs use short-lived cache entries for repeated reads
- engagement reads/writes use cache-backed fast path
- cache uses bounded LRU + TTL expiration + periodic janitor cleanup
- concurrent cache misses collapse into a single compute path (
getOrCompute) to reduce thundering-herd overhead - like/comment updates are now serialized per-card with in-process locking to reduce lost updates under concurrent writes
- store mutations publish events onto the runtime bus and enqueue records onto
store-events - auth token/user lookups and user list reads use short-lived cache acceleration
- currency overview and snapshot reads use short-lived cache acceleration
Current scope note:
- this is still a local-first single-node architecture
- native runtime improves cache and async coordination behavior but does not convert the system into a distributed transactional database with consensus semantics
The single Node.js application in src contains both:
- an admin-focused operations experience for inventory, envelopes, blobs, and references
- a client-style feed experience for scrolling, likes, and comments
The internal protocol and store modules remain the durable backbone that these interfaces build on top of.
The local store now includes first-class user and role records under .nextube-data/data/auth:
- user registration with username + password and either email or phone
- login with email, phone, or username
- profile update support for display name, avatar URL, bio, username, email, and phone
- password change flow with current password verification
- role management with system roles (
role-admin,role-moderator,role-user) - admin user management for role assignment and account status (
active/disabled)
API routes in src/app/api:
POST /api/auth/registerPOST /api/auth/loginPOST /api/auth/logoutGET /api/auth/profilePUT /api/auth/profilePOST /api/auth/passwordGET /api/admin/usersPATCH /api/admin/usersGET /api/admin/rolesPOST /api/admin/roles
Auth token usage:
- send
Authorization: Bearer <token>orx-nextube-token: <token> - token is returned by register/login and stored server-side as a hashed session token
Application scripts:
npm run devto start the application in development modenpm run buildandnpm run startto build and serve the production applicationnpm run typecheckto validate TypeScriptnpm run engineto run the currency engine, with-- --oncefor one cyclenpm run seedto rebuild sample data, with optional-- --profile=extremeor-- --users=<count>argumentsnpm run benchmark -- ...to benchmark local-store throughput
Feed profile metrics:
- profile balance label uses the configured system currency identity (symbol/name) from store identity state
Drop %is computed server-side from global activity:- per-user score:
content * (1 + 0.01 * (likes + comments)) - drop share:
(userScore / sumOfAllUserScores) * 100 - response precision is fixed to two decimal places for UI consistency
- per-user score:
Maintenance guidance:
- keep API-derived profile metrics in API routes instead of recomputing from partial client lists
- prefer typed shared response payloads when the same route is consumed in multiple client flows
- keep protocol envelope fields backward-compatible and additive for v1 stability
Operational guidance:
- use the native runtime queue and bus hooks for asynchronous background workflows
- keep local store data (
.nextube-data) on fast SSD/NVMe - monitor queue lag and cache hit ratio before increasing worker complexity