Skip to content

refactor(onboarding): migrate to module-based structure and extract service layer#9

Merged
Nirbhay21 merged 1 commit into
mainfrom
refactor/module-based-architecture
Feb 15, 2026
Merged

refactor(onboarding): migrate to module-based structure and extract service layer#9
Nirbhay21 merged 1 commit into
mainfrom
refactor/module-based-architecture

Conversation

@Nirbhay21
Copy link
Copy Markdown
Owner

Summary

This PR restructures the backend from a layer-based architecture to a module-based architecture and extracts onboarding business logic into a dedicated service layer.
The onboarding flow is now clearly separated into:

  • draft saving (PATCH /onboarding)
  • completion (POST /onboarding/complete)
    Controllers are thin, business logic lives in services, and shared utilities are centralized.

Scope

  • Migrate project from layer-based structure (controllers, routes, lib) to module-based architecture.
  • Extract onboarding business logic into OnboardingService.
  • Introduce dedicated completion endpoint for onboarding.
  • Centralize shared logic into /shared.
  • Improve schema typing and validation boundaries.

Architectural Changes

1. Module-Based Structure

Reorganized features into self-contained modules:

  • modules/auth
  • modules/health
  • modules/onboarding

Each module now contains:

  • controller
  • routes
  • schemas
  • types
  • service (if applicable)

Shared utilities moved to:

  • shared/auth
  • shared/constants
  • shared/errors
  • shared/middlewares

Environment config moved to:

  • config/env.schema.ts

Onboarding Refactor

Controller → Service Extraction

  • Removed fat onboarding.controller.ts
  • Introduced OnboardingService (360 LOC)
  • Controller now:
    • Handles HTTP orchestration only
    • Delegates all business logic to service layer

Endpoint Changes

  • PUT /onboarding → replaced with:
    • PATCH /onboarding (save draft only)
    • POST /onboarding/complete (finalize onboarding)
      Completion logic separated from draft updates.

Validation Changes

  • Removed old onboarding-status.schema.ts
  • Introduced onboarding-status-update.schema.ts
  • Enforced:
    • PATCH cannot mark onboarding as completed
    • Completion must go through /onboarding/complete

Improved DB draft typing:

CandidateOnboardingDraftData | RecruiterOnboardingDraftData | null

@Nirbhay21 Nirbhay21 merged commit 366032f into main Feb 15, 2026
@Nirbhay21 Nirbhay21 deleted the refactor/module-based-architecture branch February 15, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant