Skip to content

feat: gateways get created on project init#4367

Merged
chronark merged 6 commits intomainfrom
11-19-feat_gateways_get_created_on_project_init
Nov 26, 2025
Merged

feat: gateways get created on project init#4367
chronark merged 6 commits intomainfrom
11-19-feat_gateways_get_created_on_project_init

Conversation

@chronark
Copy link
Collaborator

@chronark chronark commented Nov 19, 2025

What does this PR do?

Relocates the protobuf generated files from internal/proto to apps/dashboard/gen/proto and updates all imports to use the new location. This change removes the dependency on the @unkey/proto package and instead directly imports the generated protobuf files from their new location.

Type of change

  • Chore (refactoring code, technical debt, workflow improvements)

How should this be tested?

  • Verify that the dashboard can still make API calls to the backend services
  • Check that the OpenAPI diff functionality still works correctly
  • Test project creation flow to ensure it communicates properly with the backend

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Ran make fmt on /go directory
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

@changeset-bot
Copy link

changeset-bot bot commented Nov 19, 2025

⚠️ No Changeset found

Latest commit: 50d7032

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dashboard Ready Ready Preview Comment Nov 26, 2025 1:45pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
engineering Ignored Ignored Preview Nov 26, 2025 1:45pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR migrates from an internal proto package to generated proto files, updates import paths across the dashboard, implements new Project and Environment services in the backend, and transitions project creation from a local database transaction to a remote Ctrl service call. Additionally, the environments.description column is made non-nullable with a default value.

Changes

Cohort / File(s) Summary
Proto Definitions
go/proto/ctrl/v1/project.proto, go/proto/ctrl/v1/environment.proto, go/proto/hydra/v1/project.proto, go/proto/hydra/v1/environment.proto
New protocol buffer definitions for ProjectService and EnvironmentService in both ctrl and hydra layers, establishing API contracts for project and environment creation with request/response message types.
Generated Database Access Layer
go/pkg/db/bulk_environment_insert.sql_generated.go, go/pkg/db/environment_insert.sql_generated.go, go/pkg/db/environment_find_by_id.sql_generated.go, go/pkg/db/environment_find_by_project_id_and_slug.sql_generated.go
New auto-generated SQL data-access methods for environment insertion and queries; Description field type changed from sql.NullString to string.
Database Schema & Model Updates
go/pkg/db/schema.sql, go/pkg/db/models_generated.go, go/pkg/db/querier_generated.go, go/pkg/db/querier_bulk_generated.go, go/pkg/db/queries/environment_insert.sql, internal/db/src/schema/environments.ts
Schema updates making environments.description NOT NULL with default empty string; corresponding generated model and querier interface updates; Drizzle ORM schema updated.
Dashboard Import Path Migrations
apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/details/project-details-expandables/sections/open-api-diff.tsx, apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/client.tsx, apps/dashboard/lib/trpc/routers/deploy/deployment/getOpenApiDiff.ts, apps/dashboard/lib/trpc/routers/deploy/deployment/promote.ts, apps/dashboard/lib/trpc/routers/deploy/deployment/rollback.ts
Import paths updated from @unkey/proto to @/gen/proto/ctrl/v1/* for OpenAPI and Deployment service types.
Go Service Implementations (Ctrl)
go/apps/ctrl/services/project/service.go, go/apps/ctrl/services/project/create_project.go
New ProjectService implementation with CreateProject method that forwards requests to Hydra's ProjectServiceIngressClient; includes Config struct and New constructor for dependency injection.
Go Workflow Implementations (Hydra)
go/apps/ctrl/workflows/project/service.go, go/apps/ctrl/workflows/project/create.go
New ProjectService workflow for Hydra with CreateProject implementation that manages project/environment creation, gateway provisioning via Krane, and database persistence.
Project Creation Service Migration
apps/dashboard/lib/trpc/routers/deploy/project/create.ts
Project creation logic moved from local database transaction to remote Ctrl service via Connect client; adds environment-based validation for CTRL_URL and CTRL_API_KEY; removes local project/environment/audit-log creation.
Service Registration & Wiring
go/apps/ctrl/run.go, go/apps/krane/run.go
Ctrl services extended with Project service handler and Restate workflow binding; Krane services refactored to support both Deployment and Gateway handlers via composite Svc interface.
Build Configuration & Cleanup
apps/dashboard/Dockerfile, apps/dashboard/package.json, go/buf.gen.connect.yaml, deployment/Dockerfile.mysql, deployment/05-seed-chronark.sql, internal/proto/src/index.ts, internal/proto/tsconfig.json
Removed internal/proto package copy from dashboard Dockerfile; added @bufbuild/protobuf dependency; removed @marsidev/react-turnstile dependency; updated buf proto code generation output to apps/dashboard/gen/proto; re-enabled chronark seed in deployment; removed internal proto exports.
Krane Comment Updates
go/apps/krane/backend/kubernetes/gateway_get.go
Updated comments to reference "gateway" instead of "deployment" for consistency; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dashboard as Dashboard<br/>(create.ts)
    participant Ctrl as Ctrl API<br/>(ProjectService)
    participant Hydra as Hydra<br/>(ProjectService Workflow)
    participant DB as Database
    participant Krane as Krane<br/>(GatewayService)

    Dashboard->>Ctrl: CreateProject Request<br/>(workspaceId, name, slug, gitRepository)
    Ctrl->>Ctrl: Validate workspace & slug
    Ctrl->>Hydra: CreateProject via Restate
    Hydra->>DB: Insert Project record
    Hydra->>DB: Insert Dev Environment
    Hydra->>Krane: Provision Dev Gateway<br/>(replicas: 1, image: nginx)
    Krane->>DB: Create Gateway record
    Hydra->>DB: Insert Prod Environment
    Hydra->>Krane: Provision Prod Gateway<br/>(replicas: 3, image: nginx)
    Krane->>DB: Create Gateway record
    Hydra->>Hydra: Return ProjectId
    Ctrl->>Dashboard: CreateProjectResponse<br/>(projectId)
    Dashboard->>Dashboard: Return created project
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas requiring extra attention:
    • apps/dashboard/lib/trpc/routers/deploy/project/create.ts — Critical logic migration from local transactional creation to remote service call; error handling and precondition validation changes need verification
    • go/apps/ctrl/workflows/project/create.go — Complex workflow orchestrating project, environment, and gateway creation across multiple services; restate.Run contexts and transaction semantics should be reviewed
    • Database schema migration for environments.description — NOT NULL constraint change may require validation that existing records are handled correctly or migrated
    • Service wiring in go/apps/ctrl/run.go and go/apps/krane/run.go — New service handler registration and client setup must be verified for correctness
    • Cross-cutting proto changes affecting generated code — Ensure all generated files (database, services) are correctly reflecting the new schema and proto definitions
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 11-19-feat_gateways_get_created_on_project_init

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a34739 and 50d7032.

⛔ Files ignored due to path filters (21)
  • apps/dashboard/gen/proto/cache/v1/invalidation_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/acme_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/build_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/deployment_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/environment_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/openapi_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/project_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/ctrl/v1/service_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/krane/v1/deployment_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/krane/v1/gateway_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/vault/v1/object_pb.ts is excluded by !**/gen/**
  • apps/dashboard/gen/proto/vault/v1/service_pb.ts is excluded by !**/gen/**
  • go/gen/proto/ctrl/v1/ctrlv1connect/environment.connect.go is excluded by !**/gen/**
  • go/gen/proto/ctrl/v1/ctrlv1connect/project.connect.go is excluded by !**/gen/**
  • go/gen/proto/ctrl/v1/environment.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • go/gen/proto/ctrl/v1/project.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • go/gen/proto/hydra/v1/environment.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • go/gen/proto/hydra/v1/environment_restate.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • go/gen/proto/hydra/v1/project.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • go/gen/proto/hydra/v1/project_restate.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • apps/dashboard/Dockerfile (0 hunks)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/details/project-details-expandables/sections/open-api-diff.tsx (1 hunks)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/client.tsx (1 hunks)
  • apps/dashboard/lib/trpc/routers/deploy/deployment/getOpenApiDiff.ts (2 hunks)
  • apps/dashboard/lib/trpc/routers/deploy/deployment/promote.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/deploy/deployment/rollback.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/deploy/project/create.ts (3 hunks)
  • apps/dashboard/package.json (2 hunks)
  • deployment/05-seed-chronark.sql (1 hunks)
  • deployment/Dockerfile.mysql (1 hunks)
  • go/apps/ctrl/run.go (5 hunks)
  • go/apps/ctrl/services/project/create_project.go (1 hunks)
  • go/apps/ctrl/services/project/service.go (1 hunks)
  • go/apps/ctrl/workflows/project/create.go (1 hunks)
  • go/apps/ctrl/workflows/project/service.go (1 hunks)
  • go/apps/krane/backend/kubernetes/gateway_get.go (1 hunks)
  • go/apps/krane/run.go (3 hunks)
  • go/buf.gen.connect.yaml (1 hunks)
  • go/pkg/db/bulk_environment_insert.sql_generated.go (1 hunks)
  • go/pkg/db/environment_find_by_id.sql_generated.go (1 hunks)
  • go/pkg/db/environment_find_by_project_id_and_slug.sql_generated.go (1 hunks)
  • go/pkg/db/environment_insert.sql_generated.go (1 hunks)
  • go/pkg/db/models_generated.go (1 hunks)
  • go/pkg/db/querier_bulk_generated.go (1 hunks)
  • go/pkg/db/querier_generated.go (1 hunks)
  • go/pkg/db/queries/environment_insert.sql (1 hunks)
  • go/pkg/db/schema.sql (1 hunks)
  • go/proto/ctrl/v1/environment.proto (1 hunks)
  • go/proto/ctrl/v1/project.proto (1 hunks)
  • go/proto/hydra/v1/environment.proto (1 hunks)
  • go/proto/hydra/v1/project.proto (1 hunks)
  • go/proto/krane/v1/gateway.proto (0 hunks)
  • internal/db/src/schema/environments.ts (1 hunks)
  • internal/proto/src/index.ts (0 hunks)
  • internal/proto/tsconfig.json (0 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator Author

chronark commented Nov 19, 2025

@chronark chronark mentioned this pull request Nov 19, 2025
12 tasks
@vercel vercel bot temporarily deployed to Preview – engineering November 19, 2025 22:19 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard November 19, 2025 22:22 Inactive
@chronark chronark mentioned this pull request Nov 20, 2025
19 tasks
Base automatically changed from 11-19-feat_krane_k8s_gateway_rpcs to main November 26, 2025 13:30
@vercel vercel bot temporarily deployed to Preview – engineering November 26, 2025 13:38 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard November 26, 2025 13:39 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard November 26, 2025 13:45 Inactive
@chronark chronark marked this pull request as ready for review November 26, 2025 13:51
@chronark chronark merged commit 9bc368a into main Nov 26, 2025
23 checks passed
@chronark chronark deleted the 11-19-feat_gateways_get_created_on_project_init branch November 26, 2025 13:51
@coderabbitai coderabbitai bot mentioned this pull request Mar 17, 2026
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