TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Building a CMS – Client or API Centric

1 pointsby ilmiontalmost 9 years ago
I&#x27;m in the advanced stages of building a CMS, from scratch. I&#x27;ve finally got around to adding support for tags - i.e. &quot;#Microsoft #smartphones&quot; on an article about a Lumia, to help you find articles.<p>I&#x27;ve run into a major architectural issue I&#x27;d like some insight in. The tags and posts are stored in separate tables and linked via a posts_tags table with foreign key to join the two. Therefore, to create the post and tags, requests are required to both &#x2F;post&#x2F;create and &#x2F;taglinker&#x2F;create on the API.<p>I&#x27;m not sure where to place the responsibility for these actions. I&#x27;ve considered two scenarios:<p>1) API-centric. The client calls &#x2F;post&#x2F;create and the post itself is created. The client then has to make its own requests to &#x2F;taglinker&#x2F;create to handle adding the tags. This maintains the API&#x27;s integrity - each endpoint has one very obvious purpose.<p>2) Client-centric. Calling &#x2F;post&#x2F;create, with the desired tag IDs as a parameter, will create the post <i>and</i> transparently link all the specified tags. The API takes responsibility, calling &#x2F;taglinker&#x2F;create as many times as required from &#x2F;post&#x2F;create. This would be much easier to implement client-side but would lead to some blurring of the capabilities of each API endpoint. This could be acceptable though, since it can be assumed that a call to &#x2F;post&#x2F;create will invoke calls to &#x2F;taglinker&#x2F;create, so the API linking the tags could be perceived as it just fulfilling the intended function.<p>Any thoughts?

no comments

no comments