Skip to content
ํ”„๋กœ์ ํŠธ

์†Œ๊ฐœ

๐Ÿ–ฅ CRUD Angular + Spring demonstrating Has-Many relationship, including tests for the back-end and front-end

์›น ๋ฐ ์•ฑ ๊ฐœ๋ฐœ

์ด ์ˆ˜์น˜๋ฅผ ์ธก์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

์ธก์ •๋œ ์Šคํƒ€ ์ฆ๊ฐ€

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘

์„œ๋กœ ๊ฒน์น˜๋Š” ๊ธฐ๊ฐ„์˜ ์ˆœ์ฆ๊ฐ€๋Ÿ‰์ด๋ฉฐ ์ผ๋ณ„ ํ•ฉ๊ณ„๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ์ธก์ •๊ฐ’์ด ์—†์œผ๋ฉด ๋น„์›Œ ๋‘ก๋‹ˆ๋‹ค. ์Šคํƒ€๋Š” ๊ด€์‹ฌ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ ํ’ˆ์งˆ์„ ๋ณด์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

README.md

Original

REST API with Spring Boot and Angular

Build

CRUD Angular + Spring demonstrating Has-Many relationship, with tests.

This API is to showcase, especially for beginners, what a basic CRUD API that's close to being Production-ready looks like.

๐Ÿ’ป Tecnologies

  • Java 25
  • Spring Boot 4 (Spring 7)
  • Maven
  • JPA + Hibernate
  • MySQL
  • JUnit 5 + Mockito (back-end tests)
  • Testcontainers (back-end integration tests)
  • Angular v22
  • Angular Material
  • Karma + Jasmine (front-end tests)

โŒจ๏ธ Editor / IDE

  • Visual Studio Code
  • Java Extensions link
  • Angular Extensions link

Some functionalities available in the API

  • โœ… Java model class with validation
  • โœ… JPA repository
  • โœ… JPA Pagination
  • โœ… MySQL database (you can use any database of your preference)
  • โœ… Controller, Service, and Repository layers
  • โœ… Has-Many relationships (Course-Lessons)
  • โœ… Java Records as DTO (Data Transfer Object)
  • โœ… Hibernate / Jakarta Validation, including custom validators
  • โœ… Unique course name enforcement (service check + database constraint)
  • โœ… Soft delete (deleted courses are marked inactive, not removed)
  • โœ… Transactional service layer (Open Session in View disabled)
  • โœ… Consistent error responses with RFC 7807 Problem Details
  • โœ… Unit tests for all layers (repository, service, controller)
  • โœ… Integration tests with Testcontainers (real MySQL in Docker)
  • โœ… Test coverage reports with JaCoCo
  • โœ… Spring Docs - Swagger UI (springdoc.org)

Not implemented (maybe in a future version)

  • Security (Authorization and Authentication)
  • Caching
  • Data Compression
  • Throttling e Rate-limiting
  • Profiling the app
  • Docker Build

Some functionalities available in the front end

  • โœ… Angular Standalone components
  • โœ… Angular Signals (signal, computed, httpResource)
  • โœ… Zoneless change detection (Angular v22 default)
  • โœ… Built-in control flow (@if, @for)
  • โœ… Lazy loading with loadComponent routes
  • โœ… Angular Material components
  • โœ… List of all courses with pagination
  • โœ… Form to update/create courses with lessons (has-many)
  • โœ… View only screen
  • โœ… Signal Forms (form, FormField - stable in Angular v22)
  • โœ… Presentational x Smart Components
  • โœ… Unit and Integration tests for components, services, pipes, guards

Screenshots

Main Page with Pagination

Main Page

Form with One to Many (Course-Lessons)

Form Page

View Page with YouTube Player

View Page

โ—๏ธExecuting the code locally

Executing the back-end

You need to have Java and Maven installed and configured locally.

Open the crud-spring project in your favorite IDE as a Maven project and execute it as Spring Boot application.

Once running, the API docs are available at http://localhost:8080/swagger-ui.html.

Using MySQL (dev profile)

To run against MySQL instead, start the database with Docker (also starts phpMyAdmin on port 8081):

cd crud-spring
docker compose up -d

Then run the app with the dev profile. The connection can be customized with the MYSQL_HOST, MYSQL_USER and MYSQL_PASSWORD environment variables (in the prod profile, the credentials are required). The dev profile preserves data between restarts; to seed a fresh database, run src/main/resources/schema.sql manually.

Back-end tests

cd crud-spring
./mvnw test

Unit tests run in-memory; the integration tests use Testcontainers and require Docker to be running.

Executing the front-end

You need to have Node.js / NPM installed locally.

  1. Install all the required dependencies:
npm install
  1. Execute the project:
npm run start

This command will run the Angular project with a proxy to the Java server, without requiring CORS.

Open your browser and access http://localhost:4200 (Angular default port).

Upgrading Angular

ng update

Then

ng update @angular/cli @angular/core @angular/cdk @angular/material @angular/youtube-player --force

๊ด€๋ จ ํ”„๋กœ์ ํŠธ ์‚ดํŽด๋ณด๊ธฐ

๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ