|
| 1 | +# REST API with Spring Boot and Angular |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +CRUD Angular + Spring demonstrating Has-Many relationship, with tests. |
| 6 | + |
| 7 | +This API is to showcase, especially for beginners, what a basic CRUD API that's close to being Production-ready looks like. |
| 8 | + |
| 9 | +## 💻 Tecnologies |
| 10 | + |
| 11 | +- Java 21 |
| 12 | +- Spring Boot 3 (Spring 6) |
| 13 | +- Maven |
| 14 | +- JPA + Hibernate |
| 15 | +- MySQL |
| 16 | +- JUnit 5 + Mockito (back-end tests) |
| 17 | +- Angular v19 |
| 18 | +- Angular Material |
| 19 | +- Karma + Jasmine (front-end tests) |
| 20 | + |
| 21 | +## ⌨️ Editor / IDE |
| 22 | + |
| 23 | +- Visual Studio Code |
| 24 | +- Java Extensions [link](https://marketplace.visualstudio.com/items?itemName=loiane.java-spring-extension-pack) |
| 25 | +- Angular Extensions [link](https://marketplace.visualstudio.com/items?itemName=loiane.angular-extension-pack) |
| 26 | + |
| 27 | +## Some functionalities available in the API |
| 28 | + |
| 29 | +- ✅ Java model class with validation |
| 30 | +- ✅ JPA repository |
| 31 | +- ✅ JPA Pagination |
| 32 | +- ✅ MySQL database (you can use any database of your preference) |
| 33 | +- ✅ Controller, Service, and Repository layers |
| 34 | +- ✅ Has-Many relationships (Course-Lessons) |
| 35 | +- ✅ Java 17 Records as DTO (Data Transfer Object) |
| 36 | +- ✅ Hibernate / Jakarta Validation |
| 37 | +- ✅ Unit tests for all layers (repository, service, controller) |
| 38 | +- ✅ Test coverage for tests |
| 39 | +- ✅ Spring Docs - Swagger (https://springdoc.org/v2/) |
| 40 | + |
| 41 | +### Not implemented (maybe in a future version) |
| 42 | + |
| 43 | +- Security (Authorization and Authentication) |
| 44 | +- Caching |
| 45 | +- Data Compression |
| 46 | +- Throttling e Rate-limiting |
| 47 | +- Profiling the app |
| 48 | +- Test Containers |
| 49 | +- Docker Build |
| 50 | + |
| 51 | +## Some functionalities available in the front end |
| 52 | + |
| 53 | +- ✅ Angular Standalone components (Angular v16+) |
| 54 | +- ✅ Angular Material components |
| 55 | +- ✅ List of all courses with pagination |
| 56 | +- ✅ Form to update/create courses with lessons (has-many - FormArray) |
| 57 | +- ✅ View only screen |
| 58 | +- ✅ TypedForms (Angular v14+) |
| 59 | +- ✅ Presentational x Smart Components |
| 60 | +- 🚧 Unit and Integration tests for components, services, pipes, guards |
| 61 | + |
| 62 | +## Screenshots |
| 63 | + |
| 64 | +Main Page with Pagination |
| 65 | + |
| 66 | +<p align="center"> |
| 67 | + <img src="./docs/main.jpeg" alt="Main Page" width="100%"> |
| 68 | +</p> |
| 69 | + |
| 70 | +Form with One to Many (Course-Lessons) |
| 71 | + |
| 72 | +<p align="center"> |
| 73 | + <img src="./docs/form.jpeg" alt="Form Page" width="100%"> |
| 74 | +</p> |
| 75 | + |
| 76 | +View Page with YouTube Player |
| 77 | + |
| 78 | +<p align="center"> |
| 79 | + <img src="./docs/view.jpeg" alt="View Page" width="100%"> |
| 80 | +</p> |
| 81 | + |
| 82 | +## ❗️Executing the code locally |
| 83 | + |
| 84 | +### Executing the back-end |
| 85 | + |
| 86 | +You need to have Java and Maven installed and configured locally. |
| 87 | + |
| 88 | +Open the `crud-spring` project in your favorite IDE as a Maven project and execute it as Spring Boot application. |
| 89 | + |
| 90 | +### Executing the front-end |
| 91 | + |
| 92 | +You need to have Node.js / NPM installed locally. |
| 93 | + |
| 94 | +1. Install all the required dependencies: |
| 95 | + |
| 96 | +``` |
| 97 | +npm install |
| 98 | +``` |
| 99 | + |
| 100 | +2. Execute the project: |
| 101 | + |
| 102 | +``` |
| 103 | +npm run start |
| 104 | +``` |
| 105 | + |
| 106 | +This command will run the Angular project with a proxy to the Java server, without requiring CORS. |
| 107 | + |
| 108 | +Open your browser and access **http://localhost:4200** (Angular default port). |
| 109 | + |
| 110 | +#### Upgrading Angular |
| 111 | + |
| 112 | +``` |
| 113 | +ng update |
| 114 | +``` |
| 115 | + |
| 116 | +Then |
| 117 | + |
| 118 | +``` |
| 119 | +ng update @angular/cli @angular/core @angular/cdk @angular/material @angular/youtube-player --force |
| 120 | +``` |
0 commit comments