How capgoblin/conflux-ai works
Main Components
• Local Training Environment – This involves the Python modules dealing with computing technical indicators, training LSTM neural network models, and encrypting model weights. Represent this part using elements like “Local Data”, “Local Training”, and “Local Model”.
• Secure Storage & Model Upload – Captured in the Node.js portion where encrypted model weights are uploaded (with RESTful endpoints) and later retrieved. Include components such as “Node.js Server”, “Encrypted Weights”, and “Global Model Storage”.
• Model Aggregation System – Operates within the Python “models” code (main.py) that aggregates individual models using federated learning, calculates contribution scores, and produces the global AI model.
• Trading Agent – Encompasses the autonomous trading system including the trading logic implemented via a combination of the global LSTM model and Secret AI’s LLM. This part also interfaces with a Flask server and handles trade execution.
• Smart Contract Layer – Written in Rust (in the contract/ folder) and integrated with Secret.js functions in the web-app. It manages on-chain recording of model CIDs, contribution scores, and facilitates transparent profit distribution.
• Web Application/UI – The front end (Next.js in web-app) where users deposit funds, set up trading, and interact with the platform, integrating secret functions for on-chain transactions.
Relationships and Data Flow
• Local data is processed and models are trained locally. Once a model is trained, its encrypted weights are sent to the Node.js server, which then stores them securely.
• The global storage (maintained by the Node.js service) makes the encrypted models available for aggregation in the Python-based model aggregation system.
• The aggregated global model’s reference (CID) is recorded on-chain via the smart contract.
• The web application provides interfaces for user deposit, model registration, and profit distribution. It communicates with smart contracts (using Secret.js functions) to record trader contributions.
• The autonomous trading agent uses the analytic model to process market data, generate trading decisions, and execute trades. Feedback (including executed trade logs) is reported back through both the Flask server and web UI.
• All these interactions follow a trustless flow, ensuring data privacy and a fair, decentralized profit-sharing mechanism.
Architectural Patterns & Design Principles
• Privacy-First: Emphasize that raw data never leaves the local environment; only encrypted model weights are transmitted.
• Federated Learning: Showcase how multiple models are aggregated to form a robust global model with fair attribution.
• Decoupled Services: The system clearly separates the frontend (Next.js web app), backend APIs (Node.js), computational aggregation & agent logic (Python), and smart contracts (Rust).
• Modular Interfaces: Use clear RESTful interactions (data upload/retrieval) and smart contract interactions to highlight the decoupling between secure storage, computation, and on-chain recording.
Relevant Technologies
• Python for data processing and model training (with requirements like PyTorch).
• Node.js (JavaScript/TypeScript) for handling API requests and secure file storage (with integrations for Autonomys AutoDrive).
• Rust for smart contract development on the Secret Network.
• Next.js (React/TypeScript) for the frontend web application and user interactions.
• Flask server as part of the trading agent’s operational backbone.
• Secret.js for blockchain/smart contract interactions.