CONTENTS

    From Hackathon Challenge to Auditable AI Research — Claude Code + Momen Visual Backend

    avatar
    Cici Yu
    ·June 28, 2026
    ·6 min read

    I developed this project for Hack the Law Cambridge 2026, responding to Clifford Chance's challenge: "How Do We Supervise Legal AI Agents?"

    The core problem: while legal teams increasingly use AI for initial research, the genuine challenge involves oversight. As I framed it, "the hard part is not generation. It is supervision: seeing what the agent did, challenging the output, and keeping an audit trail a partner can stand behind."

    Project Overview

    I scoped an internal legal research supervision tool where "AI drafts a cited report; a human iterates through self-review; a leader approves or rejects. Every round and every AI step is preserved."

    The distinguishing approach: the entire backend runs within Momen's visual interface, while the React frontend connects through Momen BaaS — a visual, Postgres-native backend that AI coding tools and no-code builders plug into. You configure your data model, logic, AI agents, and permissions visually, and it exposes a standard GraphQL API your frontend consumes. One backend, many frontends.

    Matter Detail Screenshot

    The Problem Being Solved

    Traditional partner-review models assume human-only teams. When AI agents operate at scale, "supervision needs a system — not just a checklist."

    The backend requirements included:

    • Traceability — complete round history without silent overwrites

    • Accountability — documented initiation and approval chains

    • Transparency — exposed AI queries and tool calls accessible through data rather than buried logs

    Frontend Architecture

    Rather than building within Momen's canvas, Claude Code generated a React frontend consuming the backend via Momen BaaS — a single GraphQL API over everything configured in the editor.

    To connect Claude Code to the backend, I installed the Momen plugin — it gives Claude Code direct access to your tables, Actionflows, AI agent schemas, and permissions, so there's no need to document the API manually:

    # Claude Code
    claude plugin marketplace add momen-tech-org/momen-nocode-plugin
    claude plugin install momen-nocode@momen

    When you sync the backend, the plugin re-introspects the live schema and your generated code stays correct.

    Key Resources:

    Backend Architecture Overview

    Core Principle: "a review round is an immutable record. The AI never updates an existing report in place. Each iteration inserts a new review row."

    Data Model Structure

    task (Matter):

    Field

    Type

    Purpose

    title

    TEXT

    Generated from matter by query_builder

    input

    TEXT

    The legal question

    query

    JSONB

    Prepared search queries (process data)

    initiator

    → account

    Matter opener

    review (Self-Review Round):

    Field

    Type

    Purpose

    output

    TEXT

    Markdown report (insert-only, never updated)

    comment

    TEXT

    Initiator feedback triggering next round

    time

    BIGINT

    Round sequence marker

    task_status

    → task_status

    Approved/Rejected/In Progress/In Review

    conversation_id

    BIGINT

    Links to AI trace in system tables

    task

    → task

    Parent matter reference

    leader_review

    1:1

    Leader sign-off record

    leader_review (Sign-Off):

    Field

    Type

    Purpose

    comment

    TEXT

    Optional decision note

    time

    BIGINT

    Decision sequence

    self_review

    1:1 → review

    One decision per round

    Supporting Tables:

    • task_status — lookup rows: Approved, Rejected, In Progress, In Review

    • account — Momen built-in user table extended with self-relation (account.leader_id → account.id)

    Derived State (by Convention):

    • Current matter status = task_status on the latest review row

    • Round count = number of review rows for that task

    Permission Model (RBAC)

    Role

    Backend Rule

    Initiator

    Has leader_id set; can manage own matters and review rounds

    Leader

    Has subordinates; can read subordinates' In-Review rounds and write leader_review

    Unbound

    No leader/subordinates; actionflows reject; no data access

    "Access control is entirely server-side. Row-level filters in Momen Permission Management decide what each role can read and write."

    Related Documentation:

    AI Agents

    Three specialized agents handle discrete tasks:

    Agent

    Input

    Output

    Role

    query_builder

    Matter text

    Structured JSON (title, queries)

    Transform legal question into search plan

    web_search

    task_id

    Markdown report

    Search, score, select sources, write cited report

    output_reviewer

    last_output_id, comment

    Markdown report

    Revise or re-search based on feedback

    Search Implementation: The web_search agent calls Perplexity API (configured via API Integration), passes queries from the task, and applies domain filtering from config.config_json. The agent selects the top 5 results and writes first-person Markdown without AI-voice phrasing.

    Revision Process: output_reviewer determines whether feedback requires new sources or in-place revision, then produces output similarly.

    Documentation:

    AI Transparency (System Tables)

    Rather than custom logging infrastructure, the system leverages Momen's built-in tables. Each review stores conversation_id, which chains into:

    review.conversation_id
      → fz_conversation
        → fz_message
          → fz_message_content (text/json payloads)
          → fz_tool_usage_record (tool call requests/responses)

    "Any client connected via BaaS can query the chain and reconstruct what the agent did — queries sent, sources returned, reasoning steps — without custom logging infrastructure."

    AI Transparency Architecture

    Actionflows (Workflow Orchestration)

    All mutations flow through Actionflows — no direct client table inserts for AI output. Four flows manage the complete lifecycle:

    Actionflow

    Mode

    Inputs

    Effect

    first-output-for-self-review

    async

    task_input

    Run query_builder → insert task → web_search → insert first review

    self-review-for-next-output

    async

    task_id, comment

    Save comment → output_reviewer → insert new review

    self-review-to-leader-review

    sync

    task_id

    Set latest round status to In Review

    leader-review

    sync

    task_id, task_status_id, comment

    Set Approved/Rejected + insert leader_review

    Async vs. Sync Logic: AI-invoking flows run asynchronously server-side; clients wait via GraphQL subscriptions. Status transitions remain synchronous — single transactions without AI overhead.

    Immutability Enforcement: self-review-for-next-output inserts new review rows rather than updating prior ones, guaranteeing frozen report text at creation.

    Documentation:

    Third-Party Integration: Perplexity

    "Legal research needs live web search against authoritative domains." Perplexity integrates as a third-party API within Momen's API Integration interface — not embedded in application code.

    The web_search agent calls it with:

    • query — array of search strings

    • search_domain_filter — from config

    • max_results, search_context_size — tuned for legal snippets

    Requests and responses populate fz_tool_usage_record, feeding the transparency chain.

    Documentation:

    BaaS: Connecting the Frontend

    After backend sync, the visual schema becomes a typed GraphQL API. The Momen plugin lets Claude Code read this schema directly — tables, nested relations, Actionflow inputs/outputs, and AI agent schemas — without any manual API documentation.

    Capability

    Implementation

    Authentication

    authenticateWithUsername → JWT

    Reads

    Auto-generated queries per table + nested relations

    Writes

    fz_invoke_action_flow (sync), fz_create_action_flow_task (async)

    AI Trace

    Query review → nested conversationmessagestool_calls

    Real-time

    WebSocket subscriptions on actionflow task status

    "The schema is self-documenting via introspection — no hand-written API spec."

    Related Builds:

    Backend Design Decisions

    Decision

    Rationale

    New review row per iteration

    Provides native audit trail; satisfies non-destructive history requirement

    No status column on task

    Single source of truth (latest review) eliminates sync bugs

    query JSONB on task (hidden)

    Separates process data from user-facing deliverables

    Dedicated config table

    Adjust search scope without redeploying agents

    account self-relation

    Models hierarchy without extra org tables

    Actionflows as sole write path

    Centralizes RBAC enforcement; prevents client-side pipeline bypass

    conversation_id per review

    Enables transparency via system tables rather than custom logging

    Perplexity in API Integration

    Keeps third-party search in visual backend, not frontend code

    Implementation Timeline

    Component

    Time

    Data model + relations + config seed

    ~1 hour

    3 AI agents + Perplexity wiring

    ~2 hours

    4 Actionflows + RBAC

    ~2 hours

    Sync, test, iterate

    ~1 hour

    Backend Total

    ~4–6 hours

    Momen Free plan supports hackathon MVPs; Perplexity charges per search.

    Conclusion

    "For Hack the Law's supervision challenge, the backend is the product." The visual architecture delivers:

    • Immutable review history through table design

    • Guarded AI output pipeline via Actionflows

    • Complete reasoning transparency linked to system tables

    • Server-side RBAC enforcement

    "What matters here is that the backend is complete, visual, and auditable — without a line of server code."

    Try Momen — It's Free

    Headless / BaaS Documentation

    Build Your App Today. Start With No Code, Gain Full Control as You Grow.