How rs-talentos-ufsm/sulflux.backend works
This repository is a production-oriented Express backend template. A client sends API requests through the app’s global middleware and route dispatch; domain controllers validate requests, delegate to services, and return results backed by PostgreSQL. Authentication protects selected routes with cookie-based JWTs. The graph also preserves documented validation, API documentation, security, and observability capabilities. Some supporting source was not sampled, so unsourced wiring is omitted rather than inferred.
Main entry points: app.ts Express app · index.ts Route dispatch · ensureAuthenticated.ts JWT auth · database.ts Prisma data access
Components 26
API entry
- Express app
src/app.ts - Route dispatch
src/routes/index.ts - Auth routes
src/modules/auth/auth.routes.ts - User routes
src/modules/user/user.routes.ts - Property routes
src/modules/property/property.routes.ts - Field routes
src/modules/field/field.routes.ts
Domain modules
- Auth controller
src/modules/auth/auth.controller.ts - Auth service
src/modules/auth/auth.service.ts - User controller
src/modules/user/user.controller.ts - User service
src/modules/user/user.service.ts - Property controller
src/modules/property/property.controller.ts - Property service
src/modules/property/property.service.ts - Field controller
src/modules/field/field.controller.ts - Field service
src/modules/field/field.service.ts
Data and security
- JWT auth
src/middleware/ensureAuthenticated.ts - JWT utilities
src/utils/jwt.ts - Password hashing
src/utils/password.service.ts - Prisma data access
src/infra/database.ts
Cross-cutting services
- Payload validation
src/middleware/validateMiddleware.ts - HTTP protections
src/app.ts - Swagger docs
src/utils/swagger.ts - Structured logging
src/utils/logger.ts - OpenTelemetry
src/observability/tracing.ts - File storage
src/utils/FileStorageService.ts
Other components
- API client
- PostgreSQL
Connections 31
- API client → Express app: sends requests
src/app.ts - Express app → Route dispatch: mounts routes
src/app.ts - Route dispatch → Auth routes: dispatches auth
src/routes/index.ts - Route dispatch → User routes: dispatches users
src/routes/index.ts - Route dispatch → Property routes: dispatches properties
src/routes/index.ts - Route dispatch → Field routes: dispatches fields
src/routes/index.ts - Auth routes → Auth controller: routes to
src/modules/auth/auth.routes.ts - User routes → User controller: routes to
src/modules/user/user.routes.ts - Property routes → Property controller: routes to
src/modules/property/property.routes.ts - Field routes → Field controller: routes to
src/modules/field/field.routes.ts - Auth routes → JWT auth: guards routes
src/modules/auth/auth.routes.ts - User routes → JWT auth: guards routes
src/modules/user/user.routes.ts - Property routes → JWT auth: guards routes
src/modules/property/property.routes.ts - Field routes → JWT auth: guards routes
src/modules/field/field.routes.ts - Auth controller → Auth service: delegates to
src/modules/auth/auth.controller.ts - User controller → User service: delegates to
src/modules/user/user.controller.ts - Property controller → Property service: delegates to
src/modules/property/property.controller.ts - Field controller → Field service: delegates to
src/modules/field/field.controller.ts - JWT auth → JWT utilities: verifies token
src/middleware/ensureAuthenticated.ts - Auth service → Prisma data access: reads and writes
src/modules/auth/auth.service.ts - Auth service → Password hashing: hashes passwords
src/modules/auth/auth.service.ts - Auth service → JWT utilities: issues tokens
src/modules/auth/auth.service.ts - User service → Prisma data access: reads and writes
src/modules/user/user.service.ts - Property service → Prisma data access: reads and writes
src/modules/property/property.service.ts - Field service → Prisma data access: reads and writes
src/modules/field/field.service.ts - Prisma data access → PostgreSQL: persists data
README.md - Express app → Swagger docs: sets up docs
src/app.ts - Express app → Structured logging: configures logging
src/app.ts - Express app → HTTP protections: applies protections
src/app.ts - Express app → Payload validation: validates requests
README.md - Express app → OpenTelemetry: starts tracing
src/server.ts