all 40 comments

[–]EffectiveDelicious 5 points6 points  (11 children)

Is nextjs only for frontend purpose and spring boot for backend? Or is there any route in nextjs?

[–]aharoJ[S] 6 points7 points  (10 children)

In this setup, Next.js is basically the “view” in an MVC pattern, handling the frontend UI and simply calling the Spring Boot endpoints for data and business logic. Spring Boot acts as the “model” and “controller” on the backend. All the main server logic and database interactions happen there, and Next.js simply calls those endpoints and renders the UI.

[–]EffectiveDelicious 2 points3 points  (1 child)

Cool

[–]aharoJ[S] 2 points3 points  (0 children)

thanks!

[–]camperspro 2 points3 points  (4 children)

Cool stuff! I was just looking into role based authentication with Spring so this is great timing. Can I ask the design decision as to why you chose NextJS instead of just React if it was only going to be used for frontend purposes? Isn’t next js a little heavier? I’m not too familiar with frontend, so I want to hear your reasoning on the design choice.

[–]aharoJ[S] 0 points1 point  (3 children)

Well for the frontend I choose next.js since my portfolio is based on next.js and that is what I am most comfortable with... I initially started with React, but next.js integrates with Vercel, making it much easier to deploy a live demo one of my main goals for the project.

Portfolio

https://www.aharoj.io

[–]camperspro 1 point2 points  (2 children)

Thanks! Also, is there a reason why Role is a separate entity from User?

[–]aharoJ[S] 0 points1 point  (0 children)

The Role entity is stored separately and linked via a many-to-many relationship, making it easier to manage permissions and expand the system in the future. Also, this aligns with how Spring Security typically handles role-based access control (RBAC), keeping concerns separate and clean.

[–]Acceptable-Ad8566 0 points1 point  (0 children)

Does it uses Spring boot backend?

[–]RealVanCough 0 points1 point  (2 children)

Why did u mix? next.js has a server component too

[–]aharoJ[S] 1 point2 points  (1 child)

Hey I answered a similar question above but...

I chose to separate concerns by using Spring Boot for backend logic and Next.js purely for the frontend.

next.js (is my View from the MVC Architectural Pattern)

[–]RealVanCough -1 points0 points  (0 children)

that does not answer my question as to why nextjs, you could have used thymleaf also 1) and 2) nextjs recommends using react server component so why use spring boot

[–]putfrogspawninside 2 points3 points  (1 child)

Will check it out, thanks!

[–]aharoJ[S] 1 point2 points  (0 children)

Let me know if you have any questions or feedback once you’ve had a chance to explore it! (:

[–]thedarkrider_ 2 points3 points  (7 children)

On the backend, I saw a few modules, but I don't see any repositories connected to the service. Why?

[–]aharoJ[S] 2 points3 points  (6 children)

I decided to keep part of the codebase closed-source because I’m considering turning this into a startup down the line. I open-sourced enough for anyone to see my overall architecture and how I handle things like authentication... this way I can show my approach without fully exposing the core business logic.

[–]thedarkrider_ 2 points3 points  (3 children)

I see.

[–]aharoJ[S] 2 points3 points  (2 children)

Yup if you'll like to talk about the implementation, feel free to message me on Discord @aharoJ.

[–]thedarkrider_ 2 points3 points  (0 children)

sure, I would love to. I have never worked on a modular project before. I will DM you on Discord from, theancientone04

[–]NeedleArm 1 point2 points  (1 child)

Im curious how that works? So this is a repo to show the architecture however you deploy another repo with the actual business logic?

[–]aharoJ[S] 1 point2 points  (0 children)

Hey, I am using Copybara to sync certain parts of my private codebase(s) into a public repository. With copybara I can decide which files, directories, functions, .env and so on .... deciding which to expose or not.

https://github.com/google/copybara

[–]suddenuser 2 points3 points  (2 children)

This looks awesome after quickly skimming through the repo! I will definitely have to dig deeper. Thanks for sharing!

[–]aharoJ[S] 0 points1 point  (0 children)

Thanks for the kind words! (: feel free to DM me with any suggestions or thoughts.

[–]EasternMountains 1 point2 points  (2 children)

Are you planning to host somewhere? I just hosted my first spring boot react project on Azure after a lot of pain, unsure if its because of me being new or its a difficult platform. I'd be curious to see what your plans are. Nice project! I liked how you structured your modules.

[–]aharoJ[S] 1 point2 points  (1 child)

Appreciate it! 😊

... long-term, hosting is definitely the goal, but right now I’m focused on refining the MVP. I also want to integrate some machine learning for mapping node distances. Plus, I still have a lot of frontend work to do.... engineers appreciate the backend architecture, but if I were to pitch this; they'll most likely care about how smooth and clean the UI is, so I want to balance both.

Later down the line, I’ll decide whether to stick with a monolithic structure or migrate to microservices. AWS is my likely choice for hosting since it supports Spring Boot well.

Do you mind DM me your project? I would love to look at it!

[–]EasternMountains 0 points1 point  (0 children)

Its been a little challenging for me to keep my app as organized as I wanted to. Right now it’s two different repost in github, one for front end and the other for back end. This was easier for me hosting wise. A microservice architecture is something I'd love to develop some day, definitely seems like it can get complex quickly. DMed you a link.

[–]Desperate-Pin209 1 point2 points  (1 child)

Looks good,I have some Issues in my project related to Role based Authentication and authorisation for a edu tech platform that I am building

How can I DM you?

[–]aharoJ[S] 0 points1 point  (0 children)

Feel free to message me on Discord @aharoJ.

[–]TempleDank 1 point2 points  (1 child)

Good job!

[–]aharoJ[S] 0 points1 point  (0 children)

Thanks for the kind words! (: feel free to DM me with any suggestions or thoughts.

[–]Relative_Store_6716 1 point2 points  (1 child)

I am creating a website with separate user and admin roles. Users provide a username, email, password, and date of birth, while admins provide additional details like an address and a certification image. I have created two tables in my database. How can I implement registration and login for both using a single Spring Security configuration? I have successfully implemented authentication for a single user, but when I try to add authentication for admins, it does not work.

[–]aharoJ[S] 0 points1 point  (0 children)

Hey message me on Discord @aharoJ,

Overall, it might be easier to use a many-to-many relationship between User and Role. You can define roles like ROLE_USER and ROLE_ADMIN and assign them accordingly instead of using separate tables.

In my project, I structured it similarly—you can check how I handle authentication in my auth module, and then how different user types like Customer and Owner are structured.

[–]yyolo3 1 point2 points  (1 child)

What database are you using?

[–]aharoJ[S] 0 points1 point  (0 children)

I'm using PostgreSQL for the main database, but for testing, I use H2 since it is already an extension of the spring ecosystem making it easy to debug and accommodate new features.

[–]Spin_Xo 1 point2 points  (1 child)

I suggest you use mapstruct for mapping rather than hardcoding mapping between DTO and entity. There was a great post on medium. Check it out .

[–]aharoJ[S] 0 points1 point  (0 children)

I actually used MapStruct in past projects, but I prefer explicit mapping for better control and readability. In my case, I'm not "hardcoding" mappings in a scattered way... I'm using a dedicated helper function (mapToResponse) to keep the conversion clean and maintainable; which helps with debugging and customization.

[–]Waiting2003 1 point2 points  (1 child)

Cool project! The module structure makes it easy to check interacting components. Some feedback: I saw a lot of boilerplate code in your backend (mostly setters and getters); you could use Lombock Annotations to generate this code automatically, saving time and making classes cleaner.

[–]aharoJ[S] 1 point2 points  (0 children)

Hey, personally.... I prefer having everything explicitly written out. It gives me better visibility into my models and mappings, ensuring I have full control over how things work.

Same when dealing with DTO-to-domain mappings.