重构底层框架
This commit is contained in:
@@ -1,30 +1,75 @@
|
||||
# Patbond API
|
||||
|
||||
Patbond API is a Spring Cloud microservice project.
|
||||
Patbond API is a Spring Boot multi-module backend.
|
||||
|
||||
## Modules
|
||||
|
||||
- `patbond-common`: shared response objects, DTOs, and common dependencies.
|
||||
- `patbond-common`: stable cross-module contracts (response wrapper, shared DTOs). No web/messaging dependencies.
|
||||
- `patbond-user`: user service for user creation, profile lookup, and password verification.
|
||||
- `patbond-auth`: authentication service for registration and login.
|
||||
- `patbond-auth`: authentication service for registration and login. Calls `patbond-user` over HTTP via OpenFeign with a configured static URL (no service discovery in the MVP, see ADR-002).
|
||||
|
||||
## Technology Stack
|
||||
|
||||
- Java 17
|
||||
- Spring Boot 2.7.18
|
||||
- Spring Cloud 2021.0.9
|
||||
- Spring Cloud Alibaba 2021.0.6.0
|
||||
- Nacos
|
||||
- OpenFeign
|
||||
- RabbitMQ
|
||||
- Maven
|
||||
- Java 17 (build baseline; use JDK 17 for release builds)
|
||||
- Spring Boot 3.5.16
|
||||
- Spring Cloud 2025.0.3 (OpenFeign only)
|
||||
- Maven (use the committed Maven Wrapper `./mvnw`)
|
||||
|
||||
## Build
|
||||
## Build and Test
|
||||
|
||||
```bash
|
||||
mvn compile
|
||||
./mvnw clean test
|
||||
```
|
||||
|
||||
If your default JDK is not 17, point `JAVA_HOME` at a JDK 17 installation first, e.g.:
|
||||
|
||||
```bash
|
||||
JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./mvnw clean test
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
Each service ships a committed `application.yml.sample`; the real `application.yml`
|
||||
is git-ignored. First copy the samples (defaults work locally, overrides via
|
||||
environment variables):
|
||||
|
||||
```bash
|
||||
cp patbond-user/src/main/resources/application.yml.sample \
|
||||
patbond-user/src/main/resources/application.yml
|
||||
cp patbond-auth/src/main/resources/application.yml.sample \
|
||||
patbond-auth/src/main/resources/application.yml
|
||||
```
|
||||
|
||||
Install the shared module once, then run each service in its own terminal:
|
||||
|
||||
```bash
|
||||
./mvnw -pl patbond-common install
|
||||
./mvnw -pl patbond-user spring-boot:run
|
||||
./mvnw -pl patbond-auth spring-boot:run
|
||||
```
|
||||
|
||||
Tests do not require this copy step — `patbond-auth/src/test/resources/application.yml`
|
||||
keeps `./mvnw clean test` self-contained on a clean checkout.
|
||||
|
||||
Smoke check:
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8081/auth/register \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"username":"demo_user","password":"secret123"}'
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
| Environment variable | Default | Used by |
|
||||
| --- | --- | --- |
|
||||
| `PATBOND_USER_PORT` | `8082` | patbond-user |
|
||||
| `PATBOND_AUTH_PORT` | `8081` | patbond-auth |
|
||||
| `PATBOND_USER_SERVICE_URL` | `http://127.0.0.1:8082` | patbond-auth (Feign target for patbond-user) |
|
||||
|
||||
Machine-specific values live in the git-ignored `application.yml` (copied from the
|
||||
committed `.sample`); never commit secrets to the samples.
|
||||
|
||||
## Services
|
||||
|
||||
### Auth Service
|
||||
@@ -43,12 +88,6 @@ mvn compile
|
||||
- Get user by id: `GET /internal/users/{id}`
|
||||
- Get user by username: `GET /internal/users/by-username/{username}`
|
||||
|
||||
## Nacos
|
||||
|
||||
Both services read the Nacos address from `NACOS_SERVER_ADDR`.
|
||||
|
||||
Default value:
|
||||
|
||||
```text
|
||||
127.0.0.1:8848
|
||||
```
|
||||
> Note: the user store is currently in-memory (prototype); data is lost on restart.
|
||||
> Persistence (PostgreSQL + Flyway), verifiable JWT tokens, and `/internal` access
|
||||
> control are planned in iteration 1 follow-up tasks.
|
||||
|
||||
Reference in New Issue
Block a user