Skip to content

refactor:vcs strategy refactor - #386

Open
mohamedadel96e wants to merge 2 commits into
oblien:mainfrom
mohamedadel96e:feat/vcs-strategy-refactor
Open

refactor:vcs strategy refactor#386
mohamedadel96e wants to merge 2 commits into
oblien:mainfrom
mohamedadel96e:feat/vcs-strategy-refactor

Conversation

@mohamedadel96e

Copy link
Copy Markdown

Motivation & Context

Currently, the codebase is tightly coupled to GitHub as the sole source code provider, primarily through direct dependencies on github.service.ts across deployment and project modules. As we aim to support additional providers (such as GitLab and Self-Hosted options), this hard dependency creates friction and scaling challenges.

This PR resolves this technical debt by introducing a provider-agnostic Version Control System (VCS) abstraction layer using the Strategy pattern. This allows the core application to interact with git repositories purely through interfaces, decoupling it from any specific provider implementation while maintaining full backwards compatibility for existing GitHub projects.

Related issue

Closes #379

Architecture & Implementation

1. Strategy Pattern Abstraction

  • Introduced a VcsProviderStrategy interface that defines the contract for all repository operations (e.g., getting branches, commits, fetching files, resolving webhooks).
  • Implemented VcsStrategyFactory which serves as the central resolver, dynamically returning the correct implementation (e.g., github, gitlab) based on the project's configured gitProvider.

2. Generic API Endpoints (/api/vcs/:provider)

  • Extracted generic repository endpoints out of github.routes.ts into a dedicated set of generic vcs.routes.ts and vcs.controller.ts.
  • The dashboard frontend (apps/dashboard/src/lib/api/) has been migrated to consume the new /api/vcs/github/ routes, removing hardcoded assumptions about GitHub from the client-side API layer.

3. Core Modules Migration

Refactored the core domain modules to rely entirely on VcsStrategyFactory:

  • Deployments: build-pipeline.ts, preflight.ts, and prepare.service.ts now resolve the appropriate strategy using project.gitProvider before executing git operations.
  • Projects: project-crud.service.ts and project.controller.ts dynamically handle project creation, repo linking, and tear-downs using the generic VCS interface.
  • Webhooks: vcs.webhook.processor.ts now accepts a generic VcsPushPayload and dynamically handles incoming push events regardless of the origin.

4. Database Schema Alignment

  • Adapted schema typing to account for abstract provider configurations (gitProvider, etc.) to ensure long-term flexibility without losing any existing GitHub data.

Verification & Testing

To guarantee strict backwards compatibility and ensure no regressions were introduced, the following checks were performed locally:

  • Strict Diffing: Formatting drift (prettier output on unmodified lines) was manually scrubbed from the diff to ensure strict compliance with the contributing guidelines. Only logical changes are included in this PR.
  • Type Checking: Ran bun run tsc --noEmit locally on the modified packages (apps/api, apps/dashboard, packages/db). All packages compile perfectly with zero TypeScript errors.
  • Unit & Integration Tests: Executed the root bun run test suite across all workspaces. All 1,877 tests passed flawlessly.
  • Production Build: Ran the root bun run build command, successfully compiling the optimized assets and static routes for both the API and the Dashboard without issue.

Screenshots

image

these changes don't fully close the issue if we want to support another git provider right now, we should implement each strategy.

- Introduce `VcsProviderStrategy` interface and `VcsStrategyFactory`.
- Migrate `deployments`, `projects`, and `migration` modules to use provider-agnostic VCS abstractions instead of hardcoded `github.service`.
- Create `/api/vcs/:provider` endpoints to handle generic operations.
- Introduce `vcs.webhook.processor.ts` for handling provider-agnostic webhook push payloads.
- Ensure strict TypeScript compliance and backwards compatibility for existing github projects.
Abstract version control system into generic provider architecture.

- Introduce VcsProviderStrategy interface and VcsStrategyFactory.

- Migrate deployments, projects, and migration modules to use provider-agnostic VCS abstractions instead of hardcoded github.service.

- Create /api/vcs/:provider endpoints to handle generic operations.

- Introduce vcs.webhook.processor.ts for handling provider-agnostic webhook push payloads.

- Ensure strict TypeScript compliance and backwards compatibility for existing github projects.
@mohamedadel96e
mohamedadel96e force-pushed the feat/vcs-strategy-refactor branch from dbd7ecb to 41eacde Compare August 1, 2026 18:35
@mohamedadel96e mohamedadel96e changed the title Feat/vcs strategy refactor feat:vcs strategy refactor Aug 1, 2026
@mohamedadel96e mohamedadel96e changed the title feat:vcs strategy refactor refactor:vcs strategy refactor Aug 1, 2026
@Hydralerne

Copy link
Copy Markdown
Member

huge, gonna review

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.

Help Wanted: Replace GitHub-Only Integration with Multi-Git Provider Support

2 participants