How reneilwekeoagile061/centralized-dynamic-configuration-service- works
Purpose and Entry Points
This is a centralized dynamic-configuration service: authenticated users manage named configuration values, while administrators also manage users and API keys. The backend API starts at backend/src/index.ts; the React client starts at frontend/src/index.tsx and renders its root from frontend/src/App.tsx. Root development orchestration is provided by package.json, with container deployment defined in docker-compose.yml.
Backend API and Request Boundary
Express exposes health and /api endpoints from backend/src/index.ts. Route handlers divide the public API into authentication/API-key operations in backend/src/routes/auth.ts and configuration-value CRUD in backend/src/routes/config.ts. This HTTP boundary is the system’s primary integration surface for both the bundled UI and external configuration consumers.
Authentication and Authorization
JWT authentication and role enforcement are centralized in backend/src/middleware/auth.ts. Login issues credentials through backend/src/routes/auth.ts; subsequent protected requests pass through middleware before reaching configuration or administrative actions. Admin-only boundaries cover user registration and API-key lifecycle operations.
Configuration Domain Service
Configuration CRUD is separated from routing in backend/src/services/configService.ts, which is the principal domain/data-access layer for named values. The route layer in backend/src/routes/config.ts validates and dispatches requests, while shared domain contracts reside in backend/src/types/index.ts. Request payload rules are defined at backend/src/validation/schemas.ts.
Persistence and Provisioning
PostgreSQL is the durable store, accessed through the connection and startup database logic in backend/src/database/connection.ts. The application creates required tables at server startup according to the README. Bootstrap administration is handled outside the request path by backend/scripts/create-admin.js; database credentials, JWT secret, port, and rate-limit settings come from backend/env.example.
Frontend Application Flow
The React application presents either authentication or the protected configuration dashboard through frontend/src/App.tsx. frontend/src/components/LoginForm.tsx submits login credentials; frontend/src/components/Dashboard.tsx loads and manages configuration data; and frontend/src/components/ConfigValueForm.tsx supports create/update interactions. Shared request and token behavior belongs in frontend/src/services/api.ts, which targets REACT_APP_API_URL or the default backend /api endpoint.
Runtime and Deployment
The material runtimes are Node.js/Express/TypeScript on the backend, React/TypeScript/Tailwind on the frontend, and PostgreSQL externally. Independent image builds are defined by backend/Dockerfile and frontend/Dockerfile; docker-compose.yml coordinates the full stack. PostgreSQL is assumed available via environment configuration rather than represented as a database directory in this repository.
Main entry points: index.ts Express API server · config.ts Configuration routes · connection.ts Database startup · configService.ts Configuration service
Components 20
Backend API
- Express API server · Exposes health and /api endpoints.
backend/src/index.ts - Auth and admin routes · Handles login, users, and API-key lifecycle.
backend/src/routes/auth.ts - Configuration routes
backend/src/routes/config.ts - JWT and role guard · Protects requests and enforces administrator roles.
backend/src/middleware/auth.ts - Configuration service · Manages named configuration values.
backend/src/services/configService.ts - Contracts and validation
backend/src/types/index.ts - Payload schemas
backend/src/validation/schemas.ts - Database startup · Connects to PostgreSQL and creates required tables at startup.
backend/src/database/connection.ts - Admin bootstrap · Creates the initial administrator outside request handling.
backend/scripts/create-admin.js
Frontend
- React client entry
frontend/src/index.tsx - Application shell · Switches between authentication and protected dashboard.
frontend/src/App.tsx - Login form
frontend/src/components/LoginForm.tsx - Configuration dashboard · Loads and manages configuration data.
frontend/src/components/Dashboard.tsx - Configuration editor · Creates and updates configuration values.
frontend/src/components/ConfigValueForm.tsx - API client and token handling · Targets REACT_APP_API_URL or the default /api endpoint.
frontend/src/services/api.ts
Deployment
- Development scripts
package.json - Full-stack compose
docker-compose.yml - Backend image
backend/Dockerfile - Frontend image
frontend/Dockerfile - PostgreSQL · Provisioned externally through environment configuration.
Connections 23
- Development scripts → Full-stack compose: runs stack
- Full-stack compose → Backend image: builds
- Full-stack compose → Frontend image: builds
- Backend image → Express API server: packages
- Frontend image → React client entry: packages
- Express API server → Auth and admin routes: mounts
- Express API server → Configuration routes: mounts
- Express API server → Database startup: initializes
- Auth and admin routes → JWT and role guard: uses guards
- Configuration routes → JWT and role guard: protected by
- Configuration routes → Payload schemas: validates with
- Configuration routes → Configuration service: dispatches to
- Configuration service → Contracts and validation: uses contracts
- Configuration service → Database startup: persists through
- Database startup → PostgreSQL: connects to
- Admin bootstrap → Database startup: provisions through
- React client entry → Application shell: renders
- Application shell → Login form: shows when unauthenticated
- Application shell → Configuration dashboard: shows when authenticated
- Configuration dashboard → Configuration editor: uses
- Login form → API client and token handling: submits via
- Configuration dashboard → API client and token handling: loads and mutates via
- API client and token handling → Express API server: calls /api