r/SpringBoot • u/RecursionHellScape • Jan 04 '26
Discussion Built a Spotify-like backend with Spring Boot – Looking for feedback 🚀
TL;DR:
Built a Spotify-like backend using Spring Boot + JPA + PostgreSQL with songs, artists, albums, and playlists. Looking for feedback on architecture, service design, and ideas to make it more production-ready. Any suggestions welcome!
Hey everyone 👋
I built a music streaming backend (Spotify-style) using Spring Boot as a learning + portfolio project and would love some feedback.
Tech Stack
- Java 17, Spring Boot
- Spring Data JPA (Hibernate)
- PostgreSQL
- Gradle, Postman
What it does
- Manage Songs, Artists, Albums, Playlists
- Many-to-Many & One-to-Many relationships
- Create playlists, add/remove songs
- Fetch songs by artist/album/playlist
What I want feedback on
- Project structure & design
- Service/repository layer quality
- Should I switch fully to DTOs?
- Features worth adding next
- How to make it more production-ready
This project helped me learn real-world JPA issues (lazy loading, relationships, transactions).
Any suggestions or improvements are welcome. Thanks! 🙌
15
u/guss_bro Jan 04 '26 edited Jan 04 '26
Few feedback
- you can use `@ControllerAdvice` and `@ExceptionHandler` to handle the exceptions in one place that you are currently handling in each Controller methods.
- There's no need for Service and ServiceImpl. You can get rid of the interfaces.
- Add tests
- Try using docker-compose and TestContainer
- Dockerize your app
- create native image
- Try integrating springdocs swagger
- Try upgrading to new spring boot 4
- Perform load test and watch out for any N+1 query issues and fix them
- add security with different user role. use plain JDBC based user auth and upgrade that to use OIDC using keycloak later.
10
u/Outrageous_Ranger812 Jan 04 '26 edited Jan 04 '26
Had a peek at your project, you have structured it really well. The project looks really solid. I have given a star to your repo.
You can make the project even better by writing a good documentation - I'm sharing my GitHub project which has good readme you can refer this to get an idea of how to write a good README. Pls give it a star if you like it.
https://github.com/harish124/movie-app-react
Also make sure you containerise your project using docker and add Dockerfile, so that if someone wants to quickly run your project they can run it using you docker file.
Implement Pagination this is non-negotiable. Currently the getPlaylists() method returns all the results. If you have thousands of results your app would break.
Create interfaces directory and have your interfaces there don't keep them in your service classes.
In your service classes implementations, I see that you're using Constructor Injection, but I see you're using Lombok dependency, so you could use `@RequiredArgsConstructor in your class instead of Constructor injection.
Add LOGGER to your classes.
Add screenshots to your project.
In you application.properties file you have hardcoded password. Use environment variables instead, so that you don't accidentally commit these to GitHub.
In your controller have the endpoint like this - /v1/albums... always mention the version number
Add a description to your project, add tags to your GitHub repo.
Instead of org.example use org.projectname.
Don't push .idea file to GitHub add this to your gitignore file.
Add junits.
Create CONTRIBUTION md, LICENSE File, PR template files in your GitHub repo.
3
u/SectionMore Jan 04 '26
As someone who's learning SpringBoot this seems like a great repo to read through, looks cool!
2
u/WaferIndependent7601 Jan 04 '26
Don’t put all controllers in a controller package. Put everything that is used for an album to an album package
Don’t use multiple repositories in a service. Use the other service layer if you need data from another package
Create dtos
1
u/trodiix Jan 04 '26
Next, you can try the same project but with hexagonal architecture and compare the differences, it can help you a lot understanding how to build a larger project in the future.
1
u/st4reater Jan 04 '26
You deleted the test directory??
1
u/Vanln Jan 04 '26
Had a quick look at it on my phone, I think this can help you:
Model: Try to add some basic validation on your model class (can the title be empty? Can the duration be negative/null? Etc.). I suggest not using @Setters and only expose fields you actually need. Use constructors to validate your object, they are the base of your business, you should ensure they will always be in a valid state. I'm mentioning this because I saw you are instantiating an empty object and use setX, setY. Constructors should dictate which fields are necessary to instantiate the object. Have a look at hibernate and javax validation annotations.
Also, you are using the annotations for the database in your model. I would keep this separate. One class is the model needed for the business, the other one is a representation of a database table. This is coupling infrastructure to your model. Think of this: supposing you change anything on the database level (column name, add a new field, etc.). Ideally, this should not impact your model class. The way you did, even if you separate model/database layers through interfaces, you have a direct dependency of layers.
Controller: create an exception handler class. You will be able to declare the actual object of your controller methods instead of using "?". This will also help in case you decide to use Swagger docs.
Yes, I would use DTOs to call your service methods instead of passing a Request object directly from the controller layer. I would keep the request object for the controller, and possibly create a mapper class to convert it to the object your service expects (a bit unnecessary to the project size, but it's important on bigger projects. It also makes your life easier in tests). Have a look at Mapstruct.
I agree that the interface for controller-service is a bit unnecessary for this project. But again, it's good and important that you have this in mind. An interface for the service-repository layers would be more helpful to you and make your life easier for tests as well.
Overall, good job.
1
u/InfernOrangeJuice Jan 04 '26 edited Jan 04 '26
Hi! Good job. Some things that were not mentioned yet:
1
u/ikutotohoisin Jan 04 '26
Kinda curious as to why did you made a separate class for each of the services and inherited them in impl class
1
u/krishhna_ Jan 05 '26
How many YOE do you have bro ??
1
u/FunPressure1336 Jan 25 '26
Solid project. Using Spring Boot with PostgreSQL is a great way to learn the basics. You should move to DTOs for sure. It keeps your database entities safe and makes the API way cleaner to work with. Maybe try adding some unit tests or Docker next to make it feel more like a real world app. Nice job getting those relationships sorted.
1
u/No_Papaya_2442 Senior Dev Jan 05 '26
Im new to spring boot learning from engineering digest he suggested that shifting old project to DTOs it make it understandable for newbies and easy to understand..
Note: After completing this series i want to learn more about spring like how to start any backend project.. like im already a android dev since 3 years now i want to create my own api, can you help me out with this.
-2
u/UniqueTennis9351 Jan 04 '26
Spring reactive is like the future and I would highly recommend replacing non reactive flow with reactive ones.