r/Backend • • Jun 13 '26

How to design backend before actually coding it

Im working on a e commerce website using spring boot.

Initially i have created end point ' /products ' and written CRUD functions in ProuctController.java and follwed MVC architecture and also connected database also. (Spring Data JPA)

Then using antigravity i cteated a react project with prompt explaining my project.

Now im confused! How to proceed writing backend.

Like for every button i should be writing a API.

Or for every table in my database i need to write CRUD functions.

Help!

28 Upvotes

13 comments sorted by

14

u/dbsaw Jun 13 '26 edited Jun 13 '26

You need to get back to the fundamentals. The backend handles all the processes that the user doesn't see. For example, the user wouldn't care which database you are using; this is your choice depending on your preference and the business needs. Starting with CRUD for all tables is a great starting point, and most of the time, yes, you'll need that. However, moving forward, you might see that some entities don't need an endpoint because they are either unused or would create some vulnerabilities. You'll gain this knowledge as you get more experience. Do you need an endpoint for each button? Maybe it depends on your business needs, but as I mentioned earlier, anything related to the UI that can be displayed to the user without touching the backend, like the logo or about us page, can technically be served by the backend, but I think they fit the front-end more. Again, there is no standard way of doing things; it's all about trade-offs. The nice thing about software development is that you can do whatever you want, however you want, and most of the time, it's free. If you don't get it right the first time, you'll most likely learn a lot. Good luck!

2

u/draeky_ Jun 13 '26

Im right now building personal projects to understand spring boot more.

From your knowledge what i have understood is while creating endpoints or controller functions think in pov of database. Max all data in the database needs controller functions but for some private data like passwords, account details needs security. For them we wont create.

Can i follow this approach. Correct if im wrong pls

→ More replies (1)

1

u/draeky_ Jun 13 '26

Thanks mate! Helpful

→ More replies (1)

6

u/[deleted] Jun 13 '26

[removed] — view removed comment

2

u/Odd_Cow7028 Jun 13 '26

This is the closest to an actual answer I've seen on this post. It's good advice. It should also be noted that "creating an ecommerce website" is not trivial. Simple CRUD will not be sufficient; there's a ton of business logic. You mentioned validating stock, calculating prices, and creating order items. What happens when an item is in stock when the item is added to the cart, but not in stock after the shipping data has been entered? How are discounts figured into prices, and how are taxes calculated? And how are order items different from items in the product catalog? These are questions the OP will need to answer, and the data models they use will reflect those answers. "Like for every button i should be writing an API" makes me think they are way out of their depth.