[Codevel Project] - How I Organize My Spring Boot Backend Project

In this post, I share how I organize the backend of my project (Spring Boot) for codevel.io. From folder structure (config, controllers, services, repositories, etc.) to the main workflow when an API is called. This is not a strict rulebook—just a practical reference you can adapt to your own projects.

In this post, I want to share how I structure the backend (Spring Boot) part of my project.

First things first: there’s no single “correct” way to organize your codebase. Every dev and every team has their own style. You don’t need to blindly copy someone else’s structure. Just pick what makes sense for your project and workflow. Modern IDEs also generate a base structure for you, so you can always tweak it later.

So, what I’m sharing here is just for reference. If it fits your case, feel free to use it. If not, code in the way that works best for you. The most important thing is keeping your code clear and maintainable.


My backend folder structure

I’ll skip the default files like pom.xml, .gitignore, application.properties, etc., and go straight into src/main/java.

pagnation

1. Config

This package stores configuration files. For example, I have a SecurityConfig class where I define Spring @Beans, handle CORS, and set up a filterChain to control API access by URL.

2. Controllers

Classes here are annotated with @RestController. Their job is to route requests to the correct endpoints.
I usually group them by data type. For example, PostController handles all endpoints related to posts (PostEntity).

3. Converters

Responsible for transforming raw database data into JSON responses.
For instance: when returning User, you don’t want to expose the password field. Or with Post, you might want to include the related Category data as well. That’s where converters step in.

4. DTO (Data Transfer Object)

Defines request and response objects. Each request/response class contains fields and validation annotations like @NotNull, @Size, etc.

5. Entities

Holds entity classes, each mapping directly to a database table.

6. Repository

Contains interfaces that extend JpaRepository. This allows database operations through JPA/Hibernate without writing raw SQL.

7. Services

Where the main business logic lives. Controllers call services to fetch data, process it (create, update, delete), and return the final response to the client.

Here’s how the backend workflow on codevel.io looks when an API request comes in:

pagnation

II. Wrapping up

That’s how I organize the backend for my project codevel.io. For me, this structure makes the project easy to maintain and extend. But again, you don’t need to follow it strictly – just pick what feels right for your app.

In the next post, I’ll walk through how I structure the frontend (Next.js) side.
Thanks for reading!

 

Next/Previous Post

buymeacoffee
[Codevel Project] - How I Organize My Spring Boot Backend Project - codevel.io | Codevel.io