LogoRevali

Overview

Constructs are the heart of Revali's extensibility. They are standalone Dart packages that provide code generation capabilities, allowing you to extend Revali's functionality or create entirely new features.

What is a Construct?#

A construct is a Dart package that provides code generation capabilities to Revali. Constructs are imported into your project, automatically detected by Revali, and used to generate code based on your annotations and route definitions.

When you run the dev command, constructs analyze your code and generate new files, assets, or code within their own dedicated directories:

.revali/
├── server/          # Built into Revali — generated for every project
├── client/          # Generated by client constructs
├── docker/          # Generated by docker constructs
└── <custom>/        # Generated by custom constructs
graph TD
    A[Your Code] --> B[Revali Dev Command]
    B --> C[Built-in Server Generation]
    B --> D[Build Constructs]
    B --> E[Generic Constructs]

    C --> F[.revali/server/]
    D --> G[.revali/build/]
    E --> H[.revali/custom/]

    F --> I[Running Server]
    G --> J[Deployment Assets]
    H --> K[Generated Code]

Server Generation#

Revali generates your server's code — request routing, middleware, and response handling — built in, with no separate construct to install or configure. See the Revali Server docs for the classes and annotations it generates from.

Types of Constructs#

Beyond server generation, Revali supports these types of constructs:

Build Constructs#

Build constructs generate code, assets, or files needed for deployment and production builds. They run during the build process and prepare your application for distribution.

Key characteristics:

  • Generate code in the .revali/build directory
  • Run during the build command (build command)
  • Prepare assets for deployment
  • Can generate client-side code, documentation, or deployment configs

Popular Build Constructs:

Opt-In Constructs#

Some constructs require explicit activation in your revali.yaml configuration file. This allows for:

  • Conditional activation: Enable constructs only when needed
  • Configuration control: Fine-tune construct behavior
  • Performance optimization: Avoid unnecessary code generation

Enabling Opt-In Constructs#

Add the construct to your revali.yaml file:

revali.yaml
constructs:
  - name: revali_docker
    enable: true
    config:
      # construct-specific configuration

Creating Custom Constructs#

Want to extend Revali with your own functionality? You can create custom constructs for:

  • Custom protocols: Support for WebSocket, gRPC, or other protocols
  • Framework integrations: Connect with specific databases or services
  • Code generation: Generate custom boilerplate or utilities
  • Deployment tools: Create deployment scripts or configurations

Finding Constructs#

Discover available constructs on pub.dev or browse the official constructs: