I wanted to challenge myself to apply Clean Architecture and Domain-Driven Design (DDD) from the ground up β not in a greenfield project, but starting from total mess.
So I built Spaghetti API: a deliberately chaotic Spring Boot project, full of bad practices, no architecture, and zero tests.
It looks like this π
src/main/java/com/example/spaghetti
βββ ControllerService.java // controller acting as service
βββ ModelRepoController.java // model + repo + controller in one
βββ Utils.java // weird helpers
βββ MainConfig.java // useless bean
βββ SpaghettiApplication.java
π§© Why?
Because most real-life projects donβt start clean β they evolve from chaos. I wanted to document how I bring order, step by step.
π οΈ My refactoring path
- Separate responsibilities (controller, service, repo, model)
- Introduce Clean Architecture layers
- Apply DDD concepts with proper domain modeling
- Add DTOs, validations, global error handling
- Implement unit and integration tests
β Technologies
- Java 17
- Spring Boot 3
- Maven
π Source Code
π github.com/gabrielapuig/spaghetti-api
If you're dealing with a messy legacy codebase π§Ή, or want to level up your architecture skills in Java βοΈ, follow along β Iβll be sharing each refactor stage π and breaking it down step-by-step.
Ever worked on a project like this? π€ I'd love to hear how you handled it!
Top comments (3)
this is extremely impressive seeing someone work through a real mess instead of just showing a polished demo makes it way more useful for me you think starting with chaos actually speeds up learning or just adds extra pain
Thanks! I do think starting with chaos is harder, but it teaches way more. You're forced to really understand whatβs going on instead of just following steps.
Painful? Yes. Worth it? Definitely. π
Very interesting idea!! Iβll join this Spaghetti journeyβΊοΈπ