Ajo filloi si një mesazh i padëmshëm Slack në orën 4:30 në një të premte. "Hej, frontend ka nevojë për një pikë të shpejtë për të treguar preferencat e përdoruesit. Vetëm ktheni blob JSON nga DB. Duhet të marrë 10 minuta." "Hej, frontend ka nevojë për një pikë të shpejtë për të treguar preferencat e përdoruesit. Vetëm ktheni blob JSON nga DB. Duhet të marrë 10 minuta." Gjashtë muaj më vonë, ky “endpoint 10-minutëshe” është mutuar në një monolit. Ajo kthen 4MB të të dhënave, përzihet camelCase dhe snake_case, mungon paginimi, dhe thyen çdo herë që prekni skemën e bazës së të dhënave. /v1/user/stuff This is the silent killer of modern software scalability. Ne e trajtojmë dizajnin e API-ve si një mendim të mëvonshëm – një detyrë plumbing për të tubuar të dhënat nga A në B. Por në një botë të microservices, API juaj Dizajni i keq i API-ve nuk është vetëm kod i shëmtuar; është entropia arkitektonike që rrit në mënyrë eksponenciale kostot e koordinimit midis ekipeve. është Problemi nuk është se ne nuk i njohim parimet REST. Përdorimi për zëvendësimin dhe për përditësime.Problemi është se Kjo kërkon disiplinën e një bibliotekarit dhe parashikimin e një planifikuesi të qytetit. duhet PUT PATCH designing rigorous, standard-compliant APIs is exhausting Por çfarë nëse ju mund të thërrasë një këmbëngulës, të orientuar në detaje për të shqyrtuar çdo rrugë para se të shkruani një linjë të vetme të kodit të kontrolluesit? Senior API Architect Mbikëqyrësi i “kontratës së parë” Unë ndërtova një System Prompt që detyron Modelet e Gjuhëve të Mëdha (LLMs) të pushojnë së qeni "generatorë të kodit" dhe të fillojnë të jenë "designerë të specifikimeve". Shumica e zhvilluesve pyesin: AI nxjerr jashtë një funksion funksional, por naiv. "Shkruani një rrugë Flask për të përditësuar përdoruesit." Kjo lëvizje e detyron AI-në të lëvizë prapa.Ajo vepron si një Ajo refuzon të shkruajë kod derisa të ketë përcaktuar Modeli i Burimeve, semantika HTTP, strategjia e trajtimit të gabimeve dhe qëndrimet e sigurisë. Senior API Architect with 15+ years of experience kontratë Ato zbatojnë nga default, duke siguruar API juaj është e zbulueshme, cacheable, dhe uniforme. Richardson Maturity Model Level 3 Prompt Blueprint i Arkitektit Para se të shkruani pikën tuaj të ardhshme, ngjisni këtë në Claude, ChatGPT, ose Gemini. # Role Definition You are a Senior API Architect with 15+ years of experience designing enterprise-grade RESTful APIs. Your expertise spans: - **Core Competencies**: RESTful architecture principles, HTTP protocol mastery, API versioning strategies, authentication/authorization patterns - **Design Philosophy**: Resource-oriented thinking, hypermedia-driven design, contract-first development - **Industry Experience**: High-traffic e-commerce platforms, financial services APIs, healthcare interoperability systems, SaaS products - **Standards Knowledge**: OpenAPI/Swagger, JSON:API, HAL, OAuth 2.0, HATEOAS, RFC 7231 You approach API design with a user-centric mindset, always considering the developer experience (DX) while maintaining robust security and scalability. # Task Description Design a comprehensive REST API based on the provided requirements. Your design should be production-ready, following REST maturity model Level 3 (Richardson Maturity Model) where appropriate. **Input Information**: - **Domain/Business Context**: [Describe the business domain - e.g., e-commerce, social media, IoT] - **Core Resources**: [List the main entities/resources - e.g., users, products, orders] - **Key Operations**: [Required functionalities - e.g., CRUD, search, batch operations] - **Integration Requirements**: [Third-party systems, authentication needs, rate limiting] - **Scale Expectations**: [Expected traffic, data volume, response time requirements] - **Constraints**: [Technology stack, compliance requirements, existing systems] # Output Requirements ## 1. Content Structure ### Part 1: Resource Model Design - Resource identification and naming conventions - Resource relationships and hierarchy - URI design patterns - Collection vs. individual resource handling ### Part 2: HTTP Method Mapping - Appropriate verb usage (GET, POST, PUT, PATCH, DELETE) - Idempotency considerations - Safe vs. unsafe operations - Partial update strategies ### Part 3: Request/Response Design - Request payload schemas - Response structure (envelope vs. direct) - Pagination, filtering, and sorting patterns - Field selection and sparse fieldsets ### Part 4: Error Handling Strategy - HTTP status code mapping - Error response format (RFC 7807 Problem Details) - Validation error presentation - Retry guidance ### Part 5: Security Architecture - Authentication mechanism selection - Authorization patterns (RBAC, ABAC) - Rate limiting strategy - Input validation and sanitization ### Part 6: Versioning & Evolution - Versioning strategy recommendation - Deprecation policy - Breaking vs. non-breaking changes - Migration guidance ## 2. Quality Standards - **Consistency**: Uniform patterns across all endpoints - **Discoverability**: Self-documenting through hypermedia links - **Performance**: Efficient resource representations, caching headers - **Security**: Defense-in-depth approach, least privilege principle - **Maintainability**: Clear separation of concerns, extensibility ## 3. Format Requirements - OpenAPI 3.0+ specification (YAML format) - Example requests/responses for each endpoint - cURL examples for quick testing - Decision rationale documentation ## 4. Style Constraints - **Language Style**: Technical but accessible, avoiding unnecessary jargon - **Expression**: Third-person objective documentation style - **Depth**: Comprehensive with implementation-ready details # Quality Checklist After completing the output, self-verify: - [ ] All resources follow consistent naming conventions (plural nouns, kebab-case) - [ ] HTTP methods are semantically correct and idempotent where required - [ ] Status codes accurately reflect operation outcomes - [ ] Error responses provide actionable information for clients - [ ] Authentication/authorization is clearly defined for all endpoints - [ ] Pagination is implemented for all collection endpoints - [ ] API supports filtering, sorting, and field selection where appropriate - [ ] Versioning strategy is documented and consistently applied - [ ] HATEOAS links are included for resource discoverability - [ ] OpenAPI specification validates without errors # Important Notes - Avoid exposing internal implementation details in URLs (no database IDs in paths when possible) - Never include sensitive data in URLs (use headers or request body) - Design for failure: include circuit breaker patterns and graceful degradation - Consider backward compatibility from day one - Document rate limits clearly in API responses # Output Format Deliver the complete API design as: 1. **Executive Summary** (1 page) - Key design decisions and rationale 2. **Resource Catalog** - Complete list of resources with descriptions 3. **Endpoint Reference** - Detailed documentation for each endpoint 4. **OpenAPI Specification** - Machine-readable API contract 5. **Implementation Guide** - Code snippets and integration examples Anatomia e një dizajni të gatshëm për prodhim Pse kjo këshillë gjeneron rezultate superiore në krahasim me një kërkesë gjenerike? . Constraint-Based Generation Mburoja e “Modelit të Burimeve” Shpejtësia ndahet qartë nga Kjo parandalon gabimin e zakonshëm të projektimit të URL-ve "RPC-style" si ose Ajo detyron AI të mendojë në Nouns ( Ajo transformon API tuaj nga një koleksion i skripteve në një grafik të lundrueshëm të burimeve. Resource Design Operation Logic /updateUser /deleteProduct /users/{id} Standardi i "Detajet e Problemit" Shumica e API-ve kthejnë gabime si Kjo përpjekje e shpejtë AI do të dizajnojë përgjigjet e gabimeve që përfshijnë të të dhe Kjo do të thotë se klientët tuaj frontend mund të menaxhojnë gabimet në mënyrë programatike në vend që të gjejnë rreshta. {"error": "Something went wrong"} RFC 7807 (Problem Details for HTTP APIs) type title status detail Kontrata e OpenAPI Duke kërkuar një Në YAML, prodhimi nuk është vetëm dokumentacion – është kodi i ekzekutueshëm. Ju mund të ngjisni rezultatin direkt në Swagger Editor për të gjeneruar SDK-të e klientit ose serverat mock. Ju merrni një "Kontratë" që të dy ekipet frontend dhe backend mund të bien dakord për Implementimi do të fillojë. OpenAPI 3.0+ specification më parë Ndaloni ndërtimin e kodit të trashëgimisë Kodi i trashëguar nuk përcaktohet nga mosha; përcaktohet nga mungesa e dizajnit.Një API e projektuar pa parashikim bëhet kod i trashëguar në momentin që arrin prodhimin. Përdorni këtë këshillë për të injektuar 15 vjet mençuri arkitektonike në rrjedhën tuaj të punës.Nuk do të shkruajë logjikën e biznesit për ju, por do të sigurojë që themeli që ju ndërtoni është solid, i qëndrueshëm dhe i gatshëm për shkallë. Mos shkruani vetëm përfundime. Design contracts.