|
| 1 | +# RealWorld Spring Boot API |
| 2 | + |
| 3 | +Backend implementation of the [RealWorld](https://github.com/realworld-apps/realworld) |
| 4 | +spec using Spring Boot 3, Java 21, PostgreSQL, Flyway, Docker, and Hurl. |
| 5 | + |
| 6 | +This repository is built against the RealWorld backend contract. It is not |
| 7 | +presented here as an official RealWorld listing. |
| 8 | + |
| 9 | +## Stack |
| 10 | + |
| 11 | +- Java 21 |
| 12 | +- Spring Boot 3 |
| 13 | +- PostgreSQL |
| 14 | +- Flyway |
| 15 | +- Docker Compose |
| 16 | +- Hurl |
| 17 | +- OpenAPI via springdoc |
| 18 | +- Scalar API reference |
| 19 | + |
| 20 | +## What is here |
| 21 | + |
| 22 | +- RealWorld backend endpoints for auth, profiles, articles, comments, tags, favorites, and feed |
| 23 | +- Docker-based local stack with PostgreSQL |
| 24 | +- Hurl verification suite against the running API |
| 25 | +- Static docs site artifact for separate publishing |
| 26 | + |
| 27 | +## API docs |
| 28 | + |
| 29 | +The app serves an interactive reference at `/`, but live request execution is |
| 30 | +disabled so the page behaves like hosted documentation instead of an API client. |
| 31 | + |
| 32 | +The repository also includes a static docs site in [`docs-site/`](./docs-site) |
| 33 | +that can be published separately, for example on `realworld.dhev.dev`. |
| 34 | + |
| 35 | +## Local development |
| 36 | + |
| 37 | +Run the full stack with Docker Compose: |
| 38 | + |
| 39 | +```sh |
| 40 | +docker compose up --build -d postgres app |
| 41 | +``` |
| 42 | + |
| 43 | +The API will be available at `http://localhost:8080` and the app will use the |
| 44 | +Compose-managed PostgreSQL container instead of requiring a host-installed |
| 45 | +database. |
| 46 | + |
| 47 | +Run the Hurl verification suite against the Compose stack: |
| 48 | + |
| 49 | +```sh |
| 50 | +./scripts/run-hurl.sh |
| 51 | +``` |
| 52 | + |
| 53 | +Export the OpenAPI document for the static docs site: |
| 54 | + |
| 55 | +```sh |
| 56 | +./scripts/export-openapi.sh |
| 57 | +``` |
| 58 | + |
| 59 | +Stop everything: |
| 60 | + |
| 61 | +```sh |
| 62 | +docker compose down |
| 63 | +``` |
| 64 | + |
| 65 | +If you want to remove the local PostgreSQL volume too: |
| 66 | + |
| 67 | +```sh |
| 68 | +docker compose down -v |
| 69 | +``` |
| 70 | + |
| 71 | +## Local build without Docker |
| 72 | + |
| 73 | +The app can still run against any reachable PostgreSQL instance through env vars. |
| 74 | +Without overrides, it defaults to `jdbc:postgresql://localhost:5432/realworld`. |
| 75 | + |
| 76 | +```sh |
| 77 | +./gradlew bootJar |
| 78 | +``` |
| 79 | + |
| 80 | +## CI and docs deploy |
| 81 | + |
| 82 | +GitHub Actions includes: |
| 83 | + |
| 84 | +- `ci.yml` to run Gradle tests, boot the Docker stack, run the Hurl suite, and export the OpenAPI document |
| 85 | +- `deploy-docs.yml` to deploy `docs-site/` to Cloudflare Pages |
| 86 | + |
| 87 | +To use the docs deploy workflow, set: |
| 88 | + |
| 89 | +- repository variable `CF_PAGES_PROJECT_NAME` |
| 90 | +- repository secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` |
| 91 | + |
| 92 | +Custom domain mapping such as `realworld.dhev.dev` is configured in Cloudflare |
| 93 | +Pages, not in this repository. |
| 94 | + |
| 95 | +## Deploy |
| 96 | + |
| 97 | +Use a Docker-capable web host and a managed PostgreSQL database. |
| 98 | + |
| 99 | +Minimal environment: |
| 100 | + |
| 101 | +```text |
| 102 | +SPRING_DATASOURCE_URL=jdbc:postgresql://<host>/<database>?sslmode=require |
| 103 | +SPRING_DATASOURCE_USERNAME=<username> |
| 104 | +SPRING_DATASOURCE_PASSWORD=<password> |
| 105 | +JWT_SECRET=<base64-encoded-strong-secret> |
| 106 | +``` |
| 107 | + |
| 108 | +For a quick public demo, use Render Free for the web service and Neon Free for |
| 109 | +PostgreSQL. The app reads the platform `PORT` env var automatically. |
0 commit comments