Skip to content

feat: create CodeRepos class#961

Draft
CasLubbers wants to merge 3 commits intomainfrom
cas-fix-stack
Draft

feat: create CodeRepos class#961
CasLubbers wants to merge 3 commits intomainfrom
cas-fix-stack

Conversation

@CasLubbers
Copy link
Copy Markdown
Contributor

@CasLubbers CasLubbers commented Mar 30, 2026

This PR is the first step in breaking down the OtomiStack God Object into smaller, cohesive domain classes.

What was done
Extracted all Code Repository–related logic into a new CodeRepos domain class
Introduced a Deployer class to encapsulate deployment-related logic
Updated route handlers to use:

req.otomi.codeRepos.<method>()

instead of calling methods directly on OtomiStack

Added an explicit initialization method to wire dependencies:

initDomain() {
  this.deployer = new Deployer(this.git, this.fileStore, this.editor, this.sessionId)
  this.codeRepos = new CodeRepos(this.fileStore, this.deployer)
}

Design choices

  • Facade pattern preserved
  • OtomiStack remains the session-scoped entry point (req.otomi)
  • Explicit initialization over lazy loading
  • Domain objects are created via initDomain() after infrastructure (git, fileStore) is ready, instead of using lazy-loaded getters
  • Use composition:
    • Domain classes are instantiated using new to keep the initial refactor simple and avoid premature abstraction

Open questions / follow-ups

  • Should we switch to lazy-loaded getters to defer object creation?
  • Do we want to evolve this into a more formal composition root pattern (e.g. factory/builder) to guarantee fully-initialized objects?
    Next steps
  • Continue extracting other domains (e.g. Builds, Teams, etc.) following the same pattern
  • Re-evaluate initialization strategy (lazy vs explicit) once more domains are migrated

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.

2 participants