|
1 | | -# Skat Backend |
| 1 | +# skat |
2 | 2 |
|
3 | | -Spring Boot REST API backend for the Skat application. |
| 3 | +Monorepo with **Backend (Java 21, Spring Boot)** at the root level and **Frontend (Angular 18)** in the `frontend` folder. |
4 | 4 |
|
5 | | -## Technology Stack |
6 | | - |
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 |
26 | | -``` |
27 | | - |
28 | | -The application will start on `http://localhost:8080` |
29 | | - |
30 | | -### Running with PostgreSQL (Production) |
31 | | - |
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: |
52 | | - |
53 | | -```bash |
54 | | -mvn clean package |
55 | | -``` |
56 | | - |
57 | | -The JAR file will be created in the `target/` directory. |
58 | | - |
59 | | -### Running the JAR |
60 | | - |
61 | | -After building, you can run the application using: |
62 | | - |
63 | | -```bash |
64 | | -# With H2 (development) |
65 | | -java -jar target/backend-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev |
66 | | - |
67 | | -# With PostgreSQL (production) |
68 | | -java -jar target/backend-0.0.1-SNAPSHOT.jar |
69 | | -``` |
70 | | - |
71 | | -## Running Tests |
72 | | - |
73 | | -Execute the test suite: |
74 | | - |
75 | | -```bash |
76 | | -mvn test |
77 | | -``` |
78 | | - |
79 | | -## API Endpoints |
80 | | - |
81 | | -### Hello World Endpoint |
82 | | - |
83 | | -- **URL**: `/api/hello` |
84 | | -- **Method**: `GET` |
85 | | -- **Response**: Plain text "Hallo" |
86 | | - |
87 | | -Example: |
88 | | -```bash |
89 | | -curl http://localhost:8080/api/hello |
90 | | -``` |
91 | | - |
92 | | -## Configuration Profiles |
93 | | - |
94 | | -### Development Profile (`dev`) |
95 | | - |
96 | | -Uses H2 in-memory database. Configuration file: `application-dev.properties` |
97 | | - |
98 | | -- Database: H2 in-memory |
99 | | -- H2 Console: Enabled at `/h2-console` |
100 | | -- SQL logging: Enabled |
101 | | - |
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 |
| 5 | +## Structure |
110 | 6 |
|
111 | 7 | ``` |
112 | | -backend/ |
113 | | -├── src/ |
| 8 | +. |
| 9 | +├── .github/workflows/build.yml |
| 10 | +├── frontend/ # Angular 18 App |
| 11 | +├── src/ # Spring Boot Backend (Java 21) |
114 | 12 | │ ├── 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 | 13 | │ └── test/ |
124 | | -│ └── java/ |
125 | | -│ └── com/skat/backend/ |
126 | | -│ └── controller/ |
127 | | -│ └── HelloWorldControllerTest.java # Controller tests |
128 | | -├── pom.xml # Maven configuration |
129 | | -└── README.md # This file |
| 14 | +├── target/ |
| 15 | +├── pom.xml |
| 16 | +└── README.md |
130 | 17 | ``` |
131 | 18 |
|
132 | | -## Troubleshooting |
133 | | - |
134 | | -### Port Already in Use |
| 19 | +- **Backend:** Spring Boot (Java 21), REST API |
| 20 | +- **Frontend:** Angular 18, consumes backend API |
| 21 | +- **Tests:** JUnit 5 + AssertJ (Given-When-Then), **@SpringBootTest** (preferred over `@WebMvcTest`), **Testcontainers** for integration/DB tests |
135 | 22 |
|
136 | | -If port 8080 is already in use, you can change it by adding to your run command: |
| 23 | +## Quickstart |
137 | 24 |
|
| 25 | +### Backend |
138 | 26 | ```bash |
139 | | -mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8081 |
| 27 | +# Requires Java 21 |
| 28 | +./mvnw spring-boot:run |
| 29 | +# or |
| 30 | +./mvnw test |
140 | 31 | ``` |
141 | 32 |
|
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` |
147 | | - |
148 | | -## Development |
149 | | - |
150 | | -### Adding New Dependencies |
151 | | - |
152 | | -Add dependencies to `pom.xml` and run: |
153 | | - |
| 33 | +### Frontend |
154 | 34 | ```bash |
155 | | -mvn clean install |
| 35 | +cd frontend |
| 36 | +npm ci |
| 37 | +npm start |
156 | 38 | ``` |
157 | 39 |
|
158 | | -### Code Style |
159 | | - |
160 | | -The project follows standard Java coding conventions. Ensure your IDE is configured to use: |
161 | | -- Tab size: 4 spaces |
162 | | -- Charset: UTF-8 |
| 40 | +## Documentation |
| 41 | +- [ARCHITECTURE.md](./ARCHITECTURE.md) |
| 42 | +- [BACKEND.md](./BACKEND.md) |
| 43 | +- [FRONTEND.md](./FRONTEND.md) |
| 44 | +- [TESTING.md](./TESTING.md) |
| 45 | +- ADRs: see `docs/architecture/decisions/` |
0 commit comments