An AI-Powered REST API Test Case Generator
TestPilot AI is a modern developer tool designed to automate exhaustive REST API test suite creation. By providing an HTTP method, endpoint path, description, and an optional sample JSON request body, the application leverages Spring AI connected to high-speed inference on Groq Cloud (openai/gpt-oss-20b) to generate categorized positive, negative, and validation test cases with expected HTTP status mappings.
-
Spring AI 2.0 Integration: Built using modern Spring AI (
spring-ai-starter-model-openai), utilizing Spring AI's fluentChatClientandOpenAiChatModelconfigured with nativeJSON_OBJECTresponse formatting and low reasoning effort to ensure deterministic, fast JSON outputs. -
Stateless & Confidential Key Management: Groq API keys are supplied on-demand per request by the user via the
X-Groq-Api-KeyHTTP header. The backend never persists or logs keys, scoping client instances strictly to individual request lifecycles. -
Multi-Stage Resilient JSON Parsing: Implements a fail-safe parsing pipeline using Jackson's streaming
JsonParseralong with automatic regex sanitizers (recovering from stray quotes, extra trailing braces, and formatting slips) to guarantee that the UI never breaks. - Postman-Inspired Dark Interface: Pure React 18 and modular Vanilla CSS designed for developer ergonomics with real-time payload tabs, status-coded badges, and instant JSON exports.
-
Clean Layered Architecture: Follows strict separation of concerns: Controller
$\rightarrow$ Orchestration Service$\rightarrow$ Spring AI Inference Layer$\rightarrow$ Global Exception Handling.
flowchart TD
subgraph Client["Frontend - React 18 & Vite"]
UI["Postman-Style UI"]
Modal["API Key Modal - Session Storage"]
AxiosClient["Axios HTTP Client"]
end
subgraph Backend["Backend - Spring Boot & Spring AI"]
Controller["TestCaseController - /api/testcases"]
Validator["Jakarta Bean Validation"]
Service["TestCaseService - Prompt & Parser"]
LLM["LLMService - Spring AI"]
SpringAI["OpenAiChatModel - Request Scoped"]
Parser["Jackson Streaming JsonParser"]
GlobalEx["GlobalExceptionHandler"]
end
subgraph Cloud["Groq Cloud Inference"]
GroqAPI["Groq OpenAI-Compatible API"]
Model["openai/gpt-oss-20b"]
end
UI -->|1. Submit Details and Key| AxiosClient
AxiosClient -->|2. POST /api/testcases/generate| Controller
Controller -->|3. Validate Payload| Validator
Validator -->|4. Valid Request| Service
Service -->|5. Build QA Persona Prompt| LLM
LLM -->|6. Build OpenAiChatModel with User Key| SpringAI
SpringAI -->|7. Execute Prompt via ChatClient| GroqAPI
GroqAPI --> Model
Model --> GroqAPI
GroqAPI -->|8. Raw JSON Output| SpringAI
SpringAI -->|9. Response String| Service
Service -->|10. Stream Token Parse & Sanitize| Parser
Parser -->|11. Structured TestCaseResponse DTO| Controller
Controller -->|12. 200 OK JSON Response| AxiosClient
AxiosClient -->|13. Render 3-Column Test Grid| UI
sequenceDiagram
autonumber
actor Dev as Developer / QA
participant UI as React Frontend
participant API as Spring Boot Controller
participant Service as TestCaseService
participant LLM as LLMService
participant Groq as Groq Cloud API
Dev->>UI: Enter HTTP Method, Endpoint, Description, Body
Dev->>UI: Enter Groq API Key via Modal
Dev->>UI: Click Generate Test Cases
UI->>API: POST /api/testcases/generate with X-Groq-Api-Key
API->>API: Validate Request Payload
API->>Service: Call generateTestCases
Service->>Service: Construct QA prompt with JSON schema
Service->>LLM: Call generateContent with prompt and Key
LLM->>LLM: Build OpenAiChatModel with ClientOptions
LLM->>Groq: POST /v1/chat/completions with JSON mode
Groq-->>LLM: Return JSON response
LLM-->>Service: Return response string
Service->>Service: Clean markdown fences and sanitize
Service->>Service: Stream parse with Jackson JsonParser
Service-->>API: Return TestCaseResponse DTO
API-->>UI: Return 200 OK with TestCaseResponse
UI-->>Dev: Display 3-Column Cards and Download JSON
| Technology | Specification | Purpose |
|---|---|---|
| Java | 21+ | Core runtime language |
| Spring Boot | 4.x (spring-boot-starter-web) |
REST API container and dependency injection |
| Spring AI | 2.0.0 (spring-ai-starter-model-openai) |
ChatClient fluent API, OpenAiChatModel client |
| Validation | spring-boot-starter-validation |
Declarative request payload validation (@NotBlank, @Valid) |
| JSON Engine | Jackson 2.x / 3.x (jackson-databind) |
Streaming JSON deserialization (JsonParser) and schema mapping |
| Inference Engine | Groq Cloud (openai/gpt-oss-20b) |
Ultra-fast token generation via OpenAI-compatible endpoint |
| Build Tool | Apache Maven 3.9+ | Dependency resolution and build lifecycle management |
| Technology | Specification | Purpose |
|---|---|---|
| React | 18.3.1 | Declarative component architecture and state management |
| Vite | 5.3.1 | Build tooling and development proxy server (/api 8080) |
| Axios | 1.7.2 | Promise-based HTTP client with 60-second generation timeout |
| Vanilla CSS | CSS3 Custom Properties (Variables) | Postman-inspired dark developer theme |
| Typography | Inter & JetBrains Mono | Monospace code styling and readable UI typography |
SmartAPITester/
โโโ backend/ # Spring Boot Application
โ โโโ pom.xml # Spring AI BOM, starters & dependencies
โ โโโ src/
โ โโโ main/
โ โโโ java/com/testpilot/
โ โ โโโ TestPilotApplication.java # Bootstrap application entry
โ โ โโโ config/
โ โ โ โโโ CorsConfig.java # Cross-Origin (CORS) rules
โ โ โโโ controller/
โ โ โ โโโ TestCaseController.java # REST endpoints (/generate, /download)
โ โ โโโ dto/ # Data Transfer Objects
โ โ โ โโโ ApiRequest.java # Incoming request payload
โ โ โ โโโ TestCase.java # Single scenario structure
โ โ โ โโโ ExpectedResponse.java # Status code prediction
โ โ โ โโโ TestCaseResponse.java # Aggregated response structure
โ โ โโโ exception/
โ โ โ โโโ GlobalExceptionHandler.java # Unified error responses
โ โ โ โโโ LLMException.java # Custom exception for AI failures
โ โ โโโ service/
โ โ โโโ LLMService.java # Spring AI ChatClient integration
โ โ โโโ TestCaseService.java # QA prompt builder & stream parsing
โ โโโ resources/
โ โโโ application.properties # Server port, Groq base URL, logging
โ
โโโ frontend/ # React 18 Application (Vite)
โโโ package.json # Dependencies & scripts
โโโ vite.config.js # Proxy forwarding /api to port 8080
โโโ src/
โโโ main.jsx # Application bootstrap
โโโ App.jsx # Master layout, state & scrolling
โโโ index.css # Global dark theme tokens & reset
โโโ components/
โ โโโ ApiKeyModal.jsx # Secure in-browser API key manager
โ โโโ InputForm.jsx # Postman-style URL bar, method selector & tabs
โ โโโ ResultSection.jsx # 3-column test cards, status chips & export
โโโ services/
โโโ apiService.js # Axios instance with request interceptors
- Java JDK: 21 or higher (
java -version) - Node.js & npm: Node 18+ and npm 9+ (
node -v,npm -v) - Groq API Key: Free key from Groq Console
- Navigate to the
backenddirectory:cd backend - Run the application:
The backend starts on
mvn spring-boot:run
http://localhost:8080.
- Open a new terminal and navigate to
frontend:cd frontend - Install dependencies:
npm install
- Start the Vite development server:
The frontend starts on
npm run dev
http://localhost:5173with automatic API reverse-proxying.
- Open
http://localhost:5173in your browser. - Click "Set API Key" in the top navigation and paste your Groq API key (
gsk_...). - Select an HTTP method (e.g.
POST,GET,PUT,DELETE). - Enter an endpoint path (e.g.
/api/v1/users). - Provide a short functional description of the endpoint.
- (Optional) Paste a sample JSON request body in the Body tab.
- Click "Generate Test Cases" to view and download your full test suite.