Deprecated ‐ Frontend Gateway ‐ Project structure - Wiz-DevTech/prettygirllz GitHub Wiki
Here’s a clean, scalable project structure for your Frontend Gateway with MongoDB caching and microservice integration:
frontend-gateway/
├── 📁 api-composition/ # API Composition Layer (Java/Spring Boot)
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/com/yourcompany/gateway/
│ │ │ │ ├── aggregation/ # Aggregation services
│ │ │ │ ├── caching/ # MongoDB caching logic
│ │ │ │ ├── config/ # Circuit breaker configs
│ │ │ │ └── Application.java
│ │ │ └── resources/
│ │ │ ├── application.yml # Mongo/retry/timeout configs
│ │ │ └── mongo/
│ │ │ └── init.js # DB indexes initialization
│ │ └── test/ # Integration tests with WireMock
│ └── pom.xml # Spring Boot + MongoDB starter
│
├── 📁 ssr-engine/ # SSR Templates (Java/Spring MVC)
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/com/yourcompany/ssr/
│ │ │ │ ├── fallback/ # MongoDB fallback handlers
│ │ │ │ └── controllers/
│ │ │ ├── webapp/
│ │ │ │ └── WEB-INF/views/ # JSP templates
│ │ │ └── resources/
│ │ │ └── messages/ # i18n error messages
│ └── pom.xml
│
├── 📁 client-adaptors/ # Device-specific rendering (Node.js)
│ ├── packages/
│ │ ├── web-adaptor/ # Web client logic
│ │ │ ├── src/
│ │ │ │ ├── transformers/ # Response shaping
│ │ │ │ └── error-handling/
│ │ │ └── package.json
│ │ └── mobile-adaptor/ # Mobile client logic
│ │ └── src/
│ │ └── offline-manager/ # Service worker setup
│ ├── config/
│ │ └── mongo-client.js # Shared MongoDB connection
│ └── package.json
│
├── 📁 monitoring/ # Observability
│ ├── prometheus/ # Metric collection rules
│ ├── grafana/ # Dashboards
│ │ └── gateway-dashboard.json
│ └── alerting/ # Alert rules
│
├── 📁 infrastructure/
│ ├── docker/ # Custom Dockerfiles
│ ├── k8s/ # Helm/K8s manifests
│ └── terraform/ # Cloud provisioning
│
├── 📄 Makefile # Build/test shortcuts
├── 📄 docker-compose.yml # Local dev stack
└── 📄 README.md # Project bootstrap guide
Key Structural Decisions:
-
Clear Layer Separation
api-composition
: Pure data aggregation (no UI logic)ssr-engine
: Presentation-focused with fallback handlingclient-adaptors
: Device-specific rendering pipelines
-
MongoDB Integration Points
- Cached API responses →
api-composition/src/main/resources/mongo/init.js
- SSR fallback templates →
ssr-engine/src/main/java/com/yourcompany/ssr/fallback/
- Client device profiles →
client-adaptors/config/mongo-client.js
- Cached API responses →
-
Testability
- Each module has its own test suite
api-composition
includes WireMock for microservice simulationclient-adaptors
has Jest tests with mocked MongoDB
-
Operational Readiness
- Dedicated monitoring configuration
- Infrastructure-as-code support
- Environment-specific configs out of the box
Validation Flow:
-
Build
make build # Runs mvn install + npm run build
-
Test
make test-all # Executes: # - Spring Boot tests # - Node.js unit tests # - Integration tests
-
Run Locally
docker-compose up -d --build
This structure ensures:
- Zero shared business logic with microservices
- Clear boundaries between composition and rendering
- Easy scaling of client-specific adaptors
- Unified observability across all layers