How to Generate Backend Code for the API Using LLMs: A Complete Developer Guide

Yes, you can generate complete, production-ready backend code for the Exercises Dataset API using Large Language Models by leveraging the interactive prompt builder in setup.html, which assembles detailed specifications including database schemas, REST endpoints, and security requirements for any major framework.

The hasaneyldrm/exercises-dataset repository includes a sophisticated LLM integration tool that eliminates the manual work of API scaffolding. Instead of writing boilerplate route handlers, database connections, and validation logic from scratch, developers can use the built-in prompt generator to produce complete backend implementations in seconds.

How the LLM Prompt Generator Works in setup.html

The repository ships with an interactive developer guide at setup.html that features an "Ask Your LLM" section. This tool automatically constructs comprehensive prompts tailored to your specific technology stack.

Inside setup.html, the JavaScript function buildLlmPrompt (lines 95-140) dynamically assembles prompts based on your selections. When you choose a framework and database engine, the function injects concrete implementation details including:

  • Exact field names and data types from the 1,324 exercise records
  • SQL CREATE statements appropriate for your chosen database (PostgreSQL, MySQL, SQL Server, or SQLite)
  • Required REST endpoints with specific routing patterns
  • Security constraints including parameterized queries and CORS configuration
  • Dependency lists with exact package names for npm, pip, or Composer

The generated prompt appears in a read-only textarea, ready for you to copy and paste into ChatGPT, Claude, Gemini, or any other code-generation LLM.

Generating Production-Ready Backend Code

The prompt builder supports six major backend frameworks and four database engines, ensuring compatibility with your existing infrastructure.

Supported Frameworks and Database Engines

You can generate backend code for any of the following combinations:

  • Express.js with PostgreSQL, MySQL, SQL Server, or SQLite
  • FastAPI with async PostgreSQL or MySQL drivers
  • ASP.NET Core with Entity Framework
  • Spring Boot with JPA/Hibernate
  • Laravel with Eloquent ORM
  • Gin (Go) with standard SQL drivers

The Complete Prompt Structure

The buildLlmPrompt function constructs a specification that includes:

Database Schema Definition The prompt includes the complete DB_SQL constant with CREATE TABLE statements mapping the exercise dataset fields: id (VARCHAR), name, category, body_part, equipment, multiple instruction language columns (instructions_en, instructions_es, etc.), secondary_muscles (JSON/JSONB), target, image paths, and gif_url paths.

Required API Endpoints The specification demands six RESTful endpoints:

  • GET /exercises/:id – Retrieve single record with 404 handling
  • GET /exercises – Paginated list with filtering capabilities
  • GET /exercises/random – Random exercise selection
  • GET /categories – Distinct category values
  • GET /body-parts – Distinct body part values
  • GET /equipment – Distinct equipment types

Technical Requirements Each prompt explicitly requires environment-variable database configuration, parameterized queries only, proper HTTP status codes, request logging (method, path, status, duration), CORS enablement, and integer validation for pagination parameters.

Step-by-Step: From Prompt to Working API

Follow this workflow to generate your backend:

  1. Open setup.html in your browser from the repository root.

  2. Select your stack using the framework and database engine buttons in the "Ask Your LLM" section.

  3. Click "Copy Prompt" to copy the assembled text from the textarea.

  4. Paste into your LLM of choice (ChatGPT, Claude, or Codex).

  5. Receive complete source code including project structure, configuration files, route handlers, database connection logic, and a README.md with setup instructions.

Code Examples: Express.js and FastAPI

Here are the actual prompt excerpts generated by the tool, demonstrating the level of detail provided to the LLM.

Express.js with PostgreSQL

// Prompt excerpt for Express.js backend
You are a senior JavaScript developer. Build a complete REST API using Express.js for an exercise/fitness database.

## Dataset Overview

- 1,324 fitness exercises
- Fields: id (string), name, category, body_part, equipment,
  instructions_en, instructions_es, …, instructions_fr,
  muscle_group, secondary_muscles (JSON array), target,
  image (path), gif_url (path), created_at

## Database Schema (PostgreSQL)

CREATE TABLE exercises (
  id VARCHAR(10) PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  category VARCHAR(100),
  body_part VARCHAR(100),
  equipment VARCHAR(100),
  instructions_en TEXT,
  instructions_es TEXT,
  …,
  secondary_muscles JSONB,
  target VARCHAR(100),
  image VARCHAR(500),
  gif_url VARCHAR(500),
  created_at TIMESTAMPTZ
);

## Required Endpoints

1. GET /exercises/:id – single record (404 if missing)
2. GET /exercises – pagination + filters (category, body_part, …)
3. GET /exercises/random – one random record
4. GET /categories – list of unique categories
5. GET /body-parts – list of unique body parts
6. GET /equipment – list of unique equipment

## Technical Requirements

- DB connection string from process.env.DATABASE_URL
- Parameterised queries only
- JSON responses with application/json
- CORS enabled for all origins
- Validate page/limit (positive integers)
- Log method, path, status, duration
- Use packages: express, pg, cors, dotenv

The LLM typically returns a complete project structure:


my-exercises-api/
├── package.json
├── .env.example
├── src/
│   ├── db.js
│   ├── routes/
│   │   └── exercises.js
│   └── server.js
└── README.md

FastAPI with SQLAlchemy


# Prompt excerpt for FastAPI backend

You are a senior Python developer. Build a complete REST API using FastAPI for an exercise/fitness database.

## Required Packages

fastapi, uvicorn, sqlalchemy, psycopg2-binary, python-dotenv

## Schema Requirements

- Use SQLAlchemy ORM with the exercises table structure provided above
- Pydantic models for request/response validation
- Async database sessions with proper connection pooling

Expected output structure:


app/
├── main.py
├── models.py
├── schemas.py
├── crud.py
├── database.py
└── .env.example

Why This Approach Works for API Generation

The buildLlmPrompt function eliminates the ambiguity that typically causes LLMs to hallucinate incorrect schemas or forget critical security requirements. By providing concrete field names, exact SQL types, and explicit endpoint specifications, the generated prompts produce consistent, runnable backends across languages.

The approach ensures:

  • Type safety through explicit schema definitions in the prompt
  • Security compliance via mandatory requirements for parameterized queries and environment variables
  • Operational completeness through required logging, error handling, and CORS configuration
  • Dependency accuracy with specific package versions for Node.js, Python, Java, PHP, and Go ecosystems

Summary

  • The hasaneyldrm/exercises-dataset repository provides an interactive LLM prompt generator in setup.html that automates backend API creation.
  • The buildLlmPrompt function crafts detailed specifications covering database schemas, REST endpoints, validation rules, and security requirements.
  • You can generate complete backends for Express.js, FastAPI, ASP.NET Core, Spring Boot, Laravel, or Gin by copying the prompt and pasting it into any LLM.
  • The resulting code includes proper project structure, environment configuration, database connection handling, and production-ready middleware.

Frequently Asked Questions

What frameworks does the LLM prompt generator support?

The buildLlmPrompt function in setup.html supports Express.js, FastAPI, ASP.NET Core, Spring Boot, Laravel, and Gin. You can combine any of these with PostgreSQL, MySQL, SQL Server, or SQLite databases, and the prompt automatically adjusts SQL dialects and package dependencies accordingly.

Does the generated backend include database connection code?

Yes, the LLM prompt explicitly requires the generated code to include database connection logic using environment variables (such as process.env.DATABASE_URL for Node.js or os.getenv("DATABASE_URL") for Python). The prompt mandates parameterized queries and proper connection pooling, ensuring the output includes complete, secure database integration rather than just route stubs.

Can I customize the endpoints before generating the code?

While the setup.html interface generates a standardized set of six endpoints (GET /exercises/:id, GET /exercises, GET /exercises/random, GET /categories, GET /body-parts, GET /equipment), you can manually edit the copied prompt text before sending it to the LLM. The prompt structure is plain text, so you can add, remove, or modify endpoints while maintaining the schema and security requirements sections.

Is the generated code production-ready?

According to the repository's implementation, the generated code is designed to be production-ready. The prompts explicitly require security best practices including CORS configuration, input validation for pagination parameters, proper HTTP status codes, request logging, and parameterized SQL queries. However, as with any LLM-generated code, you should review authentication, rate limiting, and deployment-specific configurations before deploying to production.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →