This content is currently WIP. Diagrams, content, and structure are subject to change.
The C3 AI Type System is a foundational component of the platform’s model-driven architecture. This powerful system provides a comprehensive framework for defining data structures, managing relationships between entities, and enforcing business rules within applications—enabling developers to create sophisticated, data-driven solutions with remarkable efficiency.

What is the C3 AI Type System?

The C3 AI Type System is a powerful abstraction layer that lets you define domain models that represent real-world entities and their relationships. Instead of designing software around specific data sources or manufacturers, you define abstract models that standardize how applications interact with real-world objects. For example, rather than writing separate code for different wind turbine brands, you can work with a unified wind turbine model. This approach decouples application logic from data sources, making it easier to integrate new systems and extend functionality without major rewrites. C3 Turbine Example The model-driven architecture is made possible by employing a domain-specific language that structures how you program around the models that are predefined in the C3 AI Type System.

Core concepts

The C3 AI Type System is built around several core concepts:

Types

Classes that define the structure and behavior of domain entities. Types can represent physical assets (like turbines), abstract concepts (like maintenance schedules), or system components.

Fields

Properties that store data within a Type. Fields can be simple values (like strings or numbers) or references to other Types, creating relationships between entities.

Methods

Functions that define the behavior of a Type. Methods can perform calculations, transform data, or trigger actions based on business rules.

Mixins

Reusable components that can be combined with Types to add functionality. Mixins promote code reuse and modular design.

How the Type System works

The C3 AI Type System translates your high-level domain models into concrete implementations:
  1. You define Types using a domain-specific language in .c3type files
  2. The platform validates your Type definitions for correctness
  3. The platform generates database schemas, APIs, and UI bindings based on your Types
  4. Your application interacts with these Types through a consistent interface
This approach separates what your application represents (domain models) from how it’s implemented (database schemas, APIs, etc.), allowing you to focus on business logic rather than technical details.

Benefits of the Type System

The C3 AI Type System provides several key benefits:

Abstraction from technical details

You can define domain models without worrying about how they’re implemented in the database or API layer. The platform handles the technical details, allowing you to focus on business logic.
type WindTurbine mixes Asset {
  manufacturer: String;
  model: String;
  installedCapacity: Measure<Power>;
  commissionDate: Date;
  
  sensors: -> [Sensor];
  maintenanceRecords: -> [MaintenanceRecord];
  
  calculateEfficiency(): Double ~ js-server;
}
In this example, you define a WindTurbine Type with properties and relationships. The platform automatically creates the necessary database tables, API endpoints, and UI bindings.

Consistent data access

The Type System provides a consistent interface for accessing data, regardless of where it’s stored. You can query, create, update, and delete objects using the same patterns, whether the data is in a relational database, a NoSQL store, or an external system.
// Find all turbines manufactured by Vestas
const vestasTurbines = WindTurbine.filter({
  manufacturer: "Vestas"
}).fetch();

// Calculate average efficiency
const avgEfficiency = vestasTurbines.reduce((sum, turbine) => {
  return sum + turbine.calculateEfficiency();
}, 0) / vestasTurbines.length;

Relationship management

The Type System makes it easy to define and navigate relationships between entities. You can define one-to-one, one-to-many, and many-to-many relationships, and the platform handles the underlying implementation.
type Sensor mixes Asset {
  sensorType: String;
  location: String;
  installDate: Date;
  
  turbine: -> WindTurbine;
  readings: -> [SensorReading];
}
In this example, a Sensor has a relationship to a WindTurbine and multiple SensorReading objects. You can navigate these relationships in either direction:
// Find all sensors for a turbine
const turbine = WindTurbine.fetch("turbine-123");
const sensors = turbine.sensors.fetch();

// Find the turbine for a sensor
const sensor = Sensor.fetch("sensor-456");
const turbine = sensor.turbine.fetch();

Business rule enforcement

The Type System allows you to define business rules and validations that are enforced consistently across your application. You can define constraints on fields, validation logic in methods, and event handlers that respond to changes.
type MaintenanceRecord mixes Entity {
  turbine: -> WindTurbine;
  date: Date;
  technician: String;
  description: String;
  cost: Measure<Currency>;
  
  validate() ~ js-server {
    if (!this.description) {
      throw new Error("Description is required");
    }
    if (this.date > new Date()) {
      throw new Error("Maintenance date cannot be in the future");
    }
  }
}

Type System components

The C3 AI Type System includes several components that work together to provide a comprehensive modeling framework:

Class types

Class types define the structure and behavior of domain entities. They can be abstract (base classes that aren’t instantiated directly) or concrete (classes that can be instantiated).
abstract type Asset mixes Entity {
  assetId: String;
  name: String;
  description: String;
  location: GeoLocation;
}

type WindTurbine mixes Asset {
  // Additional fields and methods specific to wind turbines
}

Fields

Fields define the properties of a Type. They can be simple values (strings, numbers, dates) or references to other Types.
type WindFarm mixes Entity {
  name: String;
  location: GeoLocation;
  capacity: Measure<Power>;
  commissionDate: Date;
  
  turbines: -> [WindTurbine];
  weatherData: -> [WeatherRecord];
}

Methods

Methods define the behavior of a Type. They can be implemented in JavaScript, Python, or other supported languages.
type WindTurbine mixes Asset {
  // Fields...
  
  calculateEfficiency(): Double ~ js-server {
    // Implementation in JavaScript
    const readings = this.powerReadings.fetch();
    // Calculate efficiency based on readings
    return efficiency;
  }
  
  predictMaintenance(): MaintenancePrediction ~ python {
    # Implementation in Python
    import numpy as np
    from sklearn.ensemble import RandomForestClassifier
    # Predict maintenance needs
    return prediction
  }
}

Schema versioning

The Type System supports schema versioning, allowing you to evolve your data model over time without breaking existing applications. You can add new fields, deprecate old ones, and migrate data between versions.
type WindTurbine mixes Asset {
  // Version 1 fields
  manufacturer: String;
  model: String;
  installedCapacity: Measure<Power>;
  
  // Version 2 fields
  @since(2.0)
  commissionDate: Date;
  @since(2.0)
  decommissionDate: Date;
  
  // Version 3 fields
  @since(3.0)
  firmware: String;
  @since(3.0)
  lastFirmwareUpdate: Date;
}

Practical application

The C3 AI Type System is used across industries to model complex domains:
  • In energy, it models power plants, transmission networks, and consumption patterns
  • In manufacturing, it models production lines, equipment, and quality metrics
  • In healthcare, it models patients, treatments, and medical devices
  • In finance, it models transactions, accounts, and risk factors
For example, in a wind farm monitoring application, you might define Types for wind farms, turbines, sensors, maintenance records, and weather data. These Types would capture the relationships between these entities (example: a wind farm contains multiple turbines, each with multiple sensors) and the business logic for analyzing performance and predicting maintenance needs.