How jhipster/jhipster-sample-app-gateway works
Purpose and entry points
This is a JHipster 9 gateway in a microservice architecture: it serves an Angular SPA, owns user/authority administration, authenticates clients, and routes requests to discovered backend services. Spring Boot starts at src/main/java/io/github/jhipster/sample/JhipsterSampleGatewayApp.java; the browser app starts at src/main/webapp/main.ts and is composed from src/main/webapp/app/app.ts.
Gateway runtime and service boundary
The Java runtime is reactive Spring Boot/WebFlux, with gateway routing exposed through src/main/java/io/github/jhipster/sample/web/rest/GatewayResource.java. Service discovery and centralized configuration are mandatory through Consul; bootstrap/profile configuration is in src/main/resources/config/bootstrap.yml, src/main/resources/config/bootstrap-prod.yml, and src/main/docker/consul.yml. The gateway is therefore the boundary between SPA/API clients and downstream microservices rather than the owner of all domain data.
HTTP, security, and error pipeline
SecurityConfiguration.java establishes server-side access control, while JWT configuration and relay filter support authenticated gateway requests to downstream services: src/main/java/io/github/jhipster/sample/config/SecurityConfiguration.java, src/main/java/io/github/jhipster/sample/config/SecurityJwtConfiguration.java, src/main/java/io/github/jhipster/sample/security/jwt/JWTRelayGatewayFilterFactory.java. REST endpoints for login/account/admin users sit under src/main/java/io/github/jhipster/sample/web/rest/AuthenticateController.java, AccountResource.java, and UserResource.java. ExceptionTranslator.java standardizes API failures; SpaWebFilter.java handles SPA-oriented web fallback behavior.
Identity and persistence
The gateway persists its own users and authorities, rather than the downstream BankAccount entity. Core model and reactive repository boundaries are src/main/java/io/github/jhipster/sample/domain/User.java, src/main/java/io/github/jhipster/sample/domain/Authority.java, and src/main/java/io/github/jhipster/sample/repository/UserRepository.java. UserService.java implements account lifecycle and administration, with mail delivery delegated to MailService.java. Liquibase owns schema and seed evolution through src/main/resources/config/liquibase/master.xml and src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml; MySQL is provisioned by src/main/docker/mysql.yml.
Angular SPA and client-side API boundary
Angular routing/configuration originate in src/main/webapp/app/app.config.ts and src/main/webapp/app/app.routes.ts. Authentication state, JWT use, route guards, and HTTP interception are centralized under src/main/webapp/app/core/auth/auth-jwt.service.ts, src/main/webapp/app/core/auth/user-route-access.service.ts, and src/main/webapp/app/core/interceptor/auth.interceptor.ts. Account and administration screens consume the gateway’s identity/admin APIs; operational UI lives under src/main/webapp/app/admin/.
Downstream entity integration
The BankAccount UI is a generated client for a separate jhipsterSampleMicroservice, not a matching Java domain controller in this repository. Its route/service layer is src/main/webapp/app/entities/jhipsterSampleMicroservice/bank-account/bank-account.routes.ts and src/main/webapp/app/entities/jhipsterSampleMicroservice/bank-account/service/bank-account.service.ts; entity aggregation is src/main/webapp/app/entities/entity.routes.ts. Requests cross the gateway/discovery boundary to the target microservice.
Operations and deployment
Profiles configure development/production behavior in src/main/resources/config/application-dev.yml and application-prod.yml. Docker Compose descriptors provide the application and dependencies: src/main/docker/app.yml, src/main/docker/services.yml, and src/main/docker/central-server-config/application.yml. Observability infrastructure includes Prometheus, Grafana, and Zipkin (src/main/docker/prometheus/prometheus.yml, src/main/docker/grafana/provisioning/datasources/datasource.yml, src/main/docker/zipkin.yml); Hazelcast management is also supplied.
Main entry points: JhipsterSampleGatewayApp.java Spring Boot gateway · GatewayResource.java Gateway routing · app.ts Angular app shell · app.routes.ts Routes & app config
Components 19
Angular SPA
- Browser client
src/main/webapp/main.ts - Angular app shell
src/main/webapp/app/app.ts - Routes & app config
src/main/webapp/app/app.routes.ts - Client auth boundary
src/main/webapp/app/core/auth/auth-jwt.service.ts - Account & admin UI
- BankAccount client · Client for a separate microservice.
src/main/webapp/app/entities/jhipsterSampleMicroservice/bank-account/service/bank-account.service.ts
Gateway Runtime
- Spring Boot gateway
src/main/java/io/github/jhipster/sample/JhipsterSampleGatewayApp.java - Security & JWT relay · Authenticates clients and relays JWTs downstream.
src/main/java/io/github/jhipster/sample/config/SecurityConfiguration.java - Identity REST APIs
src/main/java/io/github/jhipster/sample/web/rest/AuthenticateController.java - Gateway routing
src/main/java/io/github/jhipster/sample/web/rest/GatewayResource.java - SPA fallback & API errors
src/main/java/io/github/jhipster/sample/web/filter/SpaWebFilter.java
Identity Data
- User lifecycle service
src/main/java/io/github/jhipster/sample/service/UserService.java - User repository
src/main/java/io/github/jhipster/sample/repository/UserRepository.java - Users & authorities schema
src/main/resources/config/liquibase/master.xml - MySQL
src/main/docker/mysql.yml - Mail delivery
src/main/java/io/github/jhipster/sample/service/MailService.java
Platform & Operations
- Consul
src/main/resources/config/bootstrap.yml - jhipsterSampleMicroservice · Owns BankAccount domain data.
- Compose & observability · Runs gateway dependencies plus Prometheus, Grafana, and Zipkin.
src/main/docker/app.yml
Connections 22
- Browser client → Angular app shell: loads
- Angular app shell → Routes & app config: configures
- Routes & app config → Account & admin UI: navigates
- Routes & app config → BankAccount client: navigates
- Angular app shell → Client auth boundary: uses
- Client auth boundary → Spring Boot gateway: authenticated HTTP
- Account & admin UI → Identity REST APIs: identity/admin API
- BankAccount client → Gateway routing: BankAccount requests
- Spring Boot gateway → Security & JWT relay: applies
- Spring Boot gateway → Identity REST APIs: serves
- Spring Boot gateway → Gateway routing: proxies through
- Spring Boot gateway → SPA fallback & API errors: handles failures/fallback
- Security & JWT relay → Gateway routing: relays JWT
- Identity REST APIs → User lifecycle service: account administration
- User lifecycle service → User repository: persists users
- User lifecycle service → Mail delivery: sends account mail
- User repository → MySQL: reactive access
- Users & authorities schema → MySQL: migrates and seeds
- Gateway routing → Consul: discovers services
- Gateway routing → jhipsterSampleMicroservice: routes BankAccount API
- Compose & observability → Spring Boot gateway: deploys
- Compose & observability → Consul: provisions