Тоа започна како безопасна Slack порака во 4:30 часот на петок. "Еј, фронтендот треба брза крајна точка за да ги прикаже преференциите на корисникот. Само вратете го JSON blob од DB. Треба да потрае 10 минути." "Еј, фронтендот треба брза крајна точка за да ги прикаже преференциите на корисникот. Само вратете го JSON blob од DB. Треба да потрае 10 минути." Шест месеци подоцна, таа „10-минутна крајна точка“ мутирала во монолитна. Враќа 4 MB на податоци, меша camelCase и snake_case, недостасува странирање и се прекинува секој пат кога ќе го допрете шемата на базата на податоци. /v1/user/stuff This is the silent killer of modern software scalability. Ние го третираме дизајнот на API како после-мислење - задача за водовод за цевки на податоци од А до Б. Но, во светот на микро-услуги, вашиот API Лошиот дизајн на API не е само грдиот код; тоа е архитектонска ентропија која експоненцијално ги зголемува трошоците за координација меѓу тимовите. е Проблемот не е во тоа што не ги знаеме принципите на REST. Користете за замена и за ажурирање.Проблемот е дека За тоа е потребна дисциплината на библиотекарот и предвидувањето на градоначалникот. треба PUT PATCH designing rigorous, standard-compliant APIs is exhausting Но, што ако можете да повикате тврдоглав, детално ориентиран да ги разгледате сите рути пред да напишете еден ред на контролер код? Senior API Architect „Првиот“ извршител на договорот Јас изградив системски налог кој ги принудува големите јазични модели (LLMs) да престанат да бидат "генератори на код" и да почнат да бидат "дизајнери на спецификации". Повеќето програмери прашуваат: АИ исфрла функционална, но наивна функција. "Напишете Flask рута за ажурирање на корисниците." Ова поттикнува AI да се повлече.Тоа делува како Одбива да напише код додека не го дефинира Моделот на ресурсот, семантиката на HTTP, стратегијата за справување со грешките и безбедносниот став. Senior API Architect with 15+ years of experience Договорот Таа ги спроведува По подразбирање, обезбедување на вашиот API е откриена, кеширана и единствена. Richardson Maturity Model Level 3 Блуепринтот на архитектот Пред да ја напишете следната крајна точка, залепете ја во Claude, ChatGPT или 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 Анатомија на дизајн подготвен за производство Зошто овој повик генерира супериорни резултати во споредба со општо барање? . Constraint-Based Generation „Ресурсен модел“ на штитот Брзината експлицитно се одделува од Ова ја спречува честата грешка при дизајнирање на URL адреси во "RPC-стил" како или Тоа го принудува AI да размислува во ноунс ( ), не Verbs. Тоа го трансформира вашиот API од збирка на скрипти во навигациски графикон на ресурси. Resource Design Operation Logic /updateUser /deleteProduct /users/{id} Стандардот „Детали за проблемот“ Повеќето APIs враќаат грешки како Овој брз напор AI ќе дизајнира грешки кои вклучуваат , на , на и Ова значи дека вашите предни клиенти можат програматски да се справат со грешките наместо да ги погоди низа. {"error": "Something went wrong"} RFC 7807 (Problem Details for HTTP APIs) type title status detail Договорот за OpenAPI Со барање на Во YAML, излезот не е само документација – тоа е извршен код. Можете да го залепите резултатот директно во Swagger Editor за да генерирате клиентски SDKs или мак сервери. Започнува имплементацијата OpenAPI 3.0+ specification Пред Престанете да креирате наследен код Наследниот код не е дефиниран со возраста; тоа е дефинирано со недостаток на дизајн. API дизајниран без предвидување станува наследен код во моментот кога ќе го достигне производството. Користете ја оваа инспирација за да инјектирате 15 години архитектонска мудрост во вашиот работен тек. Тоа нема да ја напишете деловната логика за вас, но ќе се осигура дека темелот на кој се гради е солиден, конзистентен и подготвен за скала. Не пишувајте само крајни точки. Design contracts.