Skip to main content

Overview

The @riktajs/cli package provides a command-line interface for creating and managing Rikta projects.

Installation​

Install globally:

npm install -g @riktajs/cli

Or use with npx:

npx @riktajs/cli <command>

Quick Start​

Create a new Rikta project:

rikta new my-app
cd my-app
npm run dev

That's it! Your new Rikta application is running at http://localhost:3000.

Available Commands​

CommandDescription
new <name>Create a new Rikta project
devStart in development mode with hot reload
buildBuild the project for production

Project Templates​

The CLI provides multiple templates for different use cases:

TemplateDescription
defaultStandard REST API with controllers and services
mcp-serverMCP server for AI assistant integration

When creating a new project without specifying a template, you'll see an interactive prompt to choose one.

Project Structure​

Default Template​

When you create a new project with the default template:

my-app/
├── src/
│ ├── controllers/
│ │ └── app.controller.ts
│ ├── services/
│ │ └── greeting.service.ts
│ └── index.ts
├── package.json
├── tsconfig.json
└── README.md

MCP Server Template​

When you create a new MCP server:

my-mcp/
├── src/
│ ├── mcp/
│ │ ├── index.ts
│ │ └── hello.service.ts
│ └── index.ts
├── package.json
├── tsconfig.json
└── README.md

Directory Structure Explained​

DirectoryPurpose
src/Source code
src/controllers/HTTP controllers
src/services/Business logic services
src/index.tsApplication entry point

Configuration​

The generated project includes these configuration files:

package.json​

{
"name": "my-app",
"version": "1.0.0",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js"
},
"dependencies": {
"@riktajs/core": "latest"
},
"devDependencies": {
"typescript": "^5.0.0",
"tsx": "^4.0.0"
}
}

tsconfig.json​

{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": ["src/**/*"]
}

Starter Application​

The generated application includes a simple example:

Entry Point (src/index.ts)​

import { Rikta } from '@riktajs/core';

async function bootstrap() {
const app = await Rikta.create({
port: 3000,
autowired: ['./src'],
});

await app.listen();
console.log('🚀 Server running at http://localhost:3000');
}

bootstrap();

Controller (src/controllers/app.controller.ts)​

import { Controller, Get, Autowired } from '@riktajs/core';
import { GreetingService } from '../services/greeting.service';

@Controller('/')
export class AppController {
@Autowired()
private greetingService!: GreetingService;

@Get()
hello() {
return this.greetingService.getGreeting();
}

@Get('/health')
health() {
return { status: 'ok' };
}
}

Service (src/services/greeting.service.ts)​

import { Injectable } from '@riktajs/core';

@Injectable()
export class GreetingService {
getGreeting(): string {
return 'Hello from Rikta! 👋';
}
}

Development Workflow​

Start Development Server​

npm run dev

This starts the server with hot reload - changes to your code are automatically detected and the server restarts.

Build for Production​

npm run build

Compiles TypeScript to JavaScript in the dist/ directory.

Run in Production​

npm run start

Runs the compiled application.

Next Steps​