Skip to main content
Learn how to automatically generate list and form views for admin pages with Sonamu’s scaffolding system.

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:
  1. Time waste: Writing list, create, edit pages all by hand
  2. Lack of consistency: Different styles and structures per developer
  3. Hard to maintain: Need to modify all views when entity changes
  4. Prone to mistakes: Missing fields, wrong types, missing validation
  5. Boilerplate: Repetitive code for tables, forms, buttons
Example: Pages needed for a single User entity
Each page requires 100-200+ lines of code, and this must be repeated for every entity.

Solution: Auto Scaffolding

Sonamu automatically generates admin page views based on Entity definitions. Benefits:
  1. ✨ Instant generation: Generate views with just clicks in web UI
  2. ✨ Type safe: Entity types directly reflected in components
  3. ✨ Consistent UI: Unified design system
  4. ✨ Best practices: Proven patterns applied
  5. ✨ Customizable: Modify only necessary parts after generation
Sonamu’s scaffolding philosophy:
β€œ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.
Generating views in web UI:
  1. Access Sonamu UI
  2. Select β€œScaffold” menu
  3. Select Entity (e.g., User)
  4. Click β€œGenerate View List” button β†’ index.tsx generated
  5. Click β€œGenerate View Form” button β†’ form.tsx generated
CLI commands are currently disabled. View generation is only available through the Sonamu web UI.

Generated File Structure

Actually generated files:
  • index.tsx: Page with list table directly included
  • form.tsx: Create and edit combined into one form
Note: - Separate component files (UserTable.tsx, UserForm.tsx) are not generated - Detail page ([id].tsx) is not auto-generated - All logic is integrated into two page files

Generated View Structure

List Page (index.tsx)

Displays list in a table and provides pagination and search functionality.
Features:
  • 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.
Features:
  • 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):
Sonamu structure (simple):
Benefits of integrated structure:
  • Minimized file count
  • Less navigation between files
  • Easy maintenance
  • High code cohesion

Routing Pattern

Create/edit mode is distinguished by URL parameters.

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

This allows tracking customization history.

2. Extract Common Logic into Hooks

3. Manage Styles Globally

Use consistent styles across all admin pages.

Cautions

Cautions when using View Scaffolding: 1. Only available via web UI (CLI commands disabled) 2. Only index.tsx, form.tsx generated (no separate components) 3. Detail page needs to be added manually 4. Regenerating will lose customizations (Git commit required) 5. Consider separating components as needed after generation

Next Steps

Custom Components

Component customization

ID Async Select

Relational data selection

Search Input

Search component

Using Services

Service integration