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 lockingBaseService/BaseServiceImpl- Generic service layer with cachingBaseController/BaseControllerImpl- REST endpoints with HATEOASBaseMapper- MapStruct interface for entity-DTO mappingBaseDTO/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
deletedflag - 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
TenantContextandTenantAware - 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:
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/products | List all (with pagination) |
| GET | /api/products/{id} | Get by ID |
| GET | /api/products/search | Dynamic filtering |
| POST | /api/products | Create |
| 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/batch | Bulk create |
| PUT | /api/products/batch | Bulk update |
| DELETE | /api/products/batch | Bulk delete |
| GET | /api/products/export | Export 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
| Operator | SQL Equivalent | Example |
|---|---|---|
eq | = | ?name[eq]=iPhone |
ne | != | ?status[ne]=DELETED |
gt | > | ?price[gt]=100 |
gte | >= | ?price[gte]=100 |
lt | < | ?price[lt]=1000 |
lte | <= | ?price[lte]=1000 |
like | LIKE | ?name[like]=iPhone |
in | IN | ?id[in]=1,2,3 |
nin | NOT IN | ?status[nin]=DRAFT,DELETED |
isnull | IS NULL | ?deletedAt[isnull]=true |
notnull | IS NOT NULL | ?deletedAt[notnull]=true |
between | BETWEEN | ?price[between]=100,1000 |