Search code examples
javaspringwebspring-web

How to organize URLs in web projects


There's plenty of resources that outline how URLs should be organized for RESTful APIs but for web in general there's little to be found.

How can I structure the URLs of the web pages so that they are

  1. Sensible from the perspective of a user browsing the web
  2. Sensible from a separation of concerns in a Spring framework controller

To apply some context let's assume there's groups that contains elements and there are uses cases to create, view, edit and delete both.


Solution

  • You may have had trouble finding information about this since it's a question that touches on Information Architecture (IA) and SEO, in addition to application design. If your application or site is available on the internet (rather than an internal private network) then you have to optimize multiple, sometimes conflicting, constraints:

    1. Making the urls sensible and understandable to users
    2. Make your scheme manageable and scalable
    3. Understand which portions of your app or site need to be indexible by search engines
    4. Maintain good application design (think SOLID)
    5. Probably several others ...

    In general, I would suggest that you start with identifying your constraints, and consider "what makes sense to users" as a high priority one. Then try to work in other constraints from there. Since you mention separation of concerns, you have a good sense of what some of your design constraints are. Ultimately, it's up to you (and maybe your business SMEs) to determine which constraints need to be rigid, and which others can be relaxed.