Skip to content

Commit 0410a70

Browse files
committed
init
0 parents  commit 0410a70

File tree

106 files changed

+29098
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+29098
-0
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "maven" # See documentation for possible values
9+
directory: "crud-spring" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
12+
- package-ecosystem: "npm" # See documentation for possible values
13+
directory: "crud-angular" # Location of package manifests
14+
schedule:
15+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: CI with Maven and Angular
10+
11+
on:
12+
push:
13+
branches: [ "main" ]
14+
pull_request:
15+
branches: [ "main" ]
16+
17+
jobs:
18+
java:
19+
name: Maven Build
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
cache: maven
29+
- name: Build with Maven
30+
run: mvn -B package --file crud-spring/pom.xml
31+
angular:
32+
name: Angular Build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout the source code
36+
uses: actions/checkout@v3
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: 20
41+
cache: 'npm'
42+
cache-dependency-path: crud-angular/package-lock.json
43+
- name: Install dependencies
44+
run: npm ci
45+
working-directory: crud-angular
46+
- name: Run tests
47+
run: npm run test:ci
48+
working-directory: crud-angular
49+
- name: Build
50+
run: npm run build
51+
working-directory: crud-angular

.github/workflows/ng-update.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Update Angular Action"
2+
on: # when the action should run. Can also be a CRON or in response to external events. see https://git.io/JeBz1
3+
schedule:
4+
- cron: '30 5 * * 1,3,5'
5+
6+
jobs:
7+
ngxUptodate:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Updating ng dependencies # the magic happens here !
11+
uses: fast-facts/ng-update@v1
12+
with:
13+
base-branch: main
14+
project-path: ./crud-angular
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/settings.json

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"configurations": [
3+
{
4+
"type": "java",
5+
"name": "Spring Boot-CrudSpringApplication<crud-spring>",
6+
"request": "launch",
7+
"cwd": "${workspaceFolder}",
8+
"mainClass": "com.loiane.CrudSpringApplication",
9+
"projectName": "crud-spring",
10+
"args": "",
11+
"envFile": "${workspaceFolder}/.env"
12+
}
13+
]
14+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Loiane Groner
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# REST API with Spring Boot and Angular
2+
3+
![Build](https://github.com/tortuc/angular-springboot-crud/actions/workflows/build.yml/badge.svg?branch=main)
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+
```

crud-angular/.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

crud-angular/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": [
4+
"loiane.angular-extension-pack",
5+
"loiane.ts-extension-pack",
6+
]
7+
}

0 commit comments

Comments
 (0)