Skip to content

Commit cf6e5cb

Browse files
author
Joern Wellniak
committed
backend on top level
1 parent 09c48a7 commit cf6e5cb

10 files changed

Lines changed: 144 additions & 242 deletions

File tree

.github/workflows/build.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,61 @@ jobs:
1313
build-backend:
1414
runs-on: ubuntu-latest
1515
name: Build Backend
16-
16+
1717
permissions:
1818
contents: read
19-
19+
2020
steps:
2121
- uses: actions/checkout@v4
22-
22+
2323
- name: Set up JDK 21
2424
uses: actions/setup-java@v4
2525
with:
2626
java-version: '21'
2727
distribution: 'temurin'
2828
cache: maven
29-
29+
3030
- name: Build Backend with Maven
3131
run: |
32-
cd backend
3332
mvn clean package -DskipTests
34-
33+
3534
- name: Run Backend Tests
3635
run: |
37-
cd backend
3836
mvn test
39-
37+
4038
- name: Upload Backend Artifacts
4139
uses: actions/upload-artifact@v4
4240
with:
4341
name: backend-jar
4442
path: backend/target/*.jar
45-
43+
4644
build-frontend:
4745
runs-on: ubuntu-latest
4846
name: Build Frontend
49-
47+
5048
permissions:
5149
contents: read
52-
50+
5351
steps:
5452
- uses: actions/checkout@v4
55-
53+
5654
- name: Set up Node.js
5755
uses: actions/setup-node@v4
5856
with:
5957
node-version: '20'
6058
cache: 'npm'
6159
cache-dependency-path: frontend/package-lock.json
62-
60+
6361
- name: Install Frontend Dependencies
6462
run: |
6563
cd frontend
6664
npm ci
67-
65+
6866
- name: Build Frontend
6967
run: |
7068
cd frontend
7169
npm run build
72-
70+
7371
- name: Upload Frontend Artifacts
7472
uses: actions/upload-artifact@v4
7573
with:

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ hs_err_pid*
2626
replay_pid*
2727

2828
# Backend build artifacts
29-
backend/target/
30-
backend/.mvn/
31-
backend/mvnw
32-
backend/mvnw.cmd
29+
target/
30+
.mvn/
31+
mvnw
32+
mvnw.cmd
3333

3434
# Frontend dependencies and build artifacts
3535
frontend/node_modules/

README.md

Lines changed: 127 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,162 @@
1-
# Skat
1+
# Skat Backend
22

3-
A mono-repo project with Java 21 Spring Boot backend and Angular 18 frontend.
3+
Spring Boot REST API backend for the Skat application.
44

5-
## Project Structure
5+
## Technology Stack
66

7-
```
8-
.
9-
├── backend/ # Spring Boot backend (Java 21)
10-
├── frontend/ # Angular 18 frontend
11-
└── .github/ # CI/CD workflows
12-
└── workflows/
13-
└── build.yml # Build pipeline
7+
- **Java**: 21
8+
- **Spring Boot**: 3.5.6
9+
- **Database**: PostgreSQL (production), H2 (development)
10+
- **Build Tool**: Maven
11+
12+
## Prerequisites
13+
14+
- Java 21 or higher
15+
- Maven 3.6 or higher
16+
- PostgreSQL (for production mode)
17+
18+
## Getting Started
19+
20+
### Running with H2 In-Memory Database (Development)
21+
22+
The easiest way to start the application for development is using the H2 in-memory database:
23+
24+
```bash
25+
mvn spring-boot:run -Dspring-boot.run.profiles=dev
1426
```
1527

16-
## Backend
28+
The application will start on `http://localhost:8080`
1729

18-
### Technology Stack
19-
- Java 21
20-
- Spring Boot 3.4.2
21-
- PostgreSQL
22-
- Maven
30+
### Running with PostgreSQL (Production)
2331

24-
### Build and Run
32+
1. Ensure PostgreSQL is running and create a database:
33+
```sql
34+
CREATE DATABASE skatdb;
35+
```
36+
37+
2. Update the database credentials in `src/main/resources/application.properties` if needed:
38+
```properties
39+
spring.datasource.url=jdbc:postgresql://localhost:5432/skatdb
40+
spring.datasource.username=postgres
41+
spring.datasource.password=postgres
42+
```
43+
44+
3. Start the application:
45+
```bash
46+
mvn spring-boot:run
47+
```
48+
49+
### Building the Application
50+
51+
To build the application and create an executable JAR:
2552

2653
```bash
27-
cd backend
2854
mvn clean package
29-
mvn spring-boot:run
3055
```
3156

32-
The backend will start on `http://localhost:8080`
57+
The JAR file will be created in the `target/` directory.
3358

34-
For development without PostgreSQL, you can use the H2 in-memory database:
59+
### Running the JAR
60+
61+
After building, you can run the application using:
3562

3663
```bash
37-
cd backend
38-
mvn spring-boot:run -Dspring-boot.run.profiles=dev
39-
```
64+
# With H2 (development)
65+
java -jar target/backend-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
4066

41-
### API Endpoints
67+
# With PostgreSQL (production)
68+
java -jar target/backend-0.0.1-SNAPSHOT.jar
69+
```
4270

43-
- `GET /api/hello` - Returns "Hallo"
71+
## Running Tests
4472

45-
### Database Configuration
73+
Execute the test suite:
4674

47-
PostgreSQL configuration is in `backend/src/main/resources/application.properties`:
48-
- URL: `jdbc:postgresql://localhost:5432/skatdb`
49-
- Username: `postgres`
50-
- Password: `postgres`
75+
```bash
76+
mvn test
77+
```
5178

52-
## Frontend
79+
## API Endpoints
5380

54-
### Technology Stack
55-
- Angular 18
56-
- TypeScript
57-
- Node.js 20
81+
### Hello World Endpoint
5882

59-
### Build and Run
83+
- **URL**: `/api/hello`
84+
- **Method**: `GET`
85+
- **Response**: Plain text "Hallo"
6086

87+
Example:
6188
```bash
62-
cd frontend
63-
npm install
64-
npm start
89+
curl http://localhost:8080/api/hello
6590
```
6691

67-
The frontend will start on `http://localhost:4200`
92+
## Configuration Profiles
6893

69-
### Features
94+
### Development Profile (`dev`)
7095

71-
- Calls the backend `/api/hello` endpoint
72-
- Displays the response without formatting
96+
Uses H2 in-memory database. Configuration file: `application-dev.properties`
7397

74-
## Build Pipeline
98+
- Database: H2 in-memory
99+
- H2 Console: Enabled at `/h2-console`
100+
- SQL logging: Enabled
75101

76-
The project includes a GitHub Actions workflow that:
77-
- Builds the backend with Maven
78-
- Runs backend tests
79-
- Builds the frontend with npm
80-
- Uploads build artifacts
102+
### Default Profile (Production)
103+
104+
Uses PostgreSQL database. Configuration file: `application.properties`
105+
106+
- Database: PostgreSQL
107+
- Connection pooling: HikariCP (default)
108+
109+
## Project Structure
110+
111+
```
112+
backend/
113+
├── src/
114+
│ ├── main/
115+
│ │ ├── java/
116+
│ │ │ └── com/skat/backend/
117+
│ │ │ ├── SkatBackendApplication.java # Main application class
118+
│ │ │ └── controller/
119+
│ │ │ └── HelloWorldController.java # REST controller
120+
│ │ └── resources/
121+
│ │ ├── application.properties # Production config
122+
│ │ └── application-dev.properties # Development config
123+
│ └── test/
124+
│ └── java/
125+
│ └── com/skat/backend/
126+
│ └── controller/
127+
│ └── HelloWorldControllerTest.java # Controller tests
128+
├── pom.xml # Maven configuration
129+
└── README.md # This file
130+
```
131+
132+
## Troubleshooting
133+
134+
### Port Already in Use
135+
136+
If port 8080 is already in use, you can change it by adding to your run command:
137+
138+
```bash
139+
mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8081
140+
```
141+
142+
### Database Connection Issues
143+
144+
- Verify PostgreSQL is running: `pg_isready`
145+
- Check PostgreSQL logs for connection errors
146+
- Verify database credentials in `application.properties`
81147

82148
## Development
83149

84-
1. Start the backend:
85-
```bash
86-
cd backend
87-
mvn spring-boot:run
88-
```
150+
### Adding New Dependencies
89151

90-
2. In a new terminal, start the frontend:
91-
```bash
92-
cd frontend
93-
npm start
94-
```
152+
Add dependencies to `pom.xml` and run:
153+
154+
```bash
155+
mvn clean install
156+
```
157+
158+
### Code Style
95159

96-
3. Open your browser at `http://localhost:4200`
160+
The project follows standard Java coding conventions. Ensure your IDE is configured to use:
161+
- Tab size: 4 spaces
162+
- Charset: UTF-8

0 commit comments

Comments
 (0)