Social

Recipe Sharing

Public recipes with photo uploads and per-user favorites (many-to-many).

authpublic-readfilesmany-to-many

What you get

Schema

Copy and apply with PUT /v1/schema or set_schema via MCP. MoonDB auto-creates 3 tables: users, recipes, favorites.

recipes.schema.json
{
  "tables": {
    "users": {
      "auth_table": true,
      "columns": {
        "display_name": "string required",
        "avatar": "file"
      }
    },
    "recipes": {
      "columns": {
        "title": "string required max_length 160",
        "description": "text",
        "ingredients": "json required",
        "steps": "json required",
        "photo": "file",
        "minutes": "int min 1",
        "servings": "int default 2",
        "user_id": "ref users required"
      },
      "owner_field": "user_id",
      "access": {
        "read": "public",
        "create": "auth",
        "update": "owner",
        "delete": "owner"
      }
    },
    "favorites": {
      "columns": {
        "recipe_id": "ref recipes required cascade",
        "user_id": "ref users required"
      },
      "owner_field": "user_id",
      "unique": [
        [
          "recipe_id",
          "user_id"
        ]
      ],
      "access": {
        "read": "owner",
        "create": "auth",
        "delete": "owner"
      }
    }
  }
}

Auto-generated endpoints

The moment the schema applies, this REST surface is live (replace {project_id} with the id returned by POST /v1/projects):

live endpoints
GET    /api/users                  list/filter/sort/paginate
GET    /api/users/{id}             read one
POST   /api/users                  create
PATCH  /api/users/{id}             partial update
DELETE /api/users/{id}             delete
POST   /api/users/bulk             atomic bulk insert
POST   /auth/signup                 (from this auth_table)
POST   /auth/login                  (from this auth_table)
GET    /auth/me                     Bearer {token}

GET    /api/recipes                  list/filter/sort/paginate
GET    /api/recipes/{id}             read one
POST   /api/recipes                  create
PATCH  /api/recipes/{id}             partial update
DELETE /api/recipes/{id}             delete
POST   /api/recipes/bulk             atomic bulk insert

GET    /api/favorites                  list/filter/sort/paginate
GET    /api/favorites/{id}             read one
POST   /api/favorites                  create
PATCH  /api/favorites/{id}             partial update
DELETE /api/favorites/{id}             delete
POST   /api/favorites/bulk             atomic bulk insert

Plus auto-generated /v1/openapi.json (OpenAPI 3.0.3) and /v1/llm-context (machine-readable agent reference) for any client generator or coding agent.

Apply via REST

terminal
# 1. create the project
curl -X POST https://api.moondb.ai/v1/projects \
  -H "X-API-Key: mk_..." \
  -H "Content-Type: application/json" \
  -d '{"name":"recipes"}'

# 2. apply the template schema
curl -X PUT https://api.moondb.ai/p/{project_id}/v1/schema \
  -H "X-Admin-Key: sk_..." \
  -H "Content-Type: application/json" \
  -d @recipes.schema.json

Apply via MCP

If your agent has the MoonDB MCP server installed (see install), one tool call applies the template:

tools/call set_schema
# call set_schema via MCP (Cursor, Claude Code, Windsurf)
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": { "name": "set_schema", "arguments": {
    "project_id": "...",
    "schema": {
        "tables": {
            "users": {
                "auth_table": true,
                "columns": {
                    "display_name": "string required",
                    "avatar": "file"
                }
            },
            "recipes": {
                "columns": {
                    "title": "string required max_length 160",
                    "description": "text",
                    "ingredients": "json required",
                    "steps": "json required",
                    "photo": "file",
                    "minutes": "int min 1",
                    "servings": "int default 2",
                    "user_id": "ref users required"
                },
                "owner_field": "user_id",
                "access": {
                    "read": "public",
                    "create": "auth",
                    "update": "owner",
                    "delete": "owner"
                }
            },
            "favorites": {
                "columns": {
                    "recipe_id": "ref recipes required cascade",
                    "user_id": "ref users required"
                },
                "owner_field": "user_id",
                "unique": [
                    [
                        "recipe_id",
                        "user_id"
                    ]
                ],
                "access": {
                    "read": "owner",
                    "create": "auth",
                    "delete": "owner"
                }
            }
        }
    }
  } } }

Prompt your agent

Or just paste this one-liner into Cursor / Claude Code / Lovable after the MoonDB prompt is in .cursorrules / CLAUDE.md:

prompt
Apply the MoonDB "Recipe Sharing" template — public recipes with photo upload, ingredients/steps as JSON, favorites as a many-to-many with composite unique.

Extending the template

Send the full updated schema (with your additions) to PUT /v1/schema — MoonDB diffs against the current version and auto-migrates. Destructive changes (dropping columns, narrowing enums, renaming) require "confirm_destructive": true in the body. Read more about schema updates →

Ship this in 30 seconds

Sign up free, create a project, paste the schema. The API is live before your kettle boils.

Get an API key

Related templates

Productivity

Todo App

Classic personal task list with auth, owner-scoped writes, and priority enums.

Content

Blog with Comments

Public-read posts and comments, authenticated authors, owner-scoped edits.

Productivity

Habit Tracker

Daily habits with composite-unique logs (one entry per habit per day).

Copied to clipboard