Skip to content

Commit d36e801

Browse files
committed
🚀 feat: Release v0.4.0 - Revolutionary Auto-CRUD System with @crud annotation, zero-boilerplate REST APIs, smart search, pagination, batch operations, and comprehensive developer experience
2 parents a171cf3 + 7b2d630 commit d36e801

File tree

18 files changed

+3640
-15
lines changed

18 files changed

+3640
-15
lines changed

README.md

Lines changed: 96 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
Jazzy is a lightweight web framework for Java. It provides a minimal and easy-to-understand API for developing fast web applications with a structure inspired by Laravel and Spring Boot.
44

5-
## 🚀 Latest Updates (v0.3.0)
5+
## 🚀 Latest Updates (v0.4.0)
66

7-
**NEW: Database Integration & ORM System!**
7+
**NEW: Auto-CRUD System with Zero Boilerplate!**
88

9-
Jazzy Framework 0.3 introduces comprehensive database integration with Spring Data JPA-like features:
9+
Jazzy Framework 0.4 introduces revolutionary auto-CRUD capabilities that generate complete REST APIs with just annotations:
1010

11-
- 🗄️ **Hibernate Integration**: Full JPA/Hibernate support with automatic configuration
12-
- 🔍 **Spring Data JPA-like Repositories**: Automatic query generation from method names
13-
- 📝 **Custom Query Support**: @Query annotation for HQL/JPQL and native SQL
14-
- 🔄 **Transaction Management**: Automatic transaction handling
15-
- 🏗️ **Entity Management**: Automatic entity discovery and configuration
16-
- 📊 **Connection Pooling**: HikariCP integration for production-ready performance
17-
- 🎯 **Method Name Parsing**: `findByEmail`, `countByActive`, `existsByName` etc.
18-
- **Performance Optimized**: Database-level filtering instead of memory operations
11+
- 🎯 **@Crud Annotation**: Automatically generates all CRUD endpoints (GET, POST, PUT, DELETE)
12+
- 🔍 **Smart Search**: Built-in search functionality with configurable fields
13+
- 📊 **Pagination Support**: Automatic pagination with customizable page sizes
14+
- 🔄 **Batch Operations**: Support for bulk create, update, delete operations
15+
- 🎨 **Method Override**: Custom logic with @CrudOverride annotation
16+
- 📝 **Standardized Responses**: Consistent API response format with ApiResponse
17+
- **Zero Configuration**: Complete REST API with 3 lines of code
18+
- 🔧 **Highly Configurable**: Fine-tune behavior with comprehensive options
1919

2020
## Version History
2121

2222
| Version | Release Date | Key Features |
2323
|---------|-------------|--------------|
24+
| **0.4.0** | 2025 | 🆕 **Auto-CRUD System** - @Crud annotation, zero-boilerplate REST APIs, automatic endpoint generation, search & pagination |
2425
| **0.3.0** | 2025 | 🆕 **Database Integration** - Hibernate/JPA, Spring Data JPA-like repositories, automatic query generation, transaction management |
2526
| **0.2.0** | 2025 | 🆕 **Dependency Injection System**, Spring-like annotations, automatic component discovery, lifecycle management |
2627
| **0.1.0** | 2025 | Core framework with routing, request/response handling, JSON utilities, validation system, metrics |
@@ -29,7 +30,7 @@ Jazzy Framework 0.3 introduces comprehensive database integration with Spring Da
2930

3031
| Planned Version | Features |
3132
|----------------|----------|
32-
| **0.4.0** | 🔐 **Security & Authentication** - JWT support, role-based access control, security filters |
33+
| **0.5.0** | 🔐 **Security & Authentication** - JWT support, role-based access control, security filters |
3334

3435
## Features
3536

@@ -59,8 +60,81 @@ Jazzy Framework 0.3 introduces comprehensive database integration with Spring Da
5960
- **Entity Discovery**: Automatic entity scanning and configuration
6061
- **Connection Pooling**: HikariCP for production-ready database connections
6162

63+
### Auto-CRUD System (v0.4+)
64+
- **@Crud Annotation**: Automatically generates complete REST APIs with zero boilerplate
65+
- **Instant Endpoints**: GET, POST, PUT, DELETE endpoints created automatically
66+
- **Smart Search**: Built-in search functionality with configurable searchable fields
67+
- **Pagination Support**: Automatic pagination with customizable page sizes and limits
68+
- **Batch Operations**: Bulk create, update, delete operations for performance
69+
- **Method Override**: Custom business logic with @CrudOverride annotation
70+
- **Standardized Responses**: Consistent ApiResponse format across all endpoints
71+
- **Highly Configurable**: Fine-tune behavior with extensive configuration options
72+
- **Validation Integration**: Built-in input validation for create/update operations
73+
- **Audit Logging**: Optional audit trail for all CRUD operations
74+
6275
## Quick Start
6376

77+
### Auto-CRUD Application (v0.4 style) - Recommended
78+
79+
```java
80+
// 1. Entity
81+
@Entity
82+
@Table(name = "products")
83+
public class Product {
84+
@Id
85+
@GeneratedValue(strategy = GenerationType.IDENTITY)
86+
private Long id;
87+
88+
private String name;
89+
private String description;
90+
private Double price;
91+
private Integer stock;
92+
93+
// getters and setters...
94+
}
95+
96+
// 2. Repository
97+
@Component
98+
public interface ProductRepository extends BaseRepository<Product, Long> {
99+
// Framework handles all basic operations automatically
100+
}
101+
102+
// 3. Controller - That's it! Full REST API with 3 lines!
103+
@Component
104+
@Crud(
105+
entity = Product.class,
106+
endpoint = "/api/products",
107+
enablePagination = true,
108+
enableSearch = true,
109+
searchableFields = {"name", "description"}
110+
)
111+
public class ProductController {
112+
// Instantly get all these endpoints:
113+
// GET /api/products - List all products (with pagination)
114+
// GET /api/products/{id} - Get product by ID
115+
// POST /api/products - Create new product
116+
// PUT /api/products/{id} - Update product
117+
// DELETE /api/products/{id} - Delete product
118+
// GET /api/products/search?name=laptop - Search products
119+
}
120+
121+
// 4. Main Application
122+
public class App {
123+
public static void main(String[] args) {
124+
Config config = new Config();
125+
Router router = new Router();
126+
127+
// No manual route registration needed!
128+
// @Crud annotation handles everything automatically
129+
130+
Server server = new Server(router, config);
131+
server.start(8080);
132+
}
133+
}
134+
```
135+
136+
**🎉 Result**: You now have a complete REST API with 5+ endpoints, pagination, search, and standardized responses!
137+
64138
### Database Application (v0.3 style)
65139

66140
```java
@@ -236,6 +310,9 @@ Complete documentation for Jazzy Framework is available on our GitHub Pages site
236310
- [Repository Pattern](https://canermastan.github.io/jazzy-framework/repositories)
237311
- [Query Methods](https://canermastan.github.io/jazzy-framework/query-methods)
238312

313+
**Auto-CRUD System (v0.4+):**
314+
- [CRUD Operations Guide](https://canermastan.github.io/jazzy-framework/crud)
315+
239316
## Development
240317

241318
Jazzy is developed with Maven. After cloning the project, you can use the following commands:
@@ -255,6 +332,9 @@ mvn exec:java -Dexec.mainClass="examples.di.App"
255332

256333
# Run the database example application (v0.3+)
257334
mvn exec:java -Dexec.mainClass="examples.database.DatabaseExampleApp"
335+
336+
# Run the CRUD example application (v0.4+) - RECOMMENDED
337+
mvn exec:java -Dexec.mainClass="examples.simple_crud.SimpleCrudApp"
258338
```
259339

260340
## Project Structure
@@ -272,6 +352,7 @@ mvn exec:java -Dexec.mainClass="examples.database.DatabaseExampleApp"
272352
- `Request.java`: Request handling
273353
- `Response.java`: Response building
274354
- `ResponseFactory.java`: Factory for creating responses
355+
- `ApiResponse.java`: Standardized API response format (v0.4+)
275356
- `JSON.java`: JSON creation utilities
276357
- `validation/`: Validation system
277358
- `di/`: Dependency injection system (v0.2+)
@@ -287,13 +368,15 @@ mvn exec:java -Dexec.mainClass="examples.database.DatabaseExampleApp"
287368
- `HibernateConfig.java`: Hibernate/JPA configuration
288369
- `EntityScanner.java`: Automatic entity discovery
289370
- `RepositoryScanner.java`: Repository interface scanning
290-
- `annotations/`: Database annotations (@Query, @Modifying, @QueryHint)
371+
- `CrudProcessor.java`: Auto-CRUD system processor (v0.4+)
372+
- `annotations/`: Database annotations (@Query, @Modifying, @QueryHint, @Crud, @CrudOverride)
291373
- `controllers/`: System controllers
292374
- `MetricsController.java`: Metrics reporting
293375
- `examples/`: Example applications
294376
- `basic/`: Basic framework usage examples
295377
- `di/`: Dependency injection examples (v0.2+)
296378
- `database/`: Database integration examples (v0.3+)
379+
- `simple_crud/`: Auto-CRUD system examples (v0.4+)
297380

298381
## Tests
299382

docs-site/docs/crud.md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# 🚀 CRUD Operations
2+
3+
Get full REST API with **zero boilerplate code**! The `@Crud` annotation automatically generates all standard CRUD endpoints for your entities.
4+
5+
## ⚡ Quick Start
6+
7+
### 1. Create Your Entity
8+
```java
9+
@Entity
10+
@Table(name = "products")
11+
public class Product {
12+
@Id
13+
@GeneratedValue(strategy = GenerationType.IDENTITY)
14+
private Long id;
15+
16+
private String name;
17+
private String description;
18+
private Double price;
19+
private Integer stock;
20+
21+
// Constructors, getters, setters...
22+
}
23+
```
24+
25+
### 2. Create Repository
26+
```java
27+
@Component
28+
public interface ProductRepository extends BaseRepository<Product, Long> {
29+
// Framework handles all basic operations automatically
30+
}
31+
```
32+
33+
### 3. Add @Crud Controller
34+
```java
35+
@Component
36+
@Crud(
37+
entity = Product.class,
38+
endpoint = "/api/products",
39+
enablePagination = true,
40+
enableSearch = true,
41+
searchableFields = {"name", "description"}
42+
)
43+
public class ProductController {
44+
// That's it! All CRUD endpoints are auto-generated
45+
}
46+
```
47+
48+
### 4. Start Using Your API
49+
50+
**🎉 You instantly get these endpoints:**
51+
52+
| Method | Endpoint | Description |
53+
|--------|----------|-------------|
54+
| `GET` | `/api/products/{id}` | Get product by ID |
55+
| `POST` | `/api/products` | Create new product |
56+
| `PUT` | `/api/products/{id}` | Update product |
57+
| `DELETE` | `/api/products/{id}` | Delete product |
58+
| `GET` | `/api/products/search?name=laptop` | Search products |
59+
60+
## 📋 @Crud Configuration
61+
62+
```java
63+
@Crud(
64+
entity = Product.class, // Your JPA entity
65+
endpoint = "/api/products", // Base URL path
66+
enablePagination = true, // Adds ?page=1&size=10 support
67+
enableSearch = true, // Adds /search endpoint
68+
searchableFields = {"name", "description"}, // Fields to search in
69+
enableExists = true // Adds /exists/{id} endpoint
70+
)
71+
```
72+
73+
### Configuration Options
74+
75+
| Option | Default | Description |
76+
|--------|---------|-------------|
77+
| `entity` | **Required** | The JPA entity class |
78+
| `endpoint` | **Required** | Base URL path for endpoints |
79+
| `enablePagination` | `false` | Enable pagination support |
80+
| `enableSearch` | `false` | Enable search functionality |
81+
| `searchableFields` | `{}` | Fields to search in (when search enabled) |
82+
| `enableExists` | `false` | Enable exists check endpoint |
83+
84+
## 🎨 Customizing Methods
85+
86+
Need custom logic? Simply override any method:
87+
88+
```java
89+
@Component
90+
@Crud(entity = Product.class, endpoint = "/api/products")
91+
public class ProductController {
92+
93+
private final ProductRepository productRepository;
94+
95+
public ProductController(ProductRepository productRepository) {
96+
this.productRepository = productRepository;
97+
}
98+
99+
// Override findAll to show only in-stock products
100+
@CrudOverride(value = "Returns only in-stock products")
101+
public Response findAll(Request request) {
102+
var inStockProducts = productRepository.findAll().stream()
103+
.filter(product -> product.getStock() > 0)
104+
.toList();
105+
return Response.json(ApiResponse.success("In-stock products retrieved", inStockProducts));
106+
}
107+
108+
// All other methods (findById, create, update, delete) remain auto-generated
109+
}
110+
```
111+
112+
### Manual Route Registration for Overrides
113+
114+
When you override a method, register its route manually:
115+
116+
```java
117+
public static void main(String[] args) {
118+
Router router = new Router();
119+
120+
// Manual registration for overridden methods
121+
router.GET("/api/products", "findAll", ProductController.class);
122+
123+
Server server = new Server(router, config);
124+
server.start(8080);
125+
}
126+
```
127+
128+
## 🧪 Testing Your API
129+
130+
### Create Product
131+
```bash
132+
curl -X POST -H "Content-Type: application/json" \
133+
-d '{"name":"Gaming Laptop","description":"High-performance laptop","price":1299.99,"stock":5}' \
134+
"http://localhost:8080/api/products"
135+
```
136+
137+
### Get All Products
138+
```bash
139+
curl "http://localhost:8080/api/products"
140+
```
141+
142+
### Get Product by ID
143+
```bash
144+
curl "http://localhost:8080/api/products/1"
145+
```
146+
147+
### Search Products
148+
```bash
149+
curl "http://localhost:8080/api/products/search?name=laptop"
150+
```
151+
152+
### Update Product
153+
```bash
154+
curl -X PUT -H "Content-Type: application/json" \
155+
-d '{"name":"Updated Laptop","description":"Updated description","price":1199.99,"stock":3}' \
156+
"http://localhost:8080/api/products/1"
157+
```
158+
159+
### Delete Product
160+
```bash
161+
curl -X DELETE "http://localhost:8080/api/products/1"
162+
```
163+
164+
## 📊 Response Format
165+
166+
All CRUD endpoints return standardized responses:
167+
168+
```json
169+
{
170+
"success": true,
171+
"message": "Product retrieved successfully",
172+
"data": {
173+
"id": 1,
174+
"name": "Gaming Laptop",
175+
"description": "High-performance laptop",
176+
"price": 1299.99,
177+
"stock": 5
178+
},
179+
"timestamp": "2023-12-07T10:30:00"
180+
}
181+
```
182+
183+
## 🔧 Requirements
184+
185+
Before using `@Crud`, ensure you have:
186+
187+
1. **Entity Class**: JPA annotated entity
188+
2. **Repository**: Interface extending `BaseRepository<Entity, ID>`
189+
3. **Component Registration**: Repository marked with `@Component`
190+
4. **Database Configuration**: Hibernate/JPA properly configured
191+
192+
## 💡 Best Practices
193+
194+
### ✅ Do's
195+
- Use meaningful entity and endpoint names
196+
- Enable search for user-facing entities
197+
- Override methods only when you need custom logic
198+
- Use `@CrudOverride` for documentation
199+
200+
### ❌ Don'ts
201+
- Don't forget manual route registration for overrides
202+
- Don't enable unnecessary features (keeps API clean)
203+
- Don't override methods unless you need custom behavior
204+
205+
## 🔍 Complete Example
206+
207+
Check out the [Simple CRUD Example](https://github.com/your-repo/jazzy-framework/tree/main/src/main/java/examples/simple_crud) for a working implementation with:
208+
209+
- ✅ Product entity with validation
210+
- ✅ Repository implementation
211+
- ✅ Controller with one custom method
212+
- ✅ Complete test commands
213+
- ✅ Real-world usage patterns
214+
215+
---
216+
217+
**🎯 Result**: With just a few annotations, you get a complete REST API with all CRUD operations, search, pagination, and standardized responses!

0 commit comments

Comments
 (0)