Back to all projects
ActiveDeveloper Platforms / Cloud Infrastructure / Mock APIs• Technical Overview

API Gen Platform

Generate Live Relational Mock APIs with Connected Data from Plain English

What it is

API Gen is a developer tool that turns plain-English requirements into a live, relational mock database in under 10 seconds. It solves frontend-backend blocking by generating full CRUD REST endpoints with realistic, foreign-key-consistent data powered by DAG topological sorting and Hono.

Tech Stack

Frontend
Next.js 16 (App Router)React 19Monaco EditorTailwind CSS
Backend
Standalone Hono Engine (Port 3001)TypeScript Queue Daemon
Database & Cache
Neon PostgreSQLPrisma ORMSHA-256 Prompt Cache
AI & Cloud
Groq LLM 120BFaker.js with DAG Topological Sort

System Architecture

System Architecture Sketch
Whiteboard architecture • Click any box to inspect
Tier 1: Developer Console
Non-blocking Job Dispatch
Tier 2: Relational Generation Pipeline
DAG Dependency Sorter
Tier 3: Standalone Mock Engine & Storage
Next.js 16 Web ConsoleConsole
Component Role

Provides natural language prompt input, live schema relationship previews, and an interactive REST API testing client.

Core Engineering Highlight

DAG Topological Sorter for Relational Schema Integrity

Eliminating broken foreign keys and orphaned records in dynamic AI mock databases.

Static mock servers generate isolated JSON files where parent-child relationships break immediately. API Gen constructs a Directed Acyclic Graph (DAG) of all entities and performs a topological sort (e.g. Users & Categories ➔ Products ➔ Orders ➔ OrderItems). Faker.js hydrates records in strict topological order, ensuring every child record references a genuine, pre-existing parent ID.

How it works & Technical Depth:
100% valid foreign keys: Child entities strictly reference valid, pre-computed parent IDs.
Sub-millisecond mock API overhead: Served via high-performance Hono router on Port 3001.
Zero frontend blockers: Frontend developers can build against live CRUD endpoints in under 10 seconds.
Cycle detection: Automatically detects and breaks circular foreign key dependencies.
engine/src/dagSorter.ts (Topological Dependency Sorter)typescript
export interface EntitySchema {
  name: string;
  dependencies: string[]; // Parent entity names
}

export function sortEntitiesTopologically(entities: EntitySchema[]): string[] {
  const inDegree = new Map<string, number>();
  const graph = new Map<string, string[]>();

  entities.forEach(e => {
    inDegree.set(e.name, 0);
    graph.set(e.name, []);
  });

  // Build dependency edges
  entities.forEach(e => {
    e.dependencies.forEach(parent => {
      graph.get(parent)?.push(e.name);
      inDegree.set(e.name, (inDegree.get(e.name) || 0) + 1);
    });
  });

  // Kahn's algorithm: queue nodes with 0 incoming dependencies
  const queue: string[] = [];
  inDegree.forEach((deg, name) => {
    if (deg === 0) queue.push(name);
  });

  const sortedOrder: string[] = [];
  while (queue.length > 0) {
    const current = queue.shift()!;
    sortedOrder.push(current);

    graph.get(current)?.forEach(neighbor => {
      inDegree.set(neighbor, inDegree.get(neighbor)! - 1);
      if (inDegree.get(neighbor) === 0) queue.push(neighbor);
    });
  }

  return sortedOrder; // Order: ['User', 'Category'] -> ['Product'] -> ['Order'] -> ['OrderItem']
}

Key Challenges & Trade-offs

Hurdle #1

Preventing Broken Foreign Key Cascades

The Bottleneck:

Naive mock generators populate tables in arbitrary order, causing child entities (e.g. order items) to reference non-existent orders and products.

The Engineered Solution:

Applied Kahn's DAG topological sort algorithm to guarantee parent entities are always generated and assigned valid IDs before any child entity is hydrated.

Takeaway: Graph algorithms are crucial for maintaining state and relational integrity in generative AI developer tools.