@@ -62,19 +62,56 @@ Copy-paste from existing code. Fix the class names. Fix the imports. Miss someth
6262haft generate resource User
6363```
6464
65- Done. Haft generates all 8 files (Entity, DTO, Repository, Mapper, Controller) instantly . Properly structured. Following your project's conventions.
65+ Done. All 8 files. Properly structured. ** Matching your project's existing patterns. **
6666
6767<p align =" center " >
6868 <img src =" assets/demo.gif " alt =" Haft Demo " width =" 700 " />
6969</p >
7070
71+ ## Intelligent Code Generation
72+
73+ Haft doesn't just generate boilerplate — it ** learns from your codebase** and generates code that matches your existing conventions.
74+
75+ ### What Haft Detects Automatically
76+
77+ | Detection | What It Does |
78+ | -----------| --------------|
79+ | ** Architecture Pattern** | Layered, Feature/Package-by-Feature, Hexagonal, Clean, Modular |
80+ | ** Feature Style** | Flat (` user/UserController.java ` ) vs Nested (` user/controller/UserController.java ` ) |
81+ | ** DTO Naming** | ` UserRequest ` /` UserResponse ` vs ` UserDTO ` |
82+ | ** ID Type** | ` Long ` vs ` UUID ` with correct annotations |
83+ | ** Lombok Usage** | ` @Data ` , ` @Builder ` , ` @NoArgsConstructor ` , ` @AllArgsConstructor ` |
84+ | ** Mapper Type** | MapStruct, ModelMapper, or manual mapping |
85+ | ** Base Entity** | Extends your ` BaseEntity ` if detected |
86+ | ** Validation Style** | Jakarta (` jakarta.validation ` ) vs Javax (` javax.validation ` ) |
87+ | ** Swagger/OpenAPI** | Adds ` @Operation ` , ` @Tag ` annotations if detected |
88+ | ** Database Type** | JPA, MongoDB, Cassandra, R2DBC |
89+
90+ ### Profile Caching
91+
92+ First run scans your project and caches the profile to ` .haft/profile.yaml ` . Subsequent runs are ** instant** .
93+
94+ ``` bash
95+ # First run (~200ms) - scans and caches
96+ haft generate resource User
97+
98+ # Second run (~10ms) - uses cache
99+ haft generate resource Product
100+
101+ # Force re-scan if needed
102+ haft generate resource Order --refresh
103+ ```
104+
71105## Why Haft?
72106
73107| | Spring Initializr | Haft |
74108| ---| ---| ---|
75109| Project Bootstrap | ✅ | ✅ |
76110| Works Offline | ❌ | ✅ |
77111| Resource Generation | ❌ | ✅ |
112+ | ** Intelligent Detection** | ❌ | ✅ |
113+ | ** Architecture Aware** | ❌ | ✅ |
114+ | ** Test Generation** | ❌ | ✅ |
78115| Dependency Management | ❌ | ✅ |
79116| Interactive TUI | ❌ | ✅ |
80117| Lifecycle Companion | ❌ | ✅ |
@@ -191,38 +228,71 @@ An interactive wizard guides you through project setup:
191228? Dependencies: web, data-jpa, lombok, validation
192229```
193230
194- ### Non-Interactive Mode
195-
196- Perfect for CI/CD and scripting:
231+ ### Generate Resources (Smart Mode)
197232
198233``` bash
199- haft init my-service \
200- --group com.example \
201- --java 21 \
202- --deps web,data-jpa,lombok \
203- --no-interactive
234+ cd my-app
235+
236+ # Generate a complete CRUD resource
237+ # Haft automatically detects your architecture and conventions
238+ haft generate resource User
239+ ```
240+
241+ ** Generated files match your project structure:**
242+
243+ ```
244+ # If your project uses Feature/Package-by-Feature (flat style):
245+ user/
246+ ├── UserController.java
247+ ├── UserService.java
248+ ├── UserServiceImpl.java
249+ ├── UserRepository.java
250+ ├── User.java
251+ ├── UserMapper.java
252+ └── dto/
253+ ├── UserRequest.java
254+ └── UserResponse.java
255+
256+ # If your project uses Layered architecture:
257+ controller/UserController.java
258+ service/UserService.java
259+ service/impl/UserServiceImpl.java
260+ repository/UserRepository.java
261+ entity/User.java
262+ dto/UserRequest.java
263+ dto/UserResponse.java
264+ mapper/UserMapper.java
204265```
205266
206- ### Generate Resources
267+ ### Generate with Tests
207268
208269``` bash
209- # Generate a complete CRUD resource (9 files)
210- haft generate resource User # haft g r User
270+ # Generate resource + unit/integration tests
271+ haft generate resource Product
211272
212- # Or generate individual components
273+ # Skip test generation
274+ haft generate resource Payment --skip-tests
275+ ```
276+
277+ ** Generated test files:**
278+
279+ ```
280+ # ServiceTest - Unit tests with Mockito
281+ # ControllerTest - Integration tests with MockMvc
282+ # RepositoryTest - Integration tests with @DataJpaTest
283+ # EntityTest - Unit tests for entity
284+ ```
285+
286+ ### Individual Generators
287+
288+ ``` bash
213289haft generate controller Product # haft g co Product
214290haft generate service Order # haft g s Order
215291haft generate repository Payment # haft g repo Payment
216292haft generate entity Customer # haft g e Customer
217293haft generate dto Invoice # Request + Response DTOs
218294```
219295
220- All generators auto-detect your project configuration from ` pom.xml ` or ` build.gradle ` :
221- - ** Base package** - No need to specify, detected automatically
222- - ** Lombok** - Adds ` @Getter ` , ` @Setter ` , ` @Builder ` if present
223- - ** JPA** - Generates Entity/Repository with proper annotations
224- - ** Validation** - Adds ` @Valid ` to controller methods
225-
226296### Manage Dependencies
227297
228298``` bash
@@ -232,30 +302,49 @@ haft add
232302# Browse by category
233303haft add --browse
234304
235- # Add using shortcuts
305+ # Add using shortcuts (330+ available)
236306haft add lombok validation jwt
237307
238- # Add using Maven coordinates (auto-verified on Maven Central )
308+ # Add using Maven coordinates (auto-verified)
239309haft add org.mapstruct:mapstruct
240310
241311# Remove dependencies
242312haft remove lombok
243313haft remove # Interactive picker
314+ ```
244315
245- # List available shortcuts (330+)
246- haft add --list
316+ ### Development Workflow
317+
318+ ``` bash
319+ haft dev serve # Start with hot-reload
320+ haft dev build # Build project
321+ haft dev test # Run tests
322+ haft dev clean # Clean artifacts
323+ ```
324+
325+ ### Project Analysis
326+
327+ ``` bash
328+ haft info # Project information
329+ haft info --loc # With lines of code
330+ haft routes # List REST endpoints
331+ haft routes --files # With file locations
332+ haft stats # Code statistics
333+ haft stats --cocomo # COCOMO cost estimates
247334```
248335
249336## Features
250337
338+ - ** Intelligent Detection** — Learns from your codebase patterns
339+ - ** Architecture Aware** — Supports Layered, Feature, Hexagonal, Clean, Modular
340+ - ** Test Generation** — Unit and integration tests with Mockito, MockMvc
341+ - ** Profile Caching** — Instant subsequent runs with ` .haft/profile.yaml `
251342- ** Interactive TUI** — Beautiful terminal interface with keyboard navigation
252343- ** Offline First** — No internet required, all metadata bundled
253- - ** Spring Initializr Parity** — All official starters and dependencies
254344- ** Smart Defaults** — Sensible defaults that match industry standards
255345- ** Back Navigation** — Made a mistake? Press ` Esc ` to go back
256346- ** Dependency Search** — Find any dependency with ` / `
257347- ** Maven Central Verification** — Auto-verify and fetch latest versions
258- - ** Git Integration** — Initialize repository on project creation
259348
260349## Keyboard Shortcuts
261350
@@ -269,18 +358,31 @@ haft add --list
269358| ` Tab ` | Next category |
270359| ` 0-9 ` | Jump to category |
271360
361+ ## Supported Architectures
362+
363+ Haft automatically detects and generates code for:
364+
365+ | Architecture | Description |
366+ | --------------| -------------|
367+ | ** Layered** | Traditional ` controller/ ` , ` service/ ` , ` repository/ ` , ` entity/ ` |
368+ | ** Feature** | Package-by-feature with nested or flat structure |
369+ | ** Hexagonal** | Ports & Adapters with ` adapter/ ` , ` application/ ` , ` domain/ ` |
370+ | ** Clean** | Clean Architecture with ` usecase/ ` , ` gateway/ ` , ` infrastructure/ ` |
371+ | ** Modular** | Modular monolith with ` api/ ` , ` internal/ ` |
372+
272373## Roadmap
273374
274375- [x] Project initialization wizard
275376- [x] All Spring Initializr dependencies
276- - [x] Maven support
277- - [x] Offline operation
377+ - [x] Maven & Gradle support
378+ - [x] Intelligent architecture detection
379+ - [x] Test generation
380+ - [x] Profile caching
278381- [x] ` haft generate resource ` — Full CRUD generation
279- - [x] ` haft generate controller|service|entity|repository|dto ` — Individual generators
280- - [x] ` haft add ` — Dependency management with TUI picker
281- - [x] ` haft remove ` — Remove dependencies with TUI picker
382+ - [x] ` haft add ` / ` haft remove ` — Dependency management
383+ - [x] ` haft dev ` — Development commands
384+ - [x] ` haft info ` / ` haft routes ` / ` haft stats ` — Project analysis
282385- [x] Shell completions (bash, zsh, fish, powershell)
283- - [x] Gradle support (Groovy & Kotlin DSL)
284386- [ ] Neovim integration
285387- [ ] VS Code extension
286388- [ ] IntelliJ plugin
0 commit comments