How tsheylock/modu works
Project type and purpose
• This is a decentralized application (dApp) combining:
– A React + TypeScript single-page frontend (built with Vite)
– Solidity smart contracts deployed via Hardhat onto the Saske blockchain
– AI/NLP modules for emotion analysis (text, audio, video)
– Decentralized storage (IPFS) for historical data
– Visualization libraries (Chart.js, vis-network) for graphs and trend analysis
File structure
• Top-level deployment & build artifacts:
– Dockerfile, docker-compose.yml, nginx.conf, deploy.sh
– .env, .env.example, tsconfig*.json, vite.config.ts
– Hardhat config (hardhat.config.ts), scripts/, test/
• Source code directories (implied by README):
– src/components: UI widgets
– src/contracts: Solidity smart contracts
– src/utils: helpers (Ethers.js, IPFS clients, NLP wrappers)
– src/pages or index.html: entry point
• Documentation covers installation, security, scaling, monitoring, optimization, and deployment.
README for additional insights
• Technology stack: React, TypeScript, Vite, Solidity, Hardhat, IPFS, Ethers.js/Web3.js, NLP libs, Chart.js, vis-network
• Workflow: “npm run dev” spins up the Vite server; “npm run compile/test/deploy” for contracts
• Environment configuration via .env (RPC URLs, private keys, API keys)
Main components & interactions
A. Frontend (User’s Browser)
– React SPA (Vite-bundle)
– Emotion input (text/audio/video) → NLP engine (client-side or external API)
– Chart.js & vis-network for in-browser rendering
– Ethers.js/Web3.js to call smart contracts
– IPFS client to upload/download emotional data blobs
B. Smart Contracts (Solidity on Saske)
– EmotionToken contract: mints NFTs, records metadata pointers
– Event logs for downstream indexing
C. Decentralized Storage (IPFS)
– Stores emotion payloads, history archives
– Pinning node or third-party pinning service
D. Blockchain Network (Saske mainnet/testnet)
– RPC endpoints (configured in .env)
– Etherscan or similar explorer for block & contract verification
E. Dev/CI Tools (local dev only)
– Hardhat local network for testing & deployment scripts (scripts/ folder)
F. Deployment Infrastructure
– Docker containers: Nginx serves the built SPA; optional Node.js SSR container if used
– docker-compose.yml orchestrates services (frontend, optionally a local IPFS node)
– CI/CD pipelines (deploy.sh, GitHub Actions or similar)
1. User → Browser UI → NLP analysis
2. Browser UI → IPFS API → data CID returned
3. Browser UI → Smart Contract via Ethers.js → mint NFT with metadata CID
4. Smart Contract → emits events → Browser listens (WebSocket/RPC polling)
5. Browser UI ← fetches historical CIDs from contract events → IPFS → displays trends
Architectural patterns & design principles
• dApp pattern: client-heavy, blockchain as backend
• Separation of concerns: UI / business logic / blockchain / storage
• Containerization: immutable builds, reproducible environments
• Environment-driven configuration (.env) for RPC URLs and API keys
• Modular frontend: components, utils, services
• Dev-prod parity: Hardhat local network mirrors Saske testnet/mainnet
Diagramming recommendations
• Use clear, concise labels for each node (e.g., “React SPA”, “EmotionToken Contract”, “IPFS Pinning”)
– Frontend (blue rectangles)
• Important technologies next to each component