{"id":2548,"date":"2026-05-08T22:32:04","date_gmt":"2026-05-08T15:32:04","guid":{"rendered":"https:\/\/daiilynews.cu.ma\/stop-writing-endpoints-start-defining-systems\/"},"modified":"2026-05-08T22:32:04","modified_gmt":"2026-05-08T15:32:04","slug":"stop-writing-endpoints-start-defining-systems","status":"publish","type":"post","link":"https:\/\/daiilynews.cu.ma\/?p=2548","title":{"rendered":"Stop Writing Endpoints. Start Defining Systems."},"content":{"rendered":"<p> <br \/>\n<br \/>\n                For a long time, I thought building APIs meant writing endpoints.<\/p>\n<p>You know the pattern:<\/p>\n<p>Define a route<br \/>\nValidate input<br \/>\nQuery the database<br \/>\nTransform the result<br \/>\nSend a response<\/p>\n<p>Do that over and over again.<\/p>\n<p>Different routes. Same structure.<\/p>\n<p>  The Illusion of Control<\/p>\n<p>Writing endpoints feels productive.<\/p>\n<p>You\u2019re in control of everything:<\/p>\n<p>The logic<br \/>\nThe validation<br \/>\nThe data flow<\/p>\n<p>But after a while, something becomes obvious:<\/p>\n<p>You\u2019re not building systems.<\/p>\n<p>You\u2019re repeating patterns.<\/p>\n<p>  The Real Problem<\/p>\n<p>Most APIs look like this:<\/p>\n<p>app.get(&#8216;\/users\/:id&#8217;, async (req, res) => {<br \/>\n  const id = req.params.id;<\/p>\n<p>  if (!id) {<br \/>\n    return res.status(400).json({ error: &#8216;Missing id&#8217; });<br \/>\n  }<\/p>\n<p>  const user = await db.users.findById(id);<\/p>\n<p>  if (!user) {<br \/>\n    return res.status(404).json({ error: &#8216;Not found&#8217; });<br \/>\n  }<\/p>\n<p>  return res.json(user);<br \/>\n});<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>Now multiply that by:<\/p>\n<p>Dozens of endpoints<br \/>\nMultiple resources<br \/>\nDifferent validation rules<br \/>\nSlight variations in logic<\/p>\n<p>You end up with:<\/p>\n<p>Repeated code<br \/>\nInconsistent patterns<br \/>\nHard-to-maintain systems<\/p>\n<p>  You\u2019re Not Writing Logic. You\u2019re Rewriting Structure.<\/p>\n<p>Look closer at most endpoints.<\/p>\n<p>They follow the same shape:<\/p>\n<p>Extract input<br \/>\nValidate input<br \/>\nExecute query<br \/>\nHandle errors<br \/>\nReturn response<\/p>\n<p>The structure doesn\u2019t change.<\/p>\n<p>Only the details do.<\/p>\n<p>So why are we rewriting the structure every time?<\/p>\n<p>  The Shift: Define, Don\u2019t Rewrite<\/p>\n<p>Instead of writing endpoints\u2026<\/p>\n<p>Define them.<\/p>\n<p>What if your API looked like this instead?<\/p>\n<p>get:<br \/>\n  user:<br \/>\n    GetUserById:<br \/>\n      input:<br \/>\n        id: number<br \/>\n      where:<br \/>\n        id: $param.id<br \/>\n      response:<br \/>\n        id: number<br \/>\n        name: string<br \/>\n        email: string<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>No route handler.<\/p>\n<p>No repeated boilerplate.<\/p>\n<p>Just a definition.<\/p>\n<p>  What This Changes<\/p>\n<p>When you define systems instead of writing endpoints:<\/p>\n<p>Structure becomes consistent<br \/>\nValidation becomes automatic<br \/>\nQueries become predictable<br \/>\nBehavior becomes visible<\/p>\n<p>You\u2019re no longer guessing how something works.<\/p>\n<p>You can read it directly.<\/p>\n<p>  From Endpoints to Systems<\/p>\n<p>Traditional approach:<\/p>\n<p>Every endpoint is custom<br \/>\nLogic is scattered<br \/>\nBehavior is implicit<\/p>\n<p>System-driven approach:<\/p>\n<p>Endpoints follow a pattern<br \/>\nLogic is structured<br \/>\nBehavior is explicit<\/p>\n<p>You move from \u201ccode-first\u201d to \u201ccontract-first.\u201d<\/p>\n<p>  Where the Code Goes<\/p>\n<p>This doesn\u2019t eliminate code.<\/p>\n<p>It moves it.<\/p>\n<p>Instead of writing endpoint logic repeatedly\u2026<\/p>\n<p>You write:<\/p>\n<p>A compiler that reads definitions<br \/>\nA pipeline that executes them<br \/>\nA system that enforces rules<\/p>\n<p>Code becomes the engine.<\/p>\n<p>Not the repetition.<\/p>\n<p>  Example Flow<\/p>\n<p>With a system-driven approach, a request might flow like this:<\/p>\n<p>Request \u2192 Parse Definition \u2192 Validate \u2192 Build Query \u2192 Execute \u2192 Format Response<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>The difference is:<\/p>\n<p>The flow is constant<br \/>\nThe behavior is defined in configuration<\/p>\n<p>  Why This Matters<\/p>\n<p>Without this approach:<\/p>\n<p>Every developer writes endpoints differently<br \/>\nBugs are repeated across routes<br \/>\nRefactoring becomes painful<\/p>\n<p>With this approach:<\/p>\n<p>Patterns are enforced<br \/>\nBehavior is predictable<br \/>\nSystems scale cleanly<\/p>\n<p>  \u201cIsn\u2019t This Less Flexible?\u201d<\/p>\n<p>Yes.<\/p>\n<p>And that\u2019s the point.<\/p>\n<p>Unlimited flexibility leads to:<\/p>\n<p>Inconsistency<br \/>\nComplexity<br \/>\nFragile systems<\/p>\n<p>Constraints lead to:<\/p>\n<p>  Where This Fits<\/p>\n<p>This kind of system works best when:<\/p>\n<p>You have repeated CRUD patterns<br \/>\nYou want consistent APIs<br \/>\nYou care about long-term maintainability<\/p>\n<p>It doesn\u2019t replace every use case.<\/p>\n<p>But it replaces most of the boring, repetitive ones.<\/p>\n<p>  The Bigger Idea<\/p>\n<p>This isn\u2019t just about APIs.<\/p>\n<p>It\u2019s about how we build software.<\/p>\n<p>Instead of:<\/p>\n<p>Writing everything manually<br \/>\nRepeating patterns<br \/>\nHoping for consistency<\/p>\n<p>We can:<\/p>\n<p>Define systems<br \/>\nEnforce structure<br \/>\nLet the engine handle execution<\/p>\n<p>  Final Thought<\/p>\n<p>Writing endpoints feels like control.<\/p>\n<p>But it\u2019s often just repetition.<\/p>\n<p>Defining systems feels restrictive at first.<\/p>\n<p>But it leads to something better:<\/p>\n<p>Clarity.<\/p>\n<p>Consistency.<\/p>\n<p>Scalability.<\/p>\n<p>That\u2019s why I stopped writing endpoints\u2026<\/p>\n<p>  \u2026and started defining systems.<\/p>\n<p><br \/>\n<br \/><a href=\"https:\/\/dev.to\/stinklewinks\/stop-writing-endpoints-start-defining-systems-4j1g\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For a long time, I thought building APIs meant writing endpoints. You know the pattern: Define a route Validate input Query the database Transform the result Send a response Do that over and over again. Different routes. Same structure. The Illusion of Control Writing endpoints feels productive. You\u2019re in control of everything: The logic The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2549,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[676],"tags":[951,761,765,762,763,764,937,860,760,824],"class_list":["post-2548","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-ai","tag-architecture","tag-coding","tag-community","tag-development","tag-engineering","tag-inclusive","tag-opensource","tag-programming","tag-software","tag-webdev"],"_links":{"self":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts\/2548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2548"}],"version-history":[{"count":0,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts\/2548\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/media\/2549"}],"wp:attachment":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}