Skip to content

Extract db, models, ui, and provider-github into dedicated packages - #89

Open
devarshishimpi wants to merge 9 commits into
mainfrom
refactor/restructure-codra-workspace-packages-p2
Open

Extract db, models, ui, and provider-github into dedicated packages#89
devarshishimpi wants to merge 9 commits into
mainfrom
refactor/restructure-codra-workspace-packages-p2

Conversation

@devarshishimpi

Copy link
Copy Markdown
Owner

Description

Continues the workspace restructuring started in #87, splitting more of src/server and src/client out of the monolithic app into standalone packages/apps:

  • packages/db - all src/server/db/* modules (accounts, jobs, settings, repo-configs, migrations, repository classes) become a standalone package with its own package.json/tsconfig/vitest.config.
  • packages/models - the model-provider layer (Anthropic, Google, OpenAI, Vertex, Cloudflare providers, chain runner, rate limits, catalog, schema handling) and its full spec suite move out of src/server/models.
  • packages/provider-github - GitHub App auth, HTTP client, diff fetch, labels, OAuth, and review-post logic extracted into a dedicated provider package (continuing the pattern from the earlier GitHub-provider extraction).
  • packages/ui - shared React components (button, input, select, layer-card, badges, chart primitives, motion helpers) and client-side libs (theme, highlight, markdown-plugins, file-tree) consolidated into a UI package consumed by src/client.
  • apps/worker - the Cloudflare Worker entry point, wrangler config, env/session/orchestrator ports split out into its own app directory.
  • Central constants.ts files added to packages/core, packages/db, and packages/schema to replace scattered default configs.

Part of #66
Closes #70 #71 #72 #73 #75

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (refactoring, dependency updates, etc.)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • Unit Tests
  • Integration Tests
  • Manual Dashboard Verification
  • Manual GitHub Webhook Verification

Checklist:

  • I have starred Codra on GitHub
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • I have signed the CLA

Comment thread packages/models/src/providers/anthropic.ts Fixed
Comment thread packages/models/src/providers/google.ts Fixed
Comment thread packages/models/src/providers/openai.ts Fixed
Comment thread packages/models/src/providers/vertex.ts Fixed
@devarshishimpi
devarshishimpi marked this pull request as ready for review August 15, 2026 16:00
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@codra-app-personal codra-app-personal Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codra Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a691753727

ℹ️ About Codra in GitHub

Your team has set up Codra to review pull requests in this repo. Reviews are triggered when you:

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codra-app review"

If Codra has suggestions, it will comment; otherwise it will react with 👍.

Codra can also answer questions or update the PR. Try commenting "@codra-app address that feedback".

import { runBestEffortJobMaintenance } from '@server/core/job-recovery';
import { runWithDb } from '@server/db/client';
import type { AppBindings } from '../env';
import type { WorkflowStep } from 'cloudflare:workers';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Missing Workflow import

The class constructor uses the Workflow type, but it is not imported from cloudflare:workers. This will lead to a compilation error as Workflow is not available globally.

Suggested change
import type { WorkflowStep } from 'cloudflare:workers';
import type { Workflow, WorkflowStep } from 'cloudflare:workers';

}

async createSession(session: DashboardSessionUser): Promise<string> {
const token = Math.random().toString(36).substring(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Insecure session token generation

The application uses Math.random() to generate session tokens. This PRNG is not cryptographically secure and is predictable, which allows attackers to potentially guess active session tokens and hijack user sessions. Use crypto.randomUUID() or crypto.getRandomValues() to generate tokens instead.

private kv = new InMemoryKV();

async createSession(session: DashboardSessionUser): Promise<string> {
const token = Math.random().toString(36).substring(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Use of cryptographically weak random number generator for session token

Math.random() is not cryptographically secure and should not be used to generate session tokens. It is predictable and vulnerable to attacks, even if used in a mock implementation.

"test": "vitest run"
},
"dependencies": {
"@codra/schema": "*",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Ambiguous dependency versioning

Using '' for monorepo internal dependencies is non-deterministic and can cause resolution issues in workspace environments. Use 'workspace:' to ensure the local workspace version is always used.

Suggested change
"@codra/schema": "*",
"@codra/schema": "workspace:*"

Comment thread packages/db/tsconfig.json
"composite": false,
"declaration": false,
"emitDeclarationOnly": false,
"noEmit": true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Package emits no build artifacts

The 'noEmit: true' setting prevents the package from generating type definitions (.d.ts files). If this package is intended to be consumed by other workspace packages as a library, it will fail to provide type safety to consumers unless they import source files directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define a git-provider port and move GitHub behind @codra/provider-github

2 participants