Welcome to OnChainSage
Relevant source files
The following files were used as context for generating this wiki page:
OnChain Sage is an open-source, AI-driven, decentralized trading assistant designed to provide crypto traders with actionable insights. It achieves this by integrating real-time social sentiment analysis from sources like X (formerly Twitter) with on-chain market data from platforms such as Raydium and Dex Screener. The platform leverages AI and blockchain technologies to monitor trends, liquidity, volume, and whale activity, delivering reliable trading signals through a user-friendly dashboard.
The project is built with a modular, data-first architecture to encourage community contributions and ensure scalable, robust performance. It utilizes the Starknet network for its decentralized components, including a payment model based on the STRK token. This document provides a high-level overview of the project's architecture, features, and development setup.
Sources: README.md:7-12, ARCHITECTURE.md:5-9
Core Concept
OnChain Sage is founded on three core principles that guide its development and functionality.
- Data-Driven Trading: The system integrates social sentiment analysis with on-chain analytics to generate comprehensive trading signals.
- Decentralized Payment Model: It uses the Starknet network and STRK tokens to manage gas fees and access to premium features, ensuring a decentralized operational framework.
- Open-Source Collaboration: The project is structured as a modular monorepo, which simplifies maintenance and scalability, encouraging a vibrant community of contributors.
Sources: README.md:21-26
Key Features
The platform offers a suite of features designed to empower traders.
| Feature | Description | Source File |
|---|---|---|
| AI-Powered Analysis | Utilizes advanced NLP and ML models to analyze Twitter data and detect emerging crypto trends. | apps/frontend/components/Layout/features.tsx:15-18 |
| On-Chain Data Insights | Monitors key on-chain metrics like liquidity, volume, and whale activity through various APIs. | README.md:31-32 |
| Actionable Trading Signals | Provides categorized signals (e.g., high-confidence, emerging, risky) to help guide trading decisions. | README.md:33-34 |
| User-Friendly Dashboard | A responsive interface built with Next.js, featuring dynamic data visualizations using Chart.js and D3.js. | README.md:35-36 |
| Secure Blockchain Integration | Employs smart contracts written in Cairo on the Starknet network to manage STRK token transactions and premium access securely. | README.md:37-38 |
| Decentralized Payment | Leverages the Starknet network and STRK tokens for handling gas fees and premium service payments. | apps/frontend/components/Layout/features.tsx:39-42 |
| Community Signal Validation | Allows users to vote on signal credibility, with votes weighted by reputation, influencing signal rankings and reward distribution. | ARCHITECTURE.md:71-73 |
| Signal Staking | Users can stake STRK tokens on trading signals to show confidence, with rewards distributed based on the signal's accuracy. | ARCHITECTURE.md:69-70 |
Architecture Overview
OnChain Sage is built on a data-first, modular, and event-driven architecture. This design promotes scalability and loose coupling between components, making the system maintainable and adaptable for open-source contributors. The architecture is divided into five distinct layers, each with specific responsibilities.
Sources: ARCHITECTURE.md:11-16
The following diagram illustrates the high-level system architecture and the interaction between its layers.
Sources: ARCHITECTURE.md:18-24
System Components & Tech Stack
Each layer of the architecture utilizes a specific set of technologies to fulfill its role.
| Layer | Technologies | Primary Responsibilities | Source Files - |
|---|---|---|---|
| Frontend | Next.js, React, Tailwind CSS, Chart.js/D3.js | UI/Dashboard, real-time data visualization, user interaction, WebSocket communication. | ARCHITECTURE.md:30-38 - |
| Backend | NestJS, Node.js, TypeScript, PostgreSQL, Redis | API request handling, user authentication, signal coordination, and caching. | ARCHITECTURE.md:40-49 - |
| Data Processing | Python, TensorFlow, PyTorch, OpenAI API | Data ingestion, sentiment analysis, signal generation, and data aggregation. | ARCHITECTURE.md:51-60 - |
| Blockchain | Starknet, Cairo, Dojo | Smart contract management, token transactions (staking, rewards), and community validation. | ARCHITECTURE.md:62-81 - |
- Database & Infra | PostgreSQL, Redis, Docker, Kubernetes | Data persistence, caching, scalable deployment, and infrastructure management. |
ARCHITECTURE.md:83-91- |
Data Flow
The system's functionality is driven by its data-first approach, ensuring that data is processed efficiently and delivered in real-time.
This diagram shows the sequential flow of data through the system.
Sources: ARCHITECTURE.md:93-112
Project Structure
OnChain Sage is organized as a monorepo, managed with npm workspaces. This structure separates each major component into its own application directory under apps/, while shared utilities and packages are located in packages/.
This structure is detailed in the main README.md.
Sources: README.md:92-106
Getting Started
To begin contributing to OnChain Sage, you'll need to set up the development environment.
Prerequisites
- Node.js (v14+)
- Python (3.8+)
- Docker
- A Starknet wallet (e.g., Argent or Braavos)
Sources: README.md:71-76, CONTRIBUTING.md:27-30
Installation and Setup
-
Fork and Clone: Fork the repository on GitHub and clone it to your local machine.
git clone https://github.com/your-username/onchainsage.git cd onchainsageSources: CONTRIBUTING.md:16-19
-
Install Dependencies: Use
npmto install dependencies for all workspaces.npm installSources: README.md:82-84
-
Environment Configuration: Create
.envfiles for each application in theapps/directory based on the examples provided.
Sources: README.md:86-87 -
Run Applications: Start the individual services using the workspace commands.
- Frontend:
npm run dev --workspace=apps/frontend - Backend:
npm run start:dev --workspace=apps/backend
For data processing and blockchain services, refer to the
README.mdfiles within their respective directories.
Sources: README.md:90-91, package.json:5-8 - Frontend:
Contributing
Contributions from the community are highly encouraged. The development process follows a standard fork-and-pull-request model.
- Create a Branch: Create a new feature or bugfix branch from
main. - Commit Changes: Make your changes and write clear, concise commit messages.
- Run Tests: Ensure all tests pass and that code is formatted according to project standards using linters like ESLint and Prettier.
- Submit a Pull Request: Open a PR against the
mainbranch with a detailed description of your changes.
For more detailed guidelines on branching strategy, code standards, and communication channels, please refer to the CONTRIBUTING.md file.
Sources: CONTRIBUTING.md:10-40