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 :
-
Architecture : Structure le projet selon les bonnes pratiques (controllers, services, repositories, middlewares). Fournis l'arborescence complète des fichiers.
-
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.
-
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)
-
Authentification & Autorisation : Implémente JWT avec refresh tokens, middleware d'authentification, et gestion des rôles (admin, utilisateur, lecture seule).
-
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.
-
Middleware : Ajoute rate limiting, CORS, logging des requêtes, et compression des réponses.
-
Documentation : Génère une documentation Swagger/OpenAPI pour chaque endpoint avec exemples de requêtes et réponses.
-
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 · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
This prompt guides the AI to produce a production-quality REST API covering all essential layers. By specifying [PROJECT DESCRIPTION] (e.g., "a collaborative task management platform") and [LANGUAGE/FRAMEWORK] (e.g., "Node.js with Express" or "Python with FastAPI"), you get code adapted to your exact context. 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. Usage tip: 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).
Use Cases
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 OptimizerComments
- 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
Design an event-driven system
Architect event-driven systems
Write a deployment script
Automate deployment scripts
Prompt ChatGPT to Generate SQL Queries
Generating SQL queries is an essential skill for any developer, data analyst, or database administrator. However, writing complex queries involving multiple joins, nested subqueries, or aggregate functions can be time-consuming and error-prone. ChatGPT transforms this practice radically by allowing you to describe your needs in natural language to obtain optimized and functional SQL queries in seconds. Whether you work with MySQL, PostgreSQL, SQL Server, or SQLite, the AI adapts to the specific syntax of your database management system. By providing your table schema and a clear description of what you want, you can generate perfectly structured SELECT, INSERT, UPDATE, or DELETE queries. ChatGPT also excels at line-by-line explanations of generated queries, making it a valuable learning tool for beginners and professionals alike who wish to explore advanced SQL features like CTEs, window functions, or recursive queries.
Master Git Reset, Rebase, and Cherry-Pick
Master advanced Git commands (reset, rebase, cherry-pick, stash) with clear diagrams and practical scenarios.