Skip to main content

Getting Started

This guide will help you install Radish CLI and create your first generated datalayer.

Installation

Install Radish CLI globally via npm:

npm install -g radish-cli

Or use it locally in your project:

npm install --save-dev radish-cli

Quick Start

1. Create a Blueprint

Create a blueprint file that defines your entities:

blueprints/app.types.json

{
"version": 1,
"defaults": {
"owned": true,
"timestamps": true,
"adminRole": "ADMIN"
},
"entities": {
"Task": {
"label": "Task",
"description": "A todo task",
"plural": "tasks",
"fields": {
"title": {
"type": "string",
"required": true,
"label": "Title"
},
"description": {
"type": "string",
"optional": true,
"label": "Description"
},
"status": {
"type": "enum",
"values": ["todo", "in_progress", "done"],
"default": "todo",
"label": "Status"
},
"dueDate": {
"type": "isoDate",
"optional": true,
"label": "Due Date"
}
},
"filters": ["status", "dueDate"]
}
}
}

2. Generate the Datalayer

Run the generator:

radish-cli create datalayer . --schema blueprints/app.types.json

This creates:

.radish/
├── MANIFEST.json # Generation metadata & blueprint hash
├── README.md # Generated code guide
└── lib/
└── datalayer/
├── MANIFEST.json # Datalayer-specific metadata
├── package.json # @generated/datalayer package
├── contracts/ # Zod schemas & TypeScript types
├── core/ # Core infrastructure
│ ├── models/ # MongoDB models
│ └── repos/ # Data access layer
├── routes/ # HTTP API routes
├── services/ # Business logic
└── docs/ # Generated API documentation

Key files:

  • MANIFEST.json - Tracks blueprint hash for verification
  • package.json - Self-contained dependencies
  • See [Generated Code Overview]../datalayer/index.md) for details

3. Use the Generated Code

Import and use the generated services:

import { TaskService } from '@generated/datalayer/services';
import type { Task, CreateTask } from '@generated/datalayer/contracts';
import { createTaskSchema } from '@generated/datalayer/contracts';

// Create a task
const task = await TaskService.create(ctx, {
title: 'Complete documentation',
status: 'todo',
dueDate: new Date().toISOString()
});

// Validate input
const input = createTaskSchema.parse(userInput);

// Query tasks
const tasks = await TaskService.find(ctx, {
status: 'in_progress',
limit: 10
});

Explore with the Console

Launch the interactive console to explore your datalayer:

radish-cli console .

The console provides:

  • Entity browser
  • Record inspection
  • Schema metadata viewer
  • Query testing

Next Steps