genesis-stack 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/package.json +1 -1
- package/stacks/pieces/django-mysql.md +79 -0
- package/stacks/pieces/django-postgresql.md +78 -0
- package/stacks/pieces/django-sqlite.md +55 -0
- package/stacks/pieces/django.md +166 -0
- package/stacks/pieces/express.md +143 -0
- package/stacks/pieces/java.md +1 -2
- package/stacks/pieces/laravel.md +16 -1
- package/stacks/pieces/nextjs.md +153 -0
- package/stacks/pieces/nodejs.md +2 -1
- package/stacks/pieces/python.md +3 -5
- package/stacks/pieces/rails-mysql.md +76 -0
- package/stacks/pieces/rails-postgresql.md +74 -0
- package/stacks/pieces/rails-sqlite.md +60 -0
- package/stacks/pieces/rails.md +161 -0
- package/stacks/pieces/ruby.md +1 -4
- package/stacks/pieces/spring-boot-mysql.md +74 -0
- package/stacks/pieces/spring-boot-postgresql.md +68 -0
- package/stacks/pieces/spring-boot.md +148 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Stack piece: spring-boot-postgresql
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Spring Boot PostgreSQL datasource, JDBC driver, Flyway, JPA, and database
|
|
6
|
+
environment conventions.
|
|
7
|
+
|
|
8
|
+
## Requires
|
|
9
|
+
|
|
10
|
+
- `spring-boot`
|
|
11
|
+
- `postgresql`
|
|
12
|
+
|
|
13
|
+
## Conflicts
|
|
14
|
+
|
|
15
|
+
- `spring-boot-mysql`
|
|
16
|
+
|
|
17
|
+
## Environment defaults
|
|
18
|
+
|
|
19
|
+
- Default `DB_HOST`: `127.0.0.1`
|
|
20
|
+
- Default `DB_PORT`: `5432`
|
|
21
|
+
- Default `DB_NAME`: `spring`
|
|
22
|
+
- Default `DB_USERNAME`: `postgres`
|
|
23
|
+
|
|
24
|
+
## Resources
|
|
25
|
+
|
|
26
|
+
```json genesis-resource
|
|
27
|
+
{
|
|
28
|
+
"id": "database",
|
|
29
|
+
"kind": "postgresql",
|
|
30
|
+
"environmentAlternatives": [
|
|
31
|
+
{
|
|
32
|
+
"bindings": {
|
|
33
|
+
"database": "DB_NAME",
|
|
34
|
+
"host": "DB_HOST",
|
|
35
|
+
"password": "DB_PASSWORD",
|
|
36
|
+
"port": "DB_PORT",
|
|
37
|
+
"username": "DB_USERNAME"
|
|
38
|
+
},
|
|
39
|
+
"allowEmpty": ["password"],
|
|
40
|
+
"preferred": true
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"optionalBindings": {
|
|
44
|
+
"testDatabase": "TEST_DB_NAME"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Guidance
|
|
50
|
+
|
|
51
|
+
- Compose the JDBC URL from the individual names in `application.properties`:
|
|
52
|
+
`spring.datasource.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}`,
|
|
53
|
+
`spring.datasource.username=${DB_USERNAME}` and
|
|
54
|
+
`spring.datasource.password=${DB_PASSWORD:}`. A `postgres://` connection URL
|
|
55
|
+
is not a JDBC URL; do not feed one to `spring.datasource.url`.
|
|
56
|
+
- Use the `org.postgresql:postgresql` runtime driver. Flyway 10 and later also
|
|
57
|
+
need `org.flywaydb:flyway-database-postgresql` next to the Flyway starter.
|
|
58
|
+
- When `TEST_DB_NAME` is supplied, the `test` profile's
|
|
59
|
+
`src/test/resources/application-test.properties` sets
|
|
60
|
+
`spring.datasource.url` to the same JDBC URL with `${TEST_DB_NAME}` in place
|
|
61
|
+
of `${DB_NAME}`. Flyway migrates that existing database; the database role
|
|
62
|
+
may lack permission to create databases. Never point tests at `DB_NAME`.
|
|
63
|
+
|
|
64
|
+
## Adoption
|
|
65
|
+
|
|
66
|
+
- Confirm the datasource properties, the environment names they read, the
|
|
67
|
+
driver and Flyway or Liquibase modules, and every profile's overrides from
|
|
68
|
+
source before declaring readiness or connecting to the database.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Stack piece: spring-boot
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Spring Boot web application, Spring MVC, Spring Security, Actuator, profiles,
|
|
6
|
+
Maven or Gradle wrapper, and schema-migration conventions. Identified by a
|
|
7
|
+
`pom.xml` or `build.gradle(.kts)` using the Spring Boot parent or plugin and an
|
|
8
|
+
`@SpringBootApplication` class. Authoritative framework documentation:
|
|
9
|
+
https://docs.spring.io/spring-boot/
|
|
10
|
+
|
|
11
|
+
## Requires
|
|
12
|
+
|
|
13
|
+
- `java`
|
|
14
|
+
|
|
15
|
+
## Guidance
|
|
16
|
+
|
|
17
|
+
- Use the Spring Boot version selected by the build and follow its matching
|
|
18
|
+
official documentation. Boot 4 splits auto-configuration into per-technology
|
|
19
|
+
starters (`spring-boot-starter-webmvc`, `spring-boot-starter-flyway`, ...):
|
|
20
|
+
a bare `flyway-core` dependency no longer runs migrations, so add the
|
|
21
|
+
matching starter instead of hand-written configuration. Preserve Spring's
|
|
22
|
+
dependency injection, configuration properties, Spring Data repositories,
|
|
23
|
+
Spring Security and Actuator instead of adding parallel plumbing.
|
|
24
|
+
- Building and running need a full JDK (`javac`), not only a Java runtime.
|
|
25
|
+
Keep the Maven wrapper (`mvnw`, `.mvn/wrapper`) committed and executable;
|
|
26
|
+
the proposed operations call `./mvnw`.
|
|
27
|
+
- Bind the listen address and port from the environment in
|
|
28
|
+
`application.properties`: `server.address=${HOST:127.0.0.1}` and
|
|
29
|
+
`server.port=${PORT:8080}`. Spring reads `SERVER_PORT`, not `PORT`, by
|
|
30
|
+
itself. The proposed development run also passes both as
|
|
31
|
+
`--server.address`/`--server.port` application arguments.
|
|
32
|
+
- Behind a development or production reverse proxy on the same machine that
|
|
33
|
+
rewrites `Host` and sends `X-Forwarded-Host`, `X-Forwarded-Proto` and
|
|
34
|
+
`X-Forwarded-Port`, set `server.forward-headers-strategy=native`,
|
|
35
|
+
`server.tomcat.remoteip.host-header=X-Forwarded-Host` and
|
|
36
|
+
`server.tomcat.remoteip.port-header=X-Forwarded-Port`. Embedded Tomcat then
|
|
37
|
+
trusts those headers only from loopback and private internal proxies, so
|
|
38
|
+
login redirects, `ServletUriComponentsBuilder` URLs and the `Secure` session
|
|
39
|
+
cookie use the browser-facing origin. Without it, Spring Security redirects
|
|
40
|
+
to the loopback address. Use `framework` only for a non-Tomcat server, and
|
|
41
|
+
only while the server is reachable solely through that proxy.
|
|
42
|
+
- Also set `server.tomcat.use-relative-redirects=true`. A proxy may send a
|
|
43
|
+
same-origin form post with the forwarded host and port removed and `Origin`
|
|
44
|
+
rewritten to the loopback address, so Tomcat would turn the redirect after
|
|
45
|
+
login or after any POST into `https://127.0.0.1/...`; a relative `Location`
|
|
46
|
+
lets the browser resolve it against its own origin.
|
|
47
|
+
- Spring Security's CSRF protection is token based (`_csrf`) and works behind
|
|
48
|
+
such a proxy. A proxy may present same-origin requests with an `Origin`
|
|
49
|
+
rewritten to the loopback address; keep CORS configuration for genuine
|
|
50
|
+
cross-origin clients rather than comparing `Origin` with the request host.
|
|
51
|
+
- Add `spring-boot-starter-actuator`, expose
|
|
52
|
+
`management.endpoints.web.exposure.include=health`, and let Spring Security
|
|
53
|
+
`permitAll` `/actuator/health`; the proposed readiness checks use it. Its
|
|
54
|
+
status includes the datasource, so readiness also proves the database
|
|
55
|
+
connection. An application that must not expose Actuator replaces both
|
|
56
|
+
readiness lines with another unauthenticated route.
|
|
57
|
+
- Select profiles with `SPRING_PROFILES_ACTIVE` set separately in each
|
|
58
|
+
environment (for example `dev` locally); never make a development profile
|
|
59
|
+
the project-wide default, because defaults also reach deployment. Keep
|
|
60
|
+
profile-specific values in `application-<profile>.properties`.
|
|
61
|
+
- Read credentials from the environment through property placeholders; never
|
|
62
|
+
commit passwords or tokens in `application*.properties`. Spring Boot has no
|
|
63
|
+
framework secret key of its own; application secrets, such as a token
|
|
64
|
+
signing key, are generated with `openssl rand -base64 32` and supplied
|
|
65
|
+
through the environment.
|
|
66
|
+
- Flyway or Liquibase owns the schema and runs at application startup, so the
|
|
67
|
+
proposed deployment has no separate migration step. Add new migrations;
|
|
68
|
+
never edit an applied one (its checksum is validated). Use
|
|
69
|
+
`spring.jpa.hibernate.ddl-auto=validate` and never `create`, `create-drop`
|
|
70
|
+
or `update` against supplied data; set `spring.jpa.open-in-view=false`.
|
|
71
|
+
Seeds are idempotent: repeatable migrations or a startup runner that checks
|
|
72
|
+
before inserting.
|
|
73
|
+
- Keep tests off development data: a `test` profile
|
|
74
|
+
(`src/test/resources/application-test.properties`, activated with
|
|
75
|
+
`@ActiveProfiles("test")` or Surefire's `spring.profiles.active`) points the
|
|
76
|
+
datasource at a disposable test database supplied by the environment
|
|
77
|
+
(`TEST_DB_NAME` with the database integrations below). Do not
|
|
78
|
+
add `src/test/resources/application.properties`, which replaces the main file
|
|
79
|
+
on the test classpath. Testcontainers needs a container runtime the
|
|
80
|
+
environment may not provide.
|
|
81
|
+
- Deployment serves the executable jar. Set `<finalName>app</finalName>` in the
|
|
82
|
+
Maven `<build>` so the proposed Serve step finds `target/app.jar`; the jar
|
|
83
|
+
reads `HOST` and `PORT` through the properties above.
|
|
84
|
+
- When the app has login, use Spring Security users with `ADMIN` and `USER`
|
|
85
|
+
roles and a delegating `PasswordEncoder`. Seed one administrator and one
|
|
86
|
+
ordinary user for development from a `dev`-profile runner or seed migration
|
|
87
|
+
that reads the password from the environment and creates each user only
|
|
88
|
+
when absent. Never use `{noop}` passwords or seeded credentials outside
|
|
89
|
+
development.
|
|
90
|
+
- A Gradle project replaces the proposals with the wrapper equivalents:
|
|
91
|
+
`./gradlew` `bootRun` `--args=--server.address={host} --server.port={port}`,
|
|
92
|
+
`./gradlew` `test`, and `./gradlew` `bootJar` with
|
|
93
|
+
`bootJar { archiveFileName = 'app.jar' }` serving `build/libs/app.jar`.
|
|
94
|
+
|
|
95
|
+
## Adoption
|
|
96
|
+
|
|
97
|
+
- Inspect `pom.xml` or `build.gradle(.kts)`, the wrapper, the Spring Boot and
|
|
98
|
+
Java versions, `application.properties`/`application.yml` and every profile
|
|
99
|
+
file, the security configuration, the embedded server, the packaging (`jar`
|
|
100
|
+
or `war`) and the migration tool before changing project contracts. Preserve
|
|
101
|
+
the build tool and Boot major version.
|
|
102
|
+
- Replace any proposed setup, run, readiness, verification or deployment line
|
|
103
|
+
that does not match the application before claiming readiness, including
|
|
104
|
+
the jar name, the health route and the address/port properties.
|
|
105
|
+
- When the app uses PostgreSQL or MySQL, select the matching Spring Boot
|
|
106
|
+
database integration so its datasource environment names become explicit.
|
|
107
|
+
|
|
108
|
+
## Workspace setup
|
|
109
|
+
|
|
110
|
+
- Prepare `Compile application` with `java` when `pom.xml` exists: `./mvnw` `-B` `-DskipTests` `compile`
|
|
111
|
+
|
|
112
|
+
## Outputs
|
|
113
|
+
|
|
114
|
+
### Target `app`: Run Spring Boot app
|
|
115
|
+
|
|
116
|
+
- Default.
|
|
117
|
+
- Mode: `interactive`
|
|
118
|
+
- Runtimes: `java`
|
|
119
|
+
- Run `Develop`: `./mvnw` `-B` `spring-boot:run` `-Dspring-boot.run.arguments=--server.address={host} --server.port={port}`
|
|
120
|
+
|
|
121
|
+
#### Presentation
|
|
122
|
+
|
|
123
|
+
- Kind: `web`
|
|
124
|
+
- Preferred port: `8080`
|
|
125
|
+
- URL path: `/`
|
|
126
|
+
- Ready when: `GET` `/actuator/health` returns `200`
|
|
127
|
+
|
|
128
|
+
## Verification
|
|
129
|
+
|
|
130
|
+
- Verify `application`: `./mvnw` `-B` `test`
|
|
131
|
+
|
|
132
|
+
## Deployment
|
|
133
|
+
|
|
134
|
+
- Runtimes: `java`
|
|
135
|
+
- Ready when: `GET` `/actuator/health` returns `200`
|
|
136
|
+
- Build `Package`: `./mvnw` `-B` `-DskipTests` `package`
|
|
137
|
+
- Serve `Start`: `java` `-jar` `target/app.jar`
|
|
138
|
+
|
|
139
|
+
## Deslop
|
|
140
|
+
|
|
141
|
+
- Preserve Spring's constructor injection, configuration properties,
|
|
142
|
+
component boundaries, Spring Data repositories, transaction boundaries and
|
|
143
|
+
security configuration.
|
|
144
|
+
- Keep `@Transactional` at service boundaries and validation at controller or
|
|
145
|
+
configuration-properties boundaries. Remove service, mapper or DTO layers only
|
|
146
|
+
when they duplicate framework behavior without protecting a real seam.
|
|
147
|
+
- Preserve migration history and entity mappings; cleanup is not permission to
|
|
148
|
+
edit applied migrations or loosen `ddl-auto`.
|