Skip to content

APiGen Core

Enterprise-grade foundation library for building REST APIs with Spring Boot, eliminating boilerplate code through powerful base classes and architectural patterns.

Overview

Building REST APIs typically requires writing repetitive code for every entity:

  • Manual CRUD implementations (create, read, update, delete)
  • Repeated filtering and pagination logic
  • Duplicate validation and error handling
  • Boilerplate service and controller layers
  • Manual caching and performance optimization

APiGen Core solves this by providing battle-tested base classes that:

  • Generate 12+ REST endpoints automatically (CRUD + search + batch + export)
  • Eliminate 70-80% of boilerplate code (focus on business logic, not infrastructure)
  • Provide enterprise patterns out-of-the-box (CQRS, Event Sourcing, Multi-Tenancy)
  • Include production-ready features (caching, monitoring, soft delete, auditing)
  • Scale from prototype to enterprise (same code patterns, no rewrites)

Result: Build production-ready APIs in minutes, not days.

🎯 Core Features

Base Classes

  • Base - Abstract entity with soft delete, auditing, optimistic locking
  • BaseService / BaseServiceImpl - Generic service layer with caching
  • BaseController / BaseControllerImpl - REST endpoints with HATEOAS
  • BaseMapper - MapStruct interface for entity-DTO mapping
  • BaseDTO / BaseDTOValidated - Base DTOs with validation support

Data Operations

  • Dynamic filtering with 12+ operators (eq, ne, gt, lt, like, in, etc.)
  • Cursor-based pagination (CursorPageRequest, CursorPageResponse)
  • Soft delete - Logical deletion with deleted flag
  • Batch operations - Bulk create, update, delete
  • Bulk import/export - CSV and Excel support

Architecture Patterns

  • CQRS - Command Query Responsibility Segregation (QueryBus, CommandBus)
  • Event Sourcing - Event store with aggregate reconstruction
  • Domain Events - Created, Updated, Deleted, Restored events

Enterprise Features

  • Multi-Tenancy - Tenant isolation with TenantContext and TenantAware
  • Webhooks - HTTP callbacks for entity events
  • Server-Sent Events (SSE) - Real-time updates with automatic heartbeat
  • API Versioning - URL, header, and media type versioning
  • Feature Flags - Togglz integration for feature management

Performance & Observability

  • Caching - Caffeine (in-memory) and Redis (distributed)
  • ETag support - Conditional requests for optimized bandwidth
  • SLO monitoring - Service Level Objectives tracking
  • Content negotiation - JSON and XML support

📦 Installation

Gradle (Kotlin DSL)

kotlin
dependencies {
    implementation("com.jnzader.apigen:apigen-core:1.0.0-SNAPSHOT")
}

Maven

xml
<dependency>
    <groupId>com.jnzader</groupId>
    <artifactId>apigen-core</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>

🚀 Quick Start

Automatic Endpoints Generated

Your ProductController now has:

MethodEndpointDescription
GET/api/productsList all (with pagination)
GET/api/products/{id}Get by ID
GET/api/products/searchDynamic filtering
POST/api/productsCreate
PUT/api/products/{id}Update
PATCH/api/products/{id}Partial update
DELETE/api/products/{id}Soft delete
POST/api/products/restore/{id}Restore deleted
POST/api/products/batchBulk create
PUT/api/products/batchBulk update
DELETE/api/products/batchBulk delete
GET/api/products/exportExport CSV/Excel

All with zero additional code!

📊 Real-World Examples

java
// Entity
@Entity
public class Product extends Base {
    private String name;
    private BigDecimal price;
}

// Repository
public interface ProductRepository extends BaseRepository<Product, Long> {}

// Service
@Service
public class ProductService extends BaseServiceImpl<Product, Long> {
    @Override
    protected Class<Product> getEntityClass() { return Product.class; }

    @Override
    public String getEntityName() { return "Product"; }
}

// Controller - automatically gets 12+ endpoints
@RestController
@RequestMapping("/api/products")
public class ProductController extends BaseControllerImpl<Product, ProductDTO, Long> {
    public ProductController(ProductService service, ProductMapper mapper,
                            ProductResourceAssembler assembler) {
        super(service, mapper, assembler);
    }
}

📖 API Reference

Filtering Operators

OperatorSQL EquivalentExample
eq=?name[eq]=iPhone
ne!=?status[ne]=DELETED
gt>?price[gt]=100
gte>=?price[gte]=100
lt<?price[lt]=1000
lte<=?price[lte]=1000
likeLIKE?name[like]=iPhone
inIN?id[in]=1,2,3
ninNOT IN?status[nin]=DRAFT,DELETED
isnullIS NULL?deletedAt[isnull]=true
notnullIS NOT NULL?deletedAt[notnull]=true
betweenBETWEEN?price[between]=100,1000

Released under the MIT License.