Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring AI Agent Pipeline

Automated API Specification Generator powered by AI agents.


Overview

Spring AI Agent Pipeline is a multi-agent AI system that analyzes a MySQL database structure and automatically generates a professional API Specification. Users simply describe their system, and the pipeline analyzes it, generates code, and exports the API Specification as a .docx file.


Screenshot

Input Image

SA Agent Image

Dev Agent Image

Spec Agent Image

Spec .docx Output:

View the spec via: v1.0.0 Release


How It Works

User enters project description
        ↓
DatabaseReaderService reads MySQL table structure
        ↓
SA Agent analyzes the system and database
        ↓
Dev Agent generates Spring Boot code
        ↓
Spec Agent generates structured API Specification
        ↓
DocxGeneratorService fills Word template
        ↓
User downloads api-specification.docx

Example Output

Download a sample generated API Specification from the v1.0.0 Release


AI Agents

SA Agent (System Analyst)

Analyzes the project description and real database structure, then produces a comprehensive system analysis document including System Overview, Key Entities, Relationships, CRUD Operations, and REST API Endpoints.

Dev Agent (Developer)

Receives the SA Agent's analysis and generates production-ready Spring Boot code covering Model, Repository, Service, and Controller layers.

Spec Agent (Specification)

Receives the SA Agent's analysis and generates a fully structured API Specification in JSON format including Method, URL, Request Headers, Request Parameters, Response Parameters, and Example Data for each endpoint.


Tech Stack

Component Technology
Backend Framework Spring Boot 4.0.6
AI Framework Spring AI 2.0.0-M5
AI Provider Groq (llama-3.3-70b-versatile) / Ollama (llama3.2)
Database MySQL 8.0
Document Generation Apache POI + poi-tl 1.12.2
Language Java 21
Build Tool Maven

Project Structure

src/main/java/com/code/SpringAIAgentPipeline/
├── config/
│   └── AppConfig.java                  ← Jackson ObjectMapper configuration
├── controller/
│   ├── PipelineController.java         ← POST /api/v1/generate
│   └── DownloadController.java         ← POST /api/v1/download
├── dto/
│   ├── GenerateRequest.java
│   ├── GenerateResponse.java
│   ├── ApiSpecDto.java
│   └── ApiEndpointDto.java
├── service/
│   ├── DatabaseReaderService.java      ← reads MySQL table structure
│   ├── SaAgentService.java             ← SA AI Agent
│   ├── DevAgentService.java            ← Dev AI Agent
│   ├── SpecAgentService.java           ← Spec AI Agent
│   ├── DocxGeneratorService.java       ← generates .docx from template
│   └── PipelineService.java            ← orchestrates the full pipeline

src/main/resources/
├── static/
│   └── index.html                      ← Web UI
├── templates/
│   └── api-spec-template.docx          ← Word template for .docx output
└── application.properties

Prerequisites

Tool Version Download
Java JDK 21 https://adoptium.net
Maven 3.9+ https://maven.apache.org
MySQL 8.0+ https://dev.mysql.com/downloads
IntelliJ IDEA Any https://www.jetbrains.com/idea

Setup

Step 1 — Database Setup

Open MySQL Workbench and run:

CREATE DATABASE ai_agent_db
    CHARACTER SET utf8mb4
    COLLATE utf8mb4_unicode_ci;

USE ai_agent_db;

CREATE TABLE users (
    id         INT AUTO_INCREMENT PRIMARY KEY,
    name       VARCHAR(100) NOT NULL,
    email      VARCHAR(150),
    phone      VARCHAR(20),
    address    VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO users (name, email, phone, address) VALUES
('Kimthina Sok', 'kimthina@example.com', '012-345-678', 'Phnom Penh, Cambodia'),
('Jane Smith',   'jane@example.com',     '098-765-432', 'Bangkok, Thailand'),
('Bob Johnson',  'bob@example.com',      '081-234-567', 'Singapore');

Step 2 — Configure Environment Variables

  1. Copy .env.example to .env:
  2. Fill in your own values in .env:
  • AI_API_KEY — your Groq API key from https://console.groq.com
  • DB_PASSWORD — your MySQL root password
  • Other values as needed

Step 3 — Run the Project

  1. Make sure API key is set in application.properties
  2. In IntelliJ, click the ▶ Run button or press Shift + F10

Step 4 — Open the App

http://localhost:8080

How to Use

  1. Enter your system description in the Project Description field
  2. Click Generate and wait approximately 30–60 seconds
  3. View results from SA Agent, Dev Agent, and Spec Agent
  4. Click Download API Spec to download the .docx file

Example Descriptions

Build a contact list app to store and manage personal contacts.
Build a simple task tracker to create and manage daily tasks.
Build a note-taking app to save and organize personal notes.
Build a user management system with CRUD operations.

API Endpoints

Method URL Description
POST /api/v1/generate Run the full AI pipeline
POST /api/v1/download Download API Spec as .docx

POST /api/v1/generate

Request:

{
  "project_description": "Build a user management system"
}

Response:

{
  "success": true,
  "message": "Pipeline executed successfully",
  "sa_analysis": "...",
  "dev_code": "...",
  "api_spec": {
    "title": "User Management System",
    "version": "1.0.0",
    "endpoints": [...]
  }
}

POST /api/v1/download

Request: Send the api_spec object from the /generate response.

Response: .docx file download.


Tests

To run all tests in IntelliJ:

  1. Right-click the src/test/java folder
  2. Click Run 'All Tests'

Or right-click any individual test class and click Run.

Test Class Tests Coverage
SaAgentServiceTest 3 SA Agent behavior
DevAgentServiceTest 3 Dev Agent behavior
SpecAgentServiceTest 4 Spec Agent + JSON parsing
PipelineServiceTest 6 Full pipeline flow
PipelineControllerTest 2 HTTP endpoints
DocxGeneratorServiceTest 8 Document generation
Total 26

Limitations

  • Currently reads only from the users table — The goal of this project is to prove that the AI Agent Pipeline concept works end-to-end. A single table is sufficient to demonstrate the full pipeline from database reading to API Specification generation.

  • Supports MySQL only — MySQL was chosen as the primary database for this proof of concept as it is the most commonly used database.

  • Generates API Spec for basic CRUD operations — CRUD operations cover the most common use case for REST APIs and are sufficient to validate the pipeline's capability to produce a professional API Specification document.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages