How re3-1/yotubeblockchain works
1. Overall shape
- This is a monorepo for a tokenized creator marketplace split into four runtime boundaries: Solidity contracts, an Express backend, a React DApp frontend, and a Python forecast service.
- The main business loop is: creator verification on the backend → channel token and marketplace activity on-chain → trade/analytics data mirrored off-chain → UI renders dashboards and charts → milestone jobs and forecasts enrich the experience.
2. On-chain core: contracts/
- The blockchain layer is the source of truth for tokenized assets and marketplace actions.
- Key contract responsibilities are indicated by the tests and README: ChannelToken, Marketplace, MilestoneChallenge, and likely a badge NFT for milestone rewards.
- Deployment artifacts for localhost, Sepolia, and Hardhat show the contracts are intended to run across local dev and Polygon-oriented testnet/mainnet workflows.
- Scripts for deploy, direct deploy, verification, and seeding imply the contracts are also used in operational setup and demo initialization.
3. Backend API and orchestration: backend/
- The backend is an Express API that sits between the frontend and external services, and also between the UI and blockchain where off-chain state is needed.
- It uses MongoDB models for User, Trade, and Milestone, so it persists user accounts, marketplace events, and milestone state outside the chain.
- This layer is where authentication, creator/channel verification, pricing, IPFS handling, and analytics aggregation are coordinated.
4. Authentication and identity
- backend/src/services/passport.js and middleware/auth.js indicate the backend manages Google OAuth-based login and protects private endpoints.
- routes/auth.js is the entry point for login/session-related behavior.
- The repo’s architecture suggests the backend owns the trusted identity layer, while the frontend only consumes authenticated API responses and wallet state.
5. YouTube and platform verification
- backend/src/services/youtube.js plus routes/channels.js and routes/platforms.js show the backend verifies creator channels and fetches channel metadata from the YouTube Data API.
- The services/platforms/ directory contains a platform abstraction with a base adapter and concrete YouTube and Twitch adapters, so platform-specific logic is isolated behind a common interface.
- This is a key extensibility boundary: creator identity and channel metadata can come from multiple platforms, but the rest of the system consumes normalized channel data.
6. Trading, chain access, and pricing
- services/chain.js is the backend’s chain integration boundary, likely responsible for reading/writing to contracts and reconciling on-chain state.
- services/pricing.js and the dedicated __tests__/pricing.test.js indicate pricing is not hardcoded in the UI; it is a backend concern with test coverage.
- routes/trades.js, routes/analytics.js, and routes/forecast.js suggest the backend exposes market data, trade history, and computed insights to the frontend.
7. Milestones and background jobs
- routes/milestones.js exposes milestone-related endpoints, while jobs/milestoneResolver.js is a background worker/process that likely evaluates milestone completion.
- The milestone subsystem bridges off-chain activity with on-chain rewards: it can award bonus tokens or badge NFTs when creator/fan goals are met.
- This is an important asynchronous boundary in the architecture: milestone state is not just request/response driven; it also depends on scheduled or event-triggered resolution.
8. IPFS integration
- services/ipfs.js and routes/ipfs.js indicate content or metadata is uploaded/pinned through an IPFS workflow, likely via a service such as Pinata.
- The frontend includes IpfsUpload.jsx, which means users can initiate uploads from the UI, but the backend is the trusted integration point for pinning and returning content hashes/URIs.
- This is the media/metadata persistence layer for decentralized assets and badge/token metadata.
9. Frontend DApp: frontend/
- The frontend is a React + Vite + Tailwind + Ethers.js application.
- WalletContext.jsx and AuthContext.jsx separate blockchain wallet state from backend-authenticated user state, which matches the app’s dual identity model: wallet ownership plus platform login.
- Pages such as CreatorDashboard, FanDashboard, Marketplace, Milestones, and Landing divide the user experience by role and task.
- Components like PriceChart, ForecastChart, and VolumeBadge show the UI is heavily data-driven and consumes backend analytics/forecast endpoints rather than reading everything directly from chain.
10. Frontend-to-backend and frontend-to-chain data flow
- The frontend’s api.js is the API boundary for backend calls.
- The ABI bundle in frontend/src/abi/ indicates direct contract interaction via Ethers.js for wallet-connected actions, while operational data like authentication, charts, milestones, and IPFS uploads comes from the backend.
- In practice, the UI is a hybrid client: it talks to the blockchain for transaction execution and to the backend for authoritative off-chain business logic and enriched data.
11. Forecast service: forecast/
- The forecast/ folder is a separate FastAPI microservice in Python.
- The README says it provides AI price forecasting using Holt-Winters + linear regression, which makes it a specialized analytics service rather than part of the main Node backend.
- This service likely receives historical pricing/volume inputs and returns predictions consumed by frontend charts or backend analytics endpoints.
12. Analytics and reporting
- backend/src/routes/analytics.js and frontend components like PriceChart, ForecastChart, and VolumeBadge show that historical market data is surfaced as first-class product functionality.
- The Trade model suggests the backend stores trade records for aggregation, charting, and possibly reconciliation against on-chain events.
- This analytics layer is the read-optimized side of the system, separate from the write-heavy chain interactions.
13. Testing and CI
- There are three major test surfaces: Hardhat contract tests in contracts/test, Jest backend tests in backend/__tests__, and a frontend build step in CI.
- .github/workflows/ci.yml plus the README mention contract checks, backend tests, frontend build, and Slither analysis, so the repo treats security and deployment readiness as part of the pipeline.
- This supports a multi-boundary architecture where correctness is validated independently at the contract, API, and UI layers.
14. Deployment/runtime boundaries
- Each runtime has its own packaging: backend and forecast both have Dockerfiles, frontend is Vercel-oriented, and contracts use Hardhat deployment scripts.
- The repo is therefore designed for separate deployment of the chain, API, UI, and AI service, which is important for diagramming because each has different scaling and trust characteristics.
- External services materially shaping the architecture are Polygon, Google OAuth, YouTube Data API, MongoDB, IPFS/Pinata, and the forecast service’s Python ML stack.
Main entry points: index.js Express API · App.jsx React App · contracts Contracts · ci.yml CI Pipeline
Components 17
On-chain
Solidity contracts, deployment, and Hardhat workflow
- Contracts · Token, marketplace, milestone, and reward contracts
contracts/contracts - Deploy Scripts · Hardhat deployment, verification, and seeding scripts
contracts/scripts - Contract Tests · On-chain behavior tests for core contracts
contracts/test
Backend API
Express API, persistence, integrations, and jobs
- Express API · HTTP entrypoint for auth, data, and orchestration
backend/src/index.js - Auth Layer · Google OAuth, middleware, and session protection
backend/src/services/passport.js - Platform Adapters · Normalized creator-platform adapters for YouTube and Twitch
backend/src/services/platforms - Chain Service · Reads and writes blockchain state from the backend
backend/src/services/chain.js - Models & Routes · Users, trades, milestones, analytics, and platform endpoints
backend/src/routes - Milestone Job · Background milestone resolution and reward triggering
backend/src/jobs/milestoneResolver.js - IPFS Service · Uploads and pins metadata or media for decentralized assets
backend/src/services/ipfs.js
Frontend DApp
React client, state, pages, and charts
- React App · Vite-based client that combines wallet and authenticated state
frontend/src/App.jsx - Contexts · Wallet and backend-auth state management
frontend/src/context - Dashboards · Role-based pages for creators, fans, marketplace, and milestones
frontend/src/pages - Charts & Uploads · Price, forecast, volume, and IPFS upload components
frontend/src/components - API + ABI · Backend API client plus direct contract ABI bindings
frontend/src/api.js
Forecast Service
Python analytics microservice
- Forecast API · Python price forecasting microservice
forecast/app.py
CI / Ops
Repository-wide testing and release automation
- CI Pipeline · Build, test, and security checks across the repo
.github/workflows/ci.yml
Connections 21
- Express API → Auth Layer: uses · API protects routes and establishes user identity
- Express API → Platform Adapters: normalizes · API delegates creator platform lookups to adapters
- Express API → Chain Service: syncs · API reconciles off-chain requests with on-chain state
- Express API → Models & Routes: serves · Routes expose auth, trades, analytics, milestones, and IPFS
- Express API → Milestone Job: triggers · Milestone processing is also handled asynchronously
- Models & Routes → IPFS Service: uploads · IPFS endpoints back media and metadata workflows
- Models & Routes → Forecast API: queries · Forecast and analytics endpoints consume prediction service output
- Models & Routes → Contracts: reflects · Backend models mirror on-chain trading and milestone activity
- Milestone Job → Contracts: awards · Resolved milestones can trigger on-chain rewards
- React App → Contexts: holds · Client state separates wallet and authenticated identity
- React App → Dashboards: renders · Pages drive creator, fan, marketplace, and milestone flows
- React App → Charts & Uploads: composes · Dashboards embed charts and upload widgets
- React App → API + ABI: fetches · UI calls backend APIs and contract bindings
- API + ABI → Express API: calls · Client API layer talks to the Express backend
- API + ABI → Contracts: transacts · Wallet-connected actions use contract ABIs
- Deploy Scripts → Contracts: deploys · Scripts publish core contracts to target networks
- Contract Tests → Contracts: verifies · Hardhat tests validate contract behavior
- CI Pipeline → Contract Tests: checks · CI runs contract validation
- CI Pipeline → Express API: tests · CI runs backend test suite
- CI Pipeline → React App: builds · CI verifies frontend build output
- CI Pipeline → Forecast API: packages · CI includes the forecast service runtime