Full-Stack CRUD API Generator

Generate complete CRUD API endpoints with database schema, validation, error handling, and frontend integration code.

Best modelclaude-sonnet-4
Good alternativegpt-4o, gemini-2.5-pro
Budget / limitedclaude-haiku, gpt-4o-mini

How to use this prompt

  1. Fill in the details below. Skip any you do not know yet.
  2. Click Copy prompt.
  3. Paste it into ChatGPT, Claude or Gemini and send.

Easy Mode: fill in the details

Answer what you know. Empty fields stay as [brackets] in the prompt, so you can see what is left.


  
  

Text in double curly braces is a template placeholder. Fill it in above, or edit the prompt after copying.

View the full prompt template
You are a senior full-stack engineer. Generate a production-ready CRUD API.

Resource: {{resourceName}}
Fields: {{fields}}
Backend Framework: {{framework || "Express.js"}}
Database: {{database || "PostgreSQL with Prisma"}}
Frontend: {{frontend || "React with fetch/axios"}}
Authentication: {{auth || "JWT-based"}}

Generated Code Structure

1. Database Schema ({{database}})

prisma
// schema.prisma
model {{resourceName}} {
id String @id @default(cuid())
{{#each fields}}
{{this}}
{{/each}}
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

Or the equivalent for {{database}}. Include proper indexes, relations, and constraints.

2. Validation Schema

Define validation rules for create and update operations:

Create{{resourceName}}:
- [field]: [type], [required], [min/max], [custom validation]
- ...

Update{{resourceName}}:
- [field]: [type], [optional], [min/max], [custom validation]
- ...

3. API Endpoints

List GET /api/{{resourceName | downcase}}s

Pagination: ?page=1&limit=20

Search: ?search=term

Filter: ?field=value

Sort: ?sort=field&order=asc|desc

Response: { data: [...], total, page, limit, totalPages }

Get One GET /api/{{resourceName | downcase}}s/:id

Response: { data: {...} }

Error: 404 if not found

Create POST /api/{{resourceName | downcase}}s

Body: validated fields

Response: 201 { data: {...} }

Error: 400 validation errors

Update PUT /api/{{resourceName | downcase}}s/:id

Body: partial or full fields

Response: 200 { data: {...} }

Error: 404 not found, 400 validation

Delete DELETE /api/{{resourceName | downcase}}s/:id

Response: 204 No Content

Error: 404 not found

4. Error Handling Middleware

{
error: {
code: "VALIDATION_ERROR | NOT_FOUND | UNAUTHORIZED | INTERNAL",
message: "Human-readable message",
details: [...] // field-level errors
}
}

5. Frontend Integration Example

For {{frontend}}, provide:

// Example: React hook or service function
async function fetch{{resourceName}}s(params) { ... }
async function create{{resourceName}}(data) { ... }
async function update{{resourceName}}(id, data) { ... }
async function delete{{resourceName}}(id) { ... }

Include loading states, error handling, and TypeScript types if applicable.

6. Authentication Integration

For {{auth}}, include:

Middleware/guard for each protected route

Token extraction and validation

Role-based access if applicable

Output with code blocks for all generated code, bold endpoint descriptions, and | table | for field specifications.

Free tools that pair with this prompt

More Development prompts