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

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

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.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

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.

Go further

Similar Prompts

💻DeveloppementBeginnerChatGPT

Create Your First API with Express.js

Learn to create your first Express.js REST API from A to Z with pedagogical explanations adapted to beginners.

15611
💻DeveloppementAdvancedClaude

Implement Clean Architecture in Practice

Implement Clean Architecture in practice with layers, ports and adapters, use cases, and unit tests without infrastructure.

48639
💻DeveloppementIntermediateAll AIs

Prompt DALL-E to Create a Prototype

Creating visual prototypes is a crucial step in any product design process. Traditionally reserved for designers with specialized tools like Figma or Sketch, this phase can now be accelerated with DALL-E. By generating realistic visual mockups from text descriptions, DALL-E allows entrepreneurs, product managers, and developers to quickly materialize their ideas without advanced graphic skills. Whether you want to visualize a mobile app interface, a physical product, or an architectural concept, DALL-E transforms your descriptions into compelling visual representations. This approach considerably reduces the time between ideation and the first visual iteration, going from several days to a few minutes. The AI-generated prototype then serves as a basis for discussion with stakeholders, investors, or potential users, facilitating the collection of concrete feedback before investing in costly development. Mastering the art of prompting for prototype generation with DALL-E thus becomes a strategic skill for anyone wishing to innovate quickly and effectively.

0321
💻DeveloppementAdvancedAll AIs

Policy as Code with OPA

Implement infrastructure as code policies

0340