Skip to content

Commit 011d1f2

Browse files
committed
feat: project modernization and rewrite
1 parent 3f6be3a commit 011d1f2

126 files changed

Lines changed: 16695 additions & 16330 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build-backend:
11+
name: Build & Test Backend
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '21'
22+
distribution: 'temurin'
23+
cache: maven
24+
25+
- name: Build and test API
26+
working-directory: api
27+
run: mvn clean verify --batch-mode --no-transfer-progress
28+
29+
build-frontend:
30+
name: Build Frontend
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Set up Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '22'
41+
cache: 'npm'
42+
cache-dependency-path: client/package-lock.json
43+
44+
- name: Install dependencies
45+
working-directory: client
46+
run: npm ci
47+
48+
- name: Build Angular app
49+
working-directory: client
50+
run: npm run build:prod
51+
52+
- name: Run tests
53+
working-directory: client
54+
run: npm run test:ci
55+
continue-on-error: true
56+
57+
build-full:
58+
name: Full Maven Build
59+
runs-on: ubuntu-latest
60+
needs: [build-backend, build-frontend]
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Set up JDK 21
67+
uses: actions/setup-java@v4
68+
with:
69+
java-version: '21'
70+
distribution: 'temurin'
71+
cache: maven
72+
73+
- name: Set up Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: '22'
77+
78+
- name: Build entire project
79+
run: mvn clean package --batch-mode --no-transfer-progress -DskipTests

.travis.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 123 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,161 @@
1-
angular_bootstrap_spring
2-
========================
3-
[![Build Status](https://travis-ci.org/Rob-Leggett/angular_bootstrap_spring.svg?branch=master)](https://travis-ci.org/Rob-Leggett/angular_bootstrap_spring)
1+
# Angular Bootstrap Spring
42

5-
Angular JS with Bootstrap and Spring 4 and Spring Security.
3+
[![CI](https://github.com/Rob-Leggett/angular_bootstrap_spring/actions/workflows/ci.yml/badge.svg)](https://github.com/Rob-Leggett/angular_bootstrap_spring/actions/workflows/ci.yml)
4+
[![Java](https://img.shields.io/badge/Java-21-orange.svg)](https://openjdk.org/projects/jdk/21/)
5+
[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.3-green.svg)](https://spring.io/projects/spring-boot)
6+
[![Angular](https://img.shields.io/badge/Angular-19-red.svg)](https://angular.dev/)
7+
[![Bootstrap](https://img.shields.io/badge/Bootstrap-5.3-purple.svg)](https://getbootstrap.com/)
68

7-
This example is an angular js single page application (SPA) with bootstrap for the widgets and styling.
9+
A modern single-page application built with **Angular 19** and **Bootstrap 5** for the frontend, backed by **Spring Boot 3.3** with **Spring Security 6** for the API.
810

9-
The application has been broken into two modules API and CLIENT, both are built separately and both are deployed separately.
11+
## Tech Stack
1012

11-
The API can run on any web server, but it has been tested against Tomcat 8, the server required http DELETE and PUT, so ensure your web server can support those http methods.
13+
### Backend (API)
14+
- **Java 21** (LTS)
15+
- **Spring Boot 3.3** with Spring Security 6
16+
- **Stateless JWT-style token authentication**
17+
- **HSQLDB** in-memory database (for demo purposes)
18+
- **JPA/Hibernate** for persistence
19+
- **JUnit 5** for testing
1220

13-
The CLIENT currently is run via gulp, for a production release you could extract the .zip artefact and run the static client via Apache.
21+
### Frontend (Client)
22+
- **Angular 19** with standalone components
23+
- **Bootstrap 5.3** for styling
24+
- **TypeScript 5.7**
25+
- **Angular CLI** for builds
1426

15-
Ensure that you proxy the API so that you have the same domain otherwise you will experience CORS related issues. (deployed artefacts only)
27+
## Architecture
1628

17-
### Gulp:
18-
Used as the build tool for the client, this has been written using ES6
29+
The application is split into two modules:
1930

20-
### Spring 4:
21-
Used to create RESTful controller interfaces which in turn gets called through ajax requests.
22-
23-
### Spring Security 4:
24-
Used for a stateless api that allows authentication via basic authentication or token authentication.
31+
- **API** - Spring Boot REST backend (stateless, token-based auth)
32+
- **Client** - Angular SPA frontend
2533

26-
Upon authentication a token is attached to the header response which can in turn be used for sequential requests to be authenticated against.
34+
## Quick Start
2735

28-
When an authentication fails a 401 will always be returned.
36+
### Prerequisites
37+
- **Java 21** or higher
38+
- **Maven 3.8+**
39+
- **Node.js 22** (optional - Maven downloads it automatically)
2940

30-
### Login Details as per database inject.sql:
31-
**Username =** user@tester.com.au
41+
### Build Everything
3242

33-
**Password =** password
43+
```bash
44+
mvn clean package
45+
```
3446

35-
Testing
36-
====================
37-
Simply run on the parent pom to have node and modules auto install and execute all tests. **(REQUIRED FOR FIRST RUN)**
47+
This builds both the API and client modules.
3848

39-
Ensure you have Maven 3.2.0+
49+
### Run the API
4050

41-
**mvn clean install**
51+
```bash
52+
cd api
53+
mvn spring-boot:run
54+
```
4255

43-
To run specific profiles please run mvn clean install and simple pass the profile you wish to execute.
56+
The API will be available at `http://localhost:8080/api`
4457

45-
This will execute Java and Jasmine tests that will test both java classes and angular js files.
58+
### Run the Client (Development)
4659

47-
You can also run jasmine only tests if you wish via the front end:
60+
```bash
61+
cd client
62+
npm install
63+
npm start
64+
```
4865

49-
**http://localhost:4444/test**
66+
The client dev server runs at `http://localhost:4200` with API proxy to `http://localhost:8080`.
5067

51-
Running
52-
====================
68+
## Authentication
5369

54-
### Recommendations:
70+
The API uses stateless token-based authentication:
5571

56-
Use IntelliJ 16+ to run the application.
72+
1. Login with Basic Auth to `/api/auth/login`
73+
2. Receive a token in the `X-AUTH-TOKEN` response header
74+
3. Include the token in subsequent requests via `X-AUTH-TOKEN` header
5775

58-
### Run the API via Tomcat 8:
76+
### Default Credentials
5977

60-
Deploy exploded artefact to Tomcat 8 and ensure the root context is set to API.
78+
| Username | Password |
79+
|----------|----------|
80+
| user@tester.com.au | password |
6181

62-
### Run the CLIENT via gulp.babel.js:
82+
## API Endpoints
6383

64-
Where PATH is the directory to your checked out project.
84+
| Method | Endpoint | Description | Auth Required |
85+
|--------|----------|-------------|---------------|
86+
| POST | `/api/auth/login` | Login (Basic Auth) | No |
87+
| GET | `/api/user` | Get current user | Yes |
88+
| GET | `/api/customer` | List all customers | Yes |
89+
| GET | `/api/customer/{id}` | Get customer by ID | Yes |
90+
| POST | `/api/customer` | Create customer | Yes |
91+
| PUT | `/api/customer/{id}` | Update customer | Yes |
92+
| DELETE | `/api/customer/{id}` | Delete customer | Yes |
6593

66-
**Gulp File:** PATH\angular_bootstrap_spring\client\gulpfile.babel.js
94+
## Development
6795

68-
**Tasks:** run
96+
### Backend Development
6997

70-
**Node Interpreter:** PATH\angular_bootstrap_spring\client\node\node.exe
98+
```bash
99+
cd api
100+
mvn clean verify # Run tests
101+
mvn spring-boot:run # Run with hot reload
102+
```
71103

72-
**Gulp package:** PATH\angular_bootstrap_spring\client\node_modules\gulp
104+
### Frontend Development
73105

74-
### The application is set to run on
106+
```bash
107+
cd client
108+
npm install # Install dependencies
109+
npm start # Dev server with hot reload
110+
npm run build # Production build
111+
npm run test # Run unit tests
112+
```
75113

76-
**http://localhost:4444**
114+
### IDE Setup
77115

78-
Donations
79-
====================
116+
**IntelliJ IDEA** is recommended. Import the project as a Maven project.
80117

81-
### How you can help?
118+
For the frontend, ensure the Angular Language Service plugin is installed.
82119

83-
Any donations received will be able to assist me provide more blog entries and examples via GitHub, any contributions provided is greatly appreciated.
120+
## Project Structure
84121

85-
Thanks for your support.
122+
```
123+
angular_bootstrap_spring/
124+
├── api/ # Spring Boot backend
125+
│ ├── src/main/java/
126+
│ │ └── au/com/example/
127+
│ │ ├── Application.java # Spring Boot entry point
128+
│ │ ├── spring/ # Security & config
129+
│ │ ├── controller/ # REST controllers
130+
│ │ ├── service/ # Business logic
131+
│ │ ├── repository/ # Data access
132+
│ │ └── entity/ # JPA entities
133+
│ └── src/main/resources/
134+
│ ├── application.properties
135+
│ └── data.sql # Sample data
136+
├── client/ # Angular frontend
137+
│ ├── src/app/
138+
│ │ ├── components/ # Angular components
139+
│ │ ├── services/ # HTTP services
140+
│ │ ├── guards/ # Route guards
141+
│ │ └── models/ # TypeScript interfaces
142+
│ └── angular.json
143+
└── pom.xml # Parent POM
144+
```
145+
146+
## License
147+
148+
[MIT License](LICENSE)
149+
150+
## Author
151+
152+
**Robert Leggett**
153+
- [Blog](https://robertleggett.com.au)
154+
155+
---
156+
157+
## Support
158+
159+
If you find this project helpful, consider supporting further development:
86160

87161
[![paypal](https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EV2ZLZBABFJ34&lc=AU&item_name=Research%20%26%20Development&currency_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)

0 commit comments

Comments
 (0)