How mohithkudumu/opsbridge works
Purpose and Entry Points
OpsBridge is a multi-organization service-operations backend for tracking employee/client requests through intake, assignment, resolution, approvals, SLA enforcement, and auditability. The runnable server starts at opsbridge-backend/server.js, builds the HTTP application in opsbridge-backend/src/app.js, and initializes database access via opsbridge-backend/src/config/database.js. Database setup/migration entry points are opsbridge-backend/init-db.js and opsbridge-backend/src/db/migrate.js.
HTTP Application Boundary
The application is a Node.js backend organized as feature modules with route → controller → service → repository layering. opsbridge-backend/src/app.js is the composition boundary for routes and shared middleware; opsbridge-backend/src/middleware/errorHandler.js centralizes failure responses, while opsbridge-backend/src/middleware/validate.js enforces request contracts before business logic. Controllers expose the API boundary and services own cross-module workflow decisions.
Identity, Tenancy, and Access Control
Authentication issues and manages user credentials/tokens through opsbridge-backend/src/modules/auth/auth.routes.js, opsbridge-backend/src/modules/auth/auth.service.js, and opsbridge-backend/src/modules/auth/auth.repository.js. Requests are authenticated and role-gated by opsbridge-backend/src/middleware/authenticate.js and opsbridge-backend/src/middleware/authorize.js. Organization tenancy is a persistence-level concern established by opsbridge-backend/src/db/migrations/001_create_organizations.sql, with organization-scoped SLA policies added in opsbridge-backend/src/db/migrations/013_scope_sla_policies_to_organizations.sql.
Service-Request Lifecycle
Service requests are the core aggregate, exposed through opsbridge-backend/src/modules/service-requests/service-requests.routes.js. opsbridge-backend/src/modules/service-requests/service-requests.service.js coordinates request creation, triage, assignment, and resolution; opsbridge-backend/src/modules/service-requests/state-machine.js defines controlled state transitions rather than unconstrained updates. Data persistence is isolated in opsbridge-backend/src/modules/service-requests/service-requests.repository.js, backed by opsbridge-backend/src/db/migrations/005_create_service_requests.sql and request-history storage.
Collaboration, Approvals, and Audit
Comments attach collaboration to requests through opsbridge-backend/src/modules/comments/comments.service.js and opsbridge-backend/src/modules/comments/comments.repository.js. Approval workflows are isolated in opsbridge-backend/src/modules/approvals/approvals.service.js and opsbridge-backend/src/modules/approvals/approvals.repository.js. Audit is a cross-cutting write path represented by opsbridge-backend/src/modules/audit/audit.service.js, with historical request changes persisted by opsbridge-backend/src/db/migrations/007_create_request_history.sql.
SLA and Operational Monitoring
SLA policy management is implemented by opsbridge-backend/src/modules/sla/sla.service.js and its repository. opsbridge-backend/src/modules/sla/sla.scheduler.js is a background control path that evaluates time-based SLA conditions independently of incoming HTTP requests. Analytics is a read-oriented module that aggregates operational data through opsbridge-backend/src/modules/analytics/analytics.service.js and exposes it via opsbridge-backend/src/modules/analytics/analytics.routes.js.
Persistence and Infrastructure
The primary external infrastructure is a relational database, configured by opsbridge-backend/src/config/database.js and evolved through ordered SQL migrations in opsbridge-backend/src/db/migrations/. Core tables model organizations, users, categories, SLA policies, service requests, comments, approvals, assets, request-asset joins, and refresh tokens. The runtime also relies on environment-based configuration in opsbridge-backend/src/config/env.js; no frontend or other external SaaS integration is represented in this repository.
Main entry points: app.js HTTP application · service-requests.service.js Request workflow · auth.routes.js Auth API · env.js Environment config
Components 21
Identity & Access
- Authentication & roles · Authenticates requests and enforces role access.
opsbridge-backend/src/middleware/authenticate.js - Auth API
opsbridge-backend/src/modules/auth/auth.routes.js - Auth service
opsbridge-backend/src/modules/auth/auth.service.js - Auth repository
opsbridge-backend/src/modules/auth/auth.repository.js
Request Lifecycle
- Service request API
opsbridge-backend/src/modules/service-requests/service-requests.routes.js - Request workflow · Coordinates intake, triage, assignment, and resolution.
opsbridge-backend/src/modules/service-requests/service-requests.service.js - Request state machine · Controls valid lifecycle transitions.
opsbridge-backend/src/modules/service-requests/state-machine.js - Request repository
opsbridge-backend/src/modules/service-requests/service-requests.repository.js - Comments
opsbridge-backend/src/modules/comments/comments.service.js - Approvals
opsbridge-backend/src/modules/approvals/approvals.service.js
Operations
- Audit trail
opsbridge-backend/src/modules/audit/audit.service.js - SLA policies · Manages organization-scoped SLA policies.
opsbridge-backend/src/modules/sla/sla.service.js - SLA scheduler · Evaluates time-based SLA conditions outside HTTP requests.
opsbridge-backend/src/modules/sla/sla.scheduler.js - Analytics API · Aggregates operational data for reporting.
opsbridge-backend/src/modules/analytics/analytics.service.js
Persistence
- Database access
opsbridge-backend/src/config/database.js - SQL migrations · Creates tenant, request, history, and SLA schema.
- Relational database · Stores tenant-scoped operational records and tokens.
Other components
- Server entry
opsbridge-backend/server.js - HTTP application · Composes routes and shared middleware.
opsbridge-backend/src/app.js - Environment config
opsbridge-backend/src/config/env.js - Error handling · Centralizes failure responses.
opsbridge-backend/src/middleware/errorHandler.js
Connections 25
- Server entry → HTTP application: starts
- Environment config → HTTP application: configures
- Environment config → Database access: configures
- HTTP application → Authentication & roles: applies
- HTTP application → Error handling: uses
- HTTP application → Auth API: mounts
- HTTP application → Service request API: mounts
- HTTP application → Analytics API: exposes
- Authentication & roles → Auth API: protects
- Auth API → Auth service: invokes
- Auth service → Auth repository: persists via
- Auth repository → Relational database: reads/writes
- Service request API → Request workflow: invokes
- Request workflow → Request state machine: validates transitions
- Request workflow → Request repository: persists via
- Request workflow → Audit trail: records changes
- Request repository → Relational database: reads/writes
- Comments → Relational database: stores comments
- Approvals → Relational database: stores decisions
- Audit trail → Relational database: stores history
- SLA scheduler → SLA policies: evaluates with
- SLA policies → Relational database: manages policies
- Analytics API → Relational database: aggregates from
- Database access → Relational database: connects to
- SQL migrations → Relational database: evolves schema