Modelence Hackathon

AI-native Backend for TypeScript

Ship production AI apps 10x faster with built-in auth, database and LLM integration

Get Started

Backend Focused

Either add Modelence to an existing Next.js project or set up from scratch using the built-in Vite + React frontend.

MongoDB Data Models

Define your schema and indexes along with your collection in one place, then store and retrieve data anywhere in your code.

Authentication

Ready-to-use user system in your own database, with provided login, signup and logout methods, password encryption and hashing.

Works with

TypeScript
React
Vite
Next.js
MongoDB
OpenAI

Built for modern AI apps

Complete toolkit for building and running production-ready AI agents.

LLM Integration

Effortlessly connect to OpenAI, Anthropic, Google Gemini and other models with built-in API key management.

AI Observability

Get instant visibility into every LLM and AI agent action with automatic tracing, error tracking, and real-time metrics.

Agentic Workflows

Build persistent, stateful AI agents with built-in cron jobs, background workers, and a modular system for scheduling at scale.

Use Modelence Store and schema to define your data storage in MongoDB collections along with helper methods for document models

import { Store, schema } from 'modelence/server';

export const dbTodos = new Store('todos', {
  schema: {
    title: schema.string(),
    isCompleted: schema.boolean(), 
    dueDate: schema.date().optional(),
    userId: schema.userId(),
  },
  indexes: [
    { key: { dueDate: -1 } }
  ],
  methods: {
    isOverdue() {
      return this.dueDate < new Date();
    }
  }
});

Define cron jobs by simply passing a handler function, with intervals as short as one second

import { Module, time } from 'modelence/server';

export default new Module('todo', {
  stores: [dbTodos],
  cronJobs: {
    sendReminders: {
      description: 'Send reminders for overdue todos',
      interval: time.hours(24),
      async handler() {
        const overdueTodos = await dbTodos.fetch({
          isCompleted: false,
          dueDate: { $lt: new Date() }
        });
        overdueTodos.forEach(todo => {
          // Send reminder email
        });
      }
    }
  }
});

Use the AI SDK to call any LLM provider, with built-in API keys and observability

import { generateText } from '@modelence/ai';

const response = await generateText({
  provider: 'openai',
  model: 'gpt-4o',
  messages: [{
    role: 'user',
    content: 'Hi there'
  }]
});

Use TanStack Query-style useQuery and useMutation hooks to interact with your backend from React

import { modelenceQuery } from '@modelence/react-query';

function TodoItem({ todoId }) {
  const {
    data: todo,
    isPending,
    error
  } = useQuery(modelenceQuery('todo.getOne', { id: todoId }));
  if (isPending) {
    return <div>Loading...</div>;
  }
  if (error) {
    return <div>Error: {error.message}</div>;
  }
  return <div>{todo.title}</div>;
}

Cron Jobs

Simply define a handler function and it will run at your specified time interval, with sub-second precision and cron job orchestration for multiple application instances.

Data Loading

Define queries and mutations to send and retrieve data between the client and server. Use React hooks on the client to fetch data, handle errors and loading state with a single statement.

Telemetry

All cron jobs and method calls are automatically logged and traced, so you can see full insights in your application's performance dashboard in Modelence Cloud.

App Configuration

Define dynamic app configuration values, and call getConfig on both client & server to use your configuration values anywhere in your code.

Database Migrations

Seamless migration scripts and versioning support to manage your database structure changes in multiple environments without any manual steps.

Type-Safe Development

End-to-end TypeScript support with automatic type inference for your data models, methods and database queries.