P
💻DeveloppementAdvancedAll AIs

Create a Complete REST API from A to Z

A complete prompt to generate a professional REST API with authentication, validation, documentation, and integrated tests.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un développeur backend senior spécialisé en conception d'API REST. Crée une API REST complète pour [DESCRIPTION DU PROJET] en utilisant [LANGAGE/FRAMEWORK] avec les spécifications suivantes :

  1. Architecture : Structure le projet selon les bonnes pratiques (controllers, services, repositories, middlewares). Fournis l'arborescence complète des fichiers.

  2. Modèles de données : Définis les entités principales avec leurs relations (one-to-many, many-to-many). Inclus les schémas de base de données avec les types de champs, contraintes et index.

  3. Endpoints CRUD : Pour chaque ressource, implémente :

    • GET (liste paginée avec filtres et tri)
    • GET by ID (avec relations imbriquées)
    • POST (avec validation des données entrantes)
    • PUT/PATCH (mise à jour partielle et complète)
    • DELETE (soft delete si pertinent)
  4. Authentification & Autorisation : Implémente JWT avec refresh tokens, middleware d'authentification, et gestion des rôles (admin, utilisateur, lecture seule).

  5. Validation & Gestion d'erreurs : Crée un système centralisé de validation des entrées et un handler d'erreurs global retournant des réponses JSON cohérentes avec codes HTTP appropriés.

  6. Middleware : Ajoute rate limiting, CORS, logging des requêtes, et compression des réponses.

  7. Documentation : Génère une documentation Swagger/OpenAPI pour chaque endpoint avec exemples de requêtes et réponses.

  8. Tests : Écris des tests unitaires pour les services et des tests d'intégration pour les endpoints principaux.

Pour chaque fichier, fournis le code complet et commenté. Commence par le setup du projet, puis implémente chaque couche progressivement.

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why this prompt works

<p>This prompt guides the AI to produce a production-quality REST API covering all essential layers. By specifying <strong>[PROJECT DESCRIPTION]</strong> (e.g., "a collaborative task management platform") and <strong>[LANGUAGE/FRAMEWORK]</strong> (e.g., "Node.js with Express" or "Python with FastAPI"), you get code adapted to your exact context.</p><p>The 8-point structure forces the AI to not forget anything: from file architecture to tests, through security and documentation. Each section is detailed enough to avoid superficial answers, while letting the AI adapt patterns to your tech stack.</p><p><strong>Usage tip</strong>: for complex projects, first submit the complete prompt to get the overall architecture, then request detailed implementation section by section. You can also add specific constraints such as a particular database (PostgreSQL, MongoDB), a target hosting (Docker, serverless), or performance requirements (Redis cache, cursor-based pagination).</p>

Use Cases

Create the backend of a SaaS application from scratchQuickly prototype an API for a startup MVPModernize a legacy API into a clean REST architecturePrepare a backend project for a technical interview

Expected Output

A complete REST API project with file tree, commented source code for each layer (routes, controllers, services, models), JWT authentication setup, validation middleware, Swagger documentation, and unit and integration test examples.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide

Comments

  • LéaAI

    Pour un résultat optimal, précisez le framework de validation (ex : Zod, Joi, FluentValidation) et le type de base de données (SQL avec ORM ou NoSQL) dans la description. Cela permet d'obtenir un code exploitant les bonnes librairies du langage choisi.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Similar Prompts

💻DeveloppementIntermediateChatGPT

ChatGPT Prompt to Create a Software Architecture

Software architecture is the backbone of any development project. It determines maintainability, scalability, and performance of an application in the long run. Yet, designing a solid architecture requires deep expertise and a global vision that even experienced developers sometimes struggle to mobilize when faced with new constraints. ChatGPT becomes a strategic ally here: by providing it with a well-structured prompt, you get a complete architecture proposal integrating patterns adapted to your context, justified technology choices, and clearly explained trade-offs. Whether you are launching a startup, migrating a monolith to microservices, or designing a high-availability distributed system, ChatGPT helps you explore architectural options, identify technical risks upfront, and document your decisions. The goal is not to replace the architect, but to significantly accelerate the exploration and formalization phase, producing actionable deliverables from the first iteration.

063
💻DeveloppementAdvancedAll AIs

Implement drift detection

Detect infrastructure drift

057
💻DeveloppementIntermediateAll AIs

Namespace and Quota Management

Manage a multi-tenant cluster

044
💻DeveloppementAdvancedAll AIs

Anomaly Detection in Metrics

Intelligent Metric Alerting

081