Skip to content

What is APiGen?

APiGen is an enterprise-grade API generation framework for Java that dramatically accelerates API development by automating repetitive tasks while maintaining full flexibility for customization.

The Problem

Building REST APIs involves significant boilerplate:

  • Entity classes with JPA annotations
  • DTOs for request/response
  • Mappers between entities and DTOs
  • Repository interfaces
  • Service layer with business logic
  • Controllers with CRUD endpoints
  • Validation, error handling, pagination
  • Security configuration
  • Tests for all layers

This typically takes weeks of repetitive work.

The Solution

APiGen provides two approaches:

1. Code Generation

Generate complete project structures from SQL schemas:

bash
./gradlew :generator:cli:run --args="generate \
  --input schema.sql \
  --language java-spring \
  --package com.example.api \
  --output ./my-api"

This generates:

  • Entities with proper JPA mappings
  • DTOs (request/response)
  • MapStruct mappers
  • Spring Data repositories
  • Service interfaces and implementations
  • REST controllers
  • Flyway migrations
  • Unit and integration tests

2. Runtime Library

Use APiGen as a dependency for instant CRUD:

gradle
dependencies {
    implementation 'com.jnzader:apigen-core:1.0.0-SNAPSHOT'
}
java
@RestController
@RequestMapping("/api/products")
public class ProductController extends CrudController<Product, Long> {
    // All CRUD endpoints are automatic
}

Key Features

Multi-Language Support

Generate APIs in 12+ languages:

LanguageFrameworks
JavaSpring Boot, Quarkus
KotlinSpring Boot
PythonFastAPI, Django
TypeScriptNestJS, Express
C#ASP.NET Core
GoChi, Gin
PHPLaravel
RustAxum

Enterprise Features

  • Auditing: Full change history with Hibernate Envers
  • Soft Delete: Logical deletion with restore capability
  • Multi-tenancy: Tenant isolation out of the box
  • Caching: Caffeine + Redis multi-level cache
  • Rate Limiting: Per-endpoint throttling

Observability

  • OpenTelemetry distributed tracing
  • Prometheus metrics
  • Structured JSON logging
  • Health checks for Kubernetes

Multiple Protocols

  • REST with HATEOAS
  • GraphQL with schema stitching
  • gRPC for inter-service communication

Architecture

APiGen follows a modular architecture:

┌─────────────────────────────────────────────────────┐
│                    GENERATORS                        │
│  ┌──────────┐  ┌──────────┐  ┌───────────────┐    │
│  │   CLI    │  │  Server  │  │  IDE Plugins  │    │
│  └────┬─────┘  └────┬─────┘  └───────┬───────┘    │
│       └─────────────┼────────────────┘             │
│                     │                               │
│              ┌──────▼──────┐                       │
│              │   Codegen   │                       │
│              │   Engine    │                       │
│              └──────┬──────┘                       │
└─────────────────────┼───────────────────────────────┘

┌─────────────────────▼───────────────────────────────┐
│                 CORE LIBRARIES                       │
│  ┌──────────┐  ┌──────────┐  ┌────────────────┐   │
│  │   Core   │  │ Security │  │   Exceptions   │   │
│  └──────────┘  └──────────┘  └────────────────┘   │
└─────────────────────────────────────────────────────┘

┌─────────────────────▼───────────────────────────────┐
│                    FEATURES                          │
│  GraphQL │ gRPC │ Gateway │ Search │ Analytics │... │
└─────────────────────────────────────────────────────┘

When to Use APiGen

Use APiGen when you need:

  • Rapid API prototyping
  • Consistent project structure across teams
  • Enterprise features without custom implementation
  • Multi-language API generation
  • AI-assisted development (MCP server)

Consider alternatives when:

  • Building highly specialized APIs with unique patterns
  • Working with non-relational data models
  • Requiring extreme customization beyond templates

Next Steps

Released under the MIT License.