5.8 KiB
5.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Common Development Commands
Backend (.NET)
# Build entire solution
dotnet build src/Managing.sln
# Run main API (port 80/443)
dotnet run --project src/Managing.Api/Managing.Api.csproj
# Run worker API (port 81/444)
dotnet run --project src/Managing.Api.Workers/Managing.Api.Workers.csproj
# Run tests
dotnet test src/Managing.Application.Tests/
dotnet test src/Managing.Infrastructure.Tests/
# Run specific test
dotnet test --filter "TestMethodName"
# Database migrations
dotnet ef database update --project src/Managing.Infrastructure.Database/Managing.Infrastructure.Databases.csproj --context ManagingDbContext
dotnet ef migrations add <MigrationName> --project src/Managing.Infrastructure.Database/Managing.Infrastructure.Databases.csproj --context ManagingDbContext
# Regenerate API client (after API changes)
cd src/Managing.Nswag && dotnet build
Frontend (React/TypeScript)
cd src/Managing.WebApp
# Install dependencies
npm install
# Development server
npm run dev
# Build for production
npm run build
# Linting and type checking
npm run lint
npm run typecheck
# Tests
npm run test
Full Stack Development
# Quick start with Docker
./scripts/build_and_run.sh
# Alternative using Aspire
cd src && ./run-aspire.sh
Architecture Overview
Clean Architecture Pattern
The codebase follows Clean Architecture with clear layer separation:
- Domain (
Managing.Domain): Business entities and core rules - Application (
Managing.Application*): Use cases, commands, and business orchestration - Infrastructure (
Managing.Infrastructure.*): External integrations (databases, Web3, messaging) - Presentation (
Managing.Api*): REST APIs and controllers
Service Architecture
Multiple coordinated services handle different concerns:
- Managing.Api: Main trading operations, bot management, backtesting
- Managing.Api.Workers: Background workers for price data, genetic algorithms, statistics
- Managing.Web3Proxy: Node.js service for Web3/GMX blockchain interactions
- Managing.WebApp: React frontend with real-time SignalR updates
Data Storage Strategy (Polyglot Persistence)
- PostgreSQL: Transactional data (users, bots, positions, scenarios, backtests)
- InfluxDB: Time-series data (OHLCV candles, agent balances, performance metrics)
- MongoDB: Document storage for certain data types
Key Domain Concepts
- Bot: Abstract base with lifecycle management for trading automation
- Position: Trading positions with PnL tracking and trade history
- Scenario: Collections of technical indicators defining trading strategies
- Indicator: Technical analysis tools (RSI, MACD, EMA, SuperTrend, etc.)
- MoneyManagement: Risk parameters (stop loss, take profit, position sizing)
- Account: Multi-exchange trading accounts (CEX, GMX V2, Privy wallets)
Development Patterns
Adding New Features
- Domain First: Create entities in
Managing.Domain - Application Layer: Add services/command handlers in
Managing.Application - Infrastructure: Implement repositories and external integrations
- API Layer: Add controllers and endpoints
- Frontend: Update React components and API client
Bot Development
- Inherit from
Botbase class inManaging.Domain/Bots/ - Implement
SaveBackup()andLoadBackup()for persistence - Use dependency injection pattern for services
- Follow worker pattern for background execution
Adding Technical Indicators
- Create indicator class implementing
IIndicator - Add to
IndicatorTypeenum inManaging.Common - Register in DI container via
ApiBootstrap - Implement calculation logic in
TradingService
Database Changes
- Update entities in domain layer
- Modify
ManagingDbContextwith new DbSets - Generate EF Core migration
- Update repository interfaces and implementations
- Consider InfluxDB for time-series data
Web3 Integration
- GMX V2 interactions go through
Managing.Web3ProxyNode.js service - Use
Managing.Infrastructure.Web3for .NET integration - Privy handles wallet management and authentication
Configuration & Environment
Key Configuration Files
src/Managing.Api/appsettings.*.json: Main API configurationsrc/Managing.Api.Workers/appsettings.*.json: Worker configurationsrc/Managing.WebApp/.env: Frontend environment variables
Environment-Specific Deployments
- Development:
appsettings.Development.json - Sandbox:
appsettings.Sandbox.json - Production:
appsettings.Production.json - Docker:
appsettings.Oda-docker.json
Important Development Guidelines
Quantitative Finance Principles
- Use
decimalfor all monetary calculations (neverfloatordouble) - Implement proper audit trails for financial operations
- Validate trading strategies with historical backtesting
- Optimize time-series processing for performance
Code Architecture Rules
- Follow Controller → Application → Repository pattern (never inject repositories directly into controllers)
- Use CQRS pattern with command handlers for complex operations
- Implement proper error handling with user-friendly messages
- Maintain separation between domain logic and infrastructure concerns
API Development
- Follow RESTful conventions
- Use attribute routing in controllers
- Return appropriate HTTP status codes
- Implement proper validation using Data Annotations
Testing Strategy
- Unit tests focus on domain logic and indicators
- Integration tests for external service interactions
- Use data-driven testing with JSON fixtures for backtesting scenarios
Real-time Features
- SignalR hubs provide live updates for trading data, bot status, and market information
- Frontend uses reactive patterns with real-time price feeds and position updates