DartAPI CLI

DartAPI is a modular and developer-friendly CLI tool for building robust, typed REST APIs using the Dart language.
Rather than acting as a heavy, opinionated framework, DartAPI provides powerful code generation tools that let you build scalable backend applications with clean architecture, JWT authentication, request validation, and PostgreSQL/MySQL support.


πŸ“¦ What It Does

  • βœ… Project scaffolding (dartapi create)
  • βœ… Controller generation (dartapi generate controller)
  • βœ… Hot-reload style dev server with keyboard controls (dartapi run)
  • βœ… Integrated with:

πŸš€ Installation

Activate globally:

dart pub global activate dartapi

πŸ“ CLI Commands

dartapi create <project_name>

Creates a full DartAPI project with:

  • bin/main.dart
  • Controllers (UserController, AuthController, ProductController)
  • Middleware (logging, auth)
  • JWT setup with dartapi_auth
  • DB support with dartapi_db
  • DTOs and validation helpers
  • Auto schema definitions for future Swagger support

dartapi generate controller <Name>

Adds a controller to an existing DartAPI project:

dartapi generate controller Product

Generates lib/src/controllers/product_controller.dart with GET and POST methods and proper typing.


dartapi run --port <port>

Runs your DartAPI server using bin/main.dart.
You can control it interactively:

  • Type :q to quit
  • Type r to reload
dartapi run --port=8080

πŸ§ͺ Example Usage

dartapi create my_app
cd my_app
dart pub get
dartapi run --port=8080

Now open Postman and test /users or /auth/login.


🧱 Generated Project Structure

my_app/
β”œβ”€β”€ bin/
β”‚   └── main.dart
β”œβ”€β”€ lib/
β”‚   └── src/
β”‚       β”œβ”€β”€ core/           # Server/router setup
β”‚       β”œβ”€β”€ controllers/    # UserController, AuthController, etc.
β”‚       β”œβ”€β”€ dto/            # DTOs with schema
β”‚       β”œβ”€β”€ db/             # DB connection logic
β”‚       β”œβ”€β”€ middleware/     # Auth/logging middleware
β”‚       └── utils/          # Validation, helpers
β”œβ”€β”€ pubspec.yaml
└── analysis_options.yaml

βœ… Why Use DartAPI?

  • Minimal but powerful
  • Follows clean architecture principles
  • Type-safe routing using ApiRoute<ApiInput, ApiOutput>
  • Built-in JWT auth and DB integration
  • Ready to extend with OpenAPI/Swagger

πŸ“„ License

BSD 3-Clause License Β© 2025 Akash G Krishnan
LICENSE