How feedhenry-raincatcher/raincatcher-server works
Project type and purpose
• This is a server-side, full-stack Node.js/TypeScript cloud application (part of the RainCatcher suite).
• It exposes HTTP endpoints, serves a small UI (Handlebars templates + CSS), and provides data-sync, authentication, and session management.
Main components
a. Client (Frontend)
• Static assets (public/style.css)
• Handlebars views (views/login.hbs)
• User’s browser sends HTTP requests to the server UI and APIs.
b. Node.js Server (Express)
• Entry point: application.js (compiled from src/app.ts)
• Configuration tier: config-dev.js / config-prod.js
• Routing layer:
– src/user-routes (HTTP route definitions)
• Business modules:
– datasync (Connector.ts → connects to data-sync API, uses MongoDataHandler.ts)
– session (RedisSession.ts → session store)
– authentication
• passport-auth (local/demo user repository)
• keycloak (OIDC integration)
– wfm-user (static user repository)
• Utility: Config.ts for env/config loading
c. Data Stores / External Services
• MongoDB (accessed by MongoDataHandler)
• Redis (session storage)
• Keycloak server (external identity provider)
d. Development & Build
• TypeScript compiler (tsconfig.json → transpiles src/*.ts to .js + .map)
• nodemon.json for live-reload
Component relationships & data flows
• Within Express Server, show flows:
1. Static-file middleware → public/ + views/
2. Routing → user-routes → controllers
3. Controller → invokes business module (e.g., datasync, auth, session)
• Authentication flow:
• Browser → “/login” → passport-auth or Keycloak → RedisSession → success → session cookie
• Data sync flow:
• API request → datasync/Connector → MongoDataHandler → MongoDB
• datasync filters apply (e.g., ExcludeCompletedWorkorders)
• Session flow: Express middleware reads/writes session data in Redis.
Architectural patterns & design principles
• Layered architecture:
• Presentation → Routing → Business logic → Data access
• Modular design: each feature lives in src/modules/<feature>
• Externalized configuration: config files per environment
• Use of standard middleware (Express, Passport, Keycloak OIDC)
Final checklist
• [ ] A container node labeled “Browser / Client”
• [ ] A container node labeled “Node.js / Express Server”
– Routing (user-routes)
– Business modules (datasync, session, auth, wfm-user)
– Utility / Config loader
• [ ] External data stores: MongoDB, Redis
• [ ] External Auth service: Keycloak
• HTTP requests (client → server → modules → DB / service)
• Session reads/writes (server ↔ Redis)
• Data sync operations (server ↔ MongoDB)
• Auth flows (server ↔ Keycloak)
• [ ] Environment/config notes (config-dev.js vs config-prod.js)
Use this structure as your blueprint. It captures every essential architectural element without overthinking—simply group into logical components and show how data and control flow between them.