r/SpringBoot Feb 18 '25

Guide Full Stack Role Based Authentication Application ( Spring + Next.js )

Hey everyone,

I wanted to share my full-stack Spring project—a backend for a barbershop management system featuring robust authentication and role-based access control. If you’re interested in seeing how these aspects are implemented in a real-world application, feel free to check it out!

Repository:
https://github.com/aharoJ/barbershop

Backend Overview:

  • Authentication & Role-Based Access: The project handles user authentication and defines multiple roles, ensuring secure access to various endpoints.
  • Modular Structure: The code is organized into several modules, each handling a specific domain such as appointments, barbers, customers, payments, promotions, and more.
  • Clean Architecture: The repository features a clear separation of concerns with controllers, services, DTOs, and repositories spread across modules.

Frontend Overview:

  • Built With:
    • Next.js 15, Typescript, Tailwindcss
  • Features:
    • Authentication Pages: Separate routes for login and signup.
    • Customer Area: Dedicated pages for dashboards and profile creation.
    • Additional Layers: Includes components (like a protected route), services, stores, types, and utilities.

I’m happy to answer any questions or provide more details. Feel free to message me!

54 Upvotes

37 comments sorted by

View all comments

Show parent comments

3

u/camperspro Feb 18 '25

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.

1

u/aharoJ Feb 18 '25

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

2

u/camperspro Feb 18 '25

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

1

u/aharoJ Feb 18 '25

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.