Open-source Solana AI agent trading automation framework
Documentation β’ Quick Start β’ Architecture β’ Contributing
Nexgent AI is an open-source platform for building and managing AI-powered trading agents on the Solana blockchain. Create automated trading strategies, monitor positions in real-time, and execute trades with ultra-low latency.
- π€ AI Trading Agents - Create and configure multiple trading agents with custom strategies
- β‘ Ultra-Low Latency - Sub-100ms signal processing to trade execution
- π Real-Time Monitoring - Live position tracking, performance analytics, and WebSocket updates
- π Secure Wallet Management - Non-custodial wallet support with simulation and live trading modes
- π― Advanced Stop Loss - Multiple stop loss modes (fixed, exponential, zones, custom) with sub-1ms evaluation
- π Dollar Cost Averaging (DCA) - Automatic re-buys on price dips to lower average cost basis
- β±οΈ Stale Trade Auto-Close - Automatically close positions with modest gains/losses after minimum hold time
- π‘οΈ Price Impact Protection - Configurable maximum price impact limits per trade
- π Price Feeds - Real-time price data from Pyth Network, DexScreener, and Jupiter
- π Trade Execution - Automated swaps via Jupiter Aggregator API
- π± Modern Dashboard - Beautiful, responsive UI built with Next.js and shadcn/ui
- π Performance Analytics - Balance snapshots, historical swaps, transaction history, and performance metrics
- π System Health Monitoring - Real-time health checks for database, Redis, and queue services
- π‘ Webhooks - External integrations for trading signals and notifications
- π Prometheus Metrics - Comprehensive observability with Prometheus-compatible metrics
Nexgent AI is built as a monorepo with three main packages:
nexgent/
βββ packages/
β βββ backend/ # Express API + WebSocket server
β βββ frontend/ # Next.js dashboard
β βββ shared/ # Shared TypeScript types & utilities
βββ docker-compose.yml # Local development setup
βββ railway.json # Railway deployment config
- Trading Signals β External signals trigger agent evaluation
- Agent Processing β Agents check eligibility (balance, config, blacklist/whitelist) and execute trades
- Trade Execution β Jupiter Aggregator executes swaps on Solana (simulation or live mode)
- Position Management β Real-time tracking with Redis caching and PostgreSQL persistence
- Price Monitoring β Real-time Solana price via WebSocket (Pyth Network SSE), 1-second polling for other tokens with instant WebSocket delivery
- Stop Loss Evaluation β Sub-1ms in-memory evaluation with multiple calculation modes
- DCA Management β Automatic re-buys when price drops to configured levels
- Stale Trade Detection β Auto-close positions with modest gains/losses after hold period
- WebSocket Updates β Live updates to the frontend dashboard (positions, prices, balances)
- Signal Processing: Sub-100ms from signal to trade execution
- Stop Loss Evaluation: Sub-1ms in-memory evaluation
- Stop Loss Execution: Sub-500ms from trigger to on-chain execution
- Price Updates: Real-time Solana price via WebSocket (Pyth Network SSE), 1-second polling for other tokens with instant WebSocket delivery
- Node.js 18+ and pnpm 8+
- PostgreSQL 14+ (or use Docker Compose)
- Redis 6.0+ (or use Docker Compose)
-
Clone the repository
git clone https://github.com/Nexgent-ai/nexgent-open-source-trading-engine.git cd nexgent-open-source-trading-engine -
Install dependencies
pnpm install
-
Set up environment variables
# Backend cd packages/backend cp env.example .env # Edit .env with your database and Redis URLs # Frontend cd ../frontend cp env.example .env.local # Generate secrets: pnpm generate-secret
-
Start services with Docker Compose
# From root directory docker-compose up -d -
Run database migrations
pnpm --filter backend db:migrate
-
Start development servers
# From root directory pnpm dev -
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:4000
- API Docs: http://localhost:4000/api/v1/health
# Frontend (NextAuth.js)
pnpm generate-secret
# Backend (JWT)
pnpm generate-secret:backendExpress.js API server with WebSocket support built with Domain-Driven Design (DDD) principles. Handles:
- Trading signal processing and agent eligibility evaluation
- Trade execution via Jupiter (purchases, sales, DCA buys)
- Position and balance management with Redis caching
- Real-time price feeds (Solana via WebSocket SSE, other tokens via 1-second polling)
- Stop loss evaluation (multiple modes: fixed, exponential, zones, custom)
- DCA (Dollar Cost Averaging) management
- Stale trade auto-close detection
- Price impact protection
- WebSocket connections for live updates
- System health monitoring and Prometheus metrics
- Webhook endpoints for external integrations
Tech Stack: Express, TypeScript, Prisma, Redis, BullMQ, WebSocket, Prometheus
Key Scripts:
pnpm --filter backend dev # Start dev server
pnpm --filter backend build # Build for production
pnpm --filter backend db:migrate # Run migrations
pnpm --filter backend test # Run testsNext.js 15 dashboard with App Router. Features:
- Agent management and configuration with advanced trading settings
- Real-time position tracking with DCA purchase history
- Performance analytics with balance snapshots and historical charts
- Wallet management with deposit/withdraw capabilities
- Trading signal monitoring with export functionality
- System health monitoring dashboard
- Data source connection management
- Transaction history and trade detail views
Tech Stack: Next.js 15, TypeScript, Tailwind CSS, shadcn/ui, React Query, NextAuth.js
Key Scripts:
pnpm --filter frontend dev # Start dev server
pnpm --filter frontend build # Build for production
pnpm --filter frontend type-check # Type checkShared TypeScript types, utilities, and validation schemas used by both frontend and backend.
Contents:
- API request/response types
- Trading configuration types
- Validation schemas (Zod)
- Utility functions
- Runtime: Node.js 18+ (ESM)
- Framework: Express.js 4.18+
- Database: PostgreSQL 14+ with Prisma ORM
- Cache/Queue: Redis 6.0+ with BullMQ
- Blockchain: Solana Web3.js
- APIs: Jupiter Aggregator, DexScreener, Pyth Network
- Framework: Next.js 15 (App Router)
- Language: TypeScript 5.7+
- Styling: Tailwind CSS
- Components: shadcn/ui
- State: React Query (TanStack Query)
- Auth: NextAuth.js
- Charts: Recharts
- Package Manager: pnpm (workspaces)
- Deployment: Vercel (frontend), Railway (backend)
- Containerization: Docker & Docker Compose
- DEVELOPMENT.md - Complete development environment setup guide
- CONTRIBUTING.md - Contribution guidelines and development workflow
- Backend README - Detailed backend architecture and API docs
- Frontend README - Frontend architecture and component docs
- Security Policy - Security guidelines and vulnerability reporting
pnpm dev # Start both frontend and backend
pnpm dev:backend # Start backend only
pnpm dev:frontend # Start frontend only
pnpm dev:clean # Clean and start freshpnpm build # Build all packages
pnpm build:backend # Build backend only
pnpm build:frontend # Build frontend only
pnpm build:skip-tests # Build without running testspnpm test # Run all package tests
pnpm test:backend # Run backend tests (unit + integration)
pnpm --filter backend test:unit # Backend unit tests only
pnpm --filter backend test:integration # Backend integration tests onlypnpm lint # Lint all packages
pnpm type-check # Type check all packages- Fork the repository on GitHub
- Deploy frontend to Vercel
- Deploy backend to Railway with PostgreSQL and Redis
- Configure environment variables in both platforms
- Run migrations on Railway
See packages/backend/env.example and packages/frontend/env.example for required variables.
Critical variables:
DATABASE_URL- PostgreSQL connection stringREDIS_HOST/REDIS_PORT- Redis connectionJWT_SECRET- Backend authentication secretNEXTAUTH_SECRET- Frontend authentication secretJUPITER_API_KEY- Required for live trading (optional for simulation)
Important: When running Nexgent AI, you are responsible for securing your own wallet private keys and managing your trading operations. Security is critical.
- π Never commit
.envfiles or private keys to version control - π Generate strong secrets using
pnpm generate-secret - π‘οΈ Use simulation mode for testing before live trading
- π° Only fund wallets with the minimum SOL needed for trading
- π Review SECURITY.md for comprehensive security guidelines
Report vulnerabilities: Use GitHub's "Report a vulnerability" feature or email contact@nexgent.ai
Contributions are welcome! Please see our Contributing Guide for detailed information.
Quick start:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following our development guidelines
- Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For detailed setup instructions, see DEVELOPMENT.md.
Nexgent AI Trading Engine Copyright (C) 2026 Nexgent AI
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Attribution Notice: If you publicly deploy, distribute, or operate a modified or unmodified version of this software, you must preserve the following attribution in a reasonable and prominent location within the user interface or documentation:
"Powered by Nexgent AI β https://nexgent.ai"
See the LICENSE file for the full GPL-3.0 license text.
- Solana - Blockchain infrastructure
- Jupiter Aggregator - Token swap execution
- Pyth Network - Price oracles
- DexScreener - Token analytics
- Next.js - Frontend framework
- shadcn/ui - UI components
- Documentation: See the package README files and guides above
- Issues: GitHub Issues
- Security: SECURITY.md
- Email: contact@nexgent.ai
Built with β€οΈ for the Solana ecosystem
Website β’ Documentation β’ GitHub