Skip to content

Development Guide

Document Version: 2.0.0 最后更新: 2026-06-15 Git 提交: 0f56b957 作者: JAiRouter Team

Welcome to the JAiRouter Development Guide! This guide provides developers with comprehensive information on setting up the development environment, coding standards, testing strategies, and contribution processes.

Quick Start

If you are new to JAiRouter development, it is recommended to read the following documents in order:

  1. Architecture Overview - Understand the overall system architecture and design principles
  2. Contribution Guide - Learn how to participate in project development
  3. Testing Guide - Master testing strategies and best practices
  4. Code Quality Standards - Follow project coding standards

Development Environment Requirements

ToolVersionDescription
Java17+Required, LTS version
Maven3.8+Maven Wrapper included in project
Git2.20+Version control
IDE-IntelliJ IDEA (recommended) or Eclipse

Core Development Workflow

1. Environment Setup

# Clone the project
git clone https://github.com/Lincoln-cn/JAiRouter.git
cd jairouter

# Build the project (recommended for China users)
./mvnw clean package -Pchina

# Run tests
./mvnw compiler:compile compiler:testCompile surefire:test

2. Development Standards

  • Follow coding standards in Code Quality Standards
  • Use Checkstyle and SpotBugs for code quality checks
  • Ensure test coverage is at least 80%

3. Submission Process

# Create feature branch
git checkout -b feature/your-feature-name

# Write code and tests
# ...

# Run tests and quality checks
./mvnw clean verify

# Commit code
git add .
git commit -m "feat: your feature description"

# Push branch
git push origin feature/your-feature-name

# Create Pull Request

Project Architecture Overview

JAiRouter adopts a modular design with the following core modules:

ModulePackage PathResponsibility
authorg.unreal.modelrouter.authAuthentication, JWT, API Key
configorg.unreal.modelrouter.configConfiguration management, version control
routerorg.unreal.modelrouter.routerRouting, load balancing, rate limiting, circuit breaker
monitororg.unreal.modelrouter.monitorMonitoring, tracing, metrics
persistenceorg.unreal.modelrouter.persistenceData persistence, repositories
commonorg.unreal.modelrouter.commonCommon utilities, exceptions, constants

For detailed information, please refer to Architecture Overview.


Common Commands

Build Commands

# Full build (including all checks)
./mvnw clean package

# Fast build (skip checks)
./mvnw clean package -Pfast

# China mirror acceleration
./mvnw clean package -Pchina

Test Commands

# Run all tests
./mvnw test

# Run specific tests
./mvnw test -Dtest=LoadBalancerTest

# Generate coverage report
./mvnw clean test jacoco:report

Quality Checks

# Code style check
./mvnw checkstyle:check

# Static analysis
./mvnw spotbugs:check

# Full quality check
./mvnw verify

Development Tool Integration

Code Quality Tools

ToolPurposeConfiguration File
CheckstyleCode style checkingcheckstyle.xml
SpotBugsStatic code analysisspotbugs-security-*.xml
JaCoCoCode coverage analysispom.xml

Testing Frameworks

FrameworkPurpose
JUnit 5Main testing framework
MockitoMock framework
Spring Boot TestIntegration testing support
Reactor TestReactive stream testing

Extension Development

Adding New Adapters

  1. Create adapter class extending BaseAdapter
  2. Implement request transformation and response mapping logic
  3. Register in AdapterRegistry
  4. Write unit tests

For detailed instructions, please refer to Contribution Guide.

Adding New Load Balancing Strategies

  1. Implement LoadBalancer interface
  2. Register in LoadBalancerFactory
  3. Add configuration support
  4. Write test cases

Adding New Rate Limiting Algorithms

  1. Implement RateLimiter interface
  2. Register in RateLimiterFactory
  3. Add YAML configuration support
  4. Write concurrency tests

Getting Help

If you encounter problems during development, you can get help in the following ways:

  • Check project documentation and FAQ
  • Search existing GitHub Issues
  • Create a new Issue to describe the problem
  • Participate in community discussions

Contribution Methods

We welcome all forms of contributions:

TypeDescription
🐛 Bug ReportsReport issues promptly when discovered
Feature DevelopmentImplement new features or improve existing ones
📚 Documentation ImprovementsEnhance documentation content and examples
🧪 Test EnhancementsAdd test cases to improve coverage
💡 Suggestion DiscussionsPropose improvement suggestions and ideas

For detailed contribution processes, please refer to Contribution Guide.


Thank you for your contributions to the JAiRouter project!