View Scaffolding Overview
Auto Generation
List/Form views Generate via web UI
Type Safe
Entity based Compile-time validation
Customizable
Modify after generation Full control
Consistency
Unified UI/UX Best practices
What is View Scaffolding?
Problem: Repetitive CRUD View Writing
In traditional development, you have to manually write similar CRUD screens repeatedly for each entity. Problems with manual writing:- Time waste: Writing list, create, edit pages all by hand
- Lack of consistency: Different styles and structures per developer
- Hard to maintain: Need to modify all views when entity changes
- Prone to mistakes: Missing fields, wrong types, missing validation
- Boilerplate: Repetitive code for tables, forms, buttons
Solution: Auto Scaffolding
Sonamu automatically generates admin page views based on Entity definitions. Benefits:- β¨ Instant generation: Generate views with just clicks in web UI
- β¨ Type safe: Entity types directly reflected in components
- β¨ Consistent UI: Unified design system
- β¨ Best practices: Proven patterns applied
- β¨ Customizable: Modify only necessary parts after generation
β80% automatic, 20% customizationβMost CRUD functionality is auto-generated, and only special business logic needs additional implementation.
Running Scaffolding
Using Sonamu Web UI
Sonamu provides a web-based management UI.- Access Sonamu UI
- Select βScaffoldβ menu
- Select Entity (e.g., User)
- Click βGenerate View Listβ button β
index.tsxgenerated - Click βGenerate View Formβ button β
form.tsxgenerated
CLI commands are currently disabled. View generation is only available through the Sonamu web
UI.
Generated File Structure
- index.tsx: Page with list table directly included
- form.tsx: Create and edit combined into one form
Generated View Structure
List Page (index.tsx)
Displays list in a table and provides pagination and search functionality.- Pagination
- Search filter
- βCreate Newβ button
- βEditβ button (each row)
- Table directly included in page (no separate component)
Form Page (form.tsx)
Combines create and edit into one form.- Create/Edit integrated: Mode distinguished by URL parameter (
?id=) - Auto-loads existing data when editing
- Validation
- Button disabled while saving
- βBack to Listβ button
Generated File Characteristics
Integrated Structure
Sonamuβs scaffolding consists of minimal files: Traditional structure (complex):- Minimized file count
- Less navigation between files
- Easy maintenance
- High code cohesion
Routing Pattern
Customization
Modify After Generation
Generated files are fully modifiable.Separate into Components
You can manually separate components if needed:Add Detail Page
Add detail page manually since itβs not auto-generated:Best Practices
1. Git Commit Immediately After Generation
2. Extract Common Logic into Hooks
3. Manage Styles Globally
Cautions
Next Steps
Custom Components
Component customization
ID Async Select
Relational data selection
Search Input
Search component
Using Services
Service integration