Fullstack > Architecture > π MVC Architecture
The Model-View-Controller (MVC) architecture is a widely adopted design pattern for building scalable, maintainable, and modular applications. It separates an application into three main logical components: Model, View, and Controller. Each of these components handles specific responsibilities within the application.
β Why MVC?
MVC helps organize code by separating business logic from UI and user interaction logic. This leads to:
- π οΈ Better maintainability
- β Easier testing
- π Scalable structure
- π Reusability of components
- β¨ Clear separation of concerns
π§© MVC Components
1οΈβ£ Model
The Model represents the applicationβs data and business logic. In a fullstack Spring Boot + Angular application, this layer typically includes:
- ποΈ Entity classes that map to the database schema
- π¦ DTO (Data Transfer Object) classes that define the structure of data exchanged between frontend and backend
- π Mappers for converting between Entities and DTOs
The model ensures data consistency and encapsulates business rules. DTOs help decouple internal persistence models from external API contracts.
2οΈβ£ View
The View is the presentation layer of the application. Its role is to display data to the user and capture user interactions. In a Spring Boot + Angular fullstack application, the view layer can exist in both the backend and frontend, depending on architecture.
In the backend (Spring Boot), the view can be:
- π‘ JSON API responses (common in REST APIs)
- πΌοΈ HTML using Thymeleaf or similar template engines
- π JSP pages (in legacy Java web apps)
- ποΈ XML or other formats (for API integration or legacy systems)
In the frontend (Angular), the view is composed of:
- π¨ Angular components and HTML templates
- π UI logic and data-binding mechanisms
View Responsibilities
- π₯οΈ Render UI based on model data
- π±οΈ Capture user interactions and inputs
- π€ Display feedback and results returned from the controller
3οΈβ£ Controller
The Controller manages the flow of data between the View and the Model. In Spring Boot, controllers expose REST APIs that serve data and handle client requests.
Controller responsibilities include:
- π₯ Handling HTTP requests
- π οΈ Calling service and model layers
- π€ Returning appropriate responses (DTOs or errors)
πΌοΈ Visual Representation

π MVC in Fullstack Applications
Backend (Spring Boot)
- ποΈ Model: JPA Entities, DTOs, and Mappers
- π‘ View:
- JSON API responses (typical in REST APIs)
- HTML (Thymeleaf), JSP, or XML for server-rendered UIs
- π οΈ Controller: REST or web controllers using Spring
Frontend (Angular)
- ποΈ Model: Angular interfaces and services
- π¨ View: Angular HTML templates
- π οΈ Controller: Component class logic and data binding
π Folder Structure Example
```plaintext springboot-angular-app/ βββ backend/ β βββ model/ β βββ dto/ β βββ mapper/ β βββ controller/ β βββ repository/ β βββ Application.java βββ frontend/ β βββ src/app/ β β βββ components/ β β βββ services/ β βββ app.module.ts β βββ main.ts