Skip to content

fix: correct API module paths from byte_bot to byte_api#129

Merged
JacobCoffee merged 1 commit intomainfrom
fix/api-startup
Nov 23, 2025
Merged

fix: correct API module paths from byte_bot to byte_api#129
JacobCoffee merged 1 commit intomainfrom
fix/api-startup

Conversation

@JacobCoffee
Copy link
Owner

@JacobCoffee JacobCoffee commented Nov 23, 2025

Summary

Fixes the API service startup failure caused by incorrect module path references after the Phase 2 microservices migration. The application was attempting to import byte_bot.app:create_app instead of the correct byte_api.app:create_app.

Root Cause: Old monolith module paths not updated during Phase 1/2 migration.

Error Fixed:

Using Litestar app from env: 'byte_bot.app:create_app': Module not found

Changes

  • .env.example: Updated LITESTAR_APP to use byte_api.app:create_app
  • services/api/Dockerfile: Updated uvicorn command to use correct module path with --factory flag
  • services/api/README.md: Updated documentation references from byte_bot/* to byte_api/*

Note: .env also needs manual update by users (file is gitignored)

Impact

  • API service can now start successfully via make run-dev-server and Docker
  • No breaking changes to API endpoints or functionality
  • Pure configuration/path fix

Testing

  • All 1036 tests passing (make ci)
  • Verified module import works correctly
  • Docker Compose configuration validated

Checklist

  • Updated all module path references
  • Verified Docker CMD uses --factory flag
  • Updated documentation
  • All CI checks passing (lint, type-check, fmt, tests)
  • Atomic commit with clear message

🤖 Generated with Claude Code

Summary by Sourcery

Correct API service configuration and documentation to reference the new byte_api module entrypoint instead of legacy paths.

Bug Fixes:

  • Fix API container startup by pointing uvicorn to the byte_api app factory entrypoint.

Documentation:

  • Update API service README to describe the new byte_api module layout and entrypoints.

Chores:

  • Adjust example environment configuration to use the byte_api Litestar app path.

Updated all references to use the correct microservices module path:
- .env.example: LITESTAR_APP=byte_api.app:create_app
- services/api/Dockerfile: uvicorn byte_api.app:create_app --factory
- services/api/README.md: documentation references

This fixes the "Module not found" error when starting the API service.
Note: .env also needs manual update (not tracked in git).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@railway-app
Copy link

railway-app bot commented Nov 23, 2025

🚅 Environment byte-pr-129 in byte has no services deployed.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 23, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes incorrect Litestar application module references after the microservices migration by pointing configuration, Docker startup command, and documentation from the old byte_bot module paths to the correct byte_api app factory entrypoint.

Sequence diagram for corrected Docker-based API service startup

sequenceDiagram
  participant R as "Runtime / Orchestrator"
  participant C as "API Service Container"
  participant S as "Shell Process (sh -c)"
  participant M as "Alembic"
  participant U as "Uvicorn"
  participant B as "Python Module 'byte_api.app'"
  participant F as "Factory Function 'create_app'"
  participant L as "Litestar Application Instance"

  R->>C: "Start container with CMD 'alembic upgrade head && uvicorn byte_api.app:create_app --factory ...'"
  C->>S: "Execute combined shell command"
  S->>M: "Run 'alembic upgrade head'"
  M-->>S: "Migrations complete"
  S->>U: "Start 'uvicorn byte_api.app:create_app --factory ...'"
  U->>B: "Import module 'byte_api.app'"
  B-->>U: "Module loaded successfully"
  U->>F: "Call 'create_app()' (factory mode)"
  F-->>U: "Return Litestar application instance"
  U->>L: "Attach app instance and start serving"
  L-->>R: "API service ready to accept HTTP requests"
Loading

Flow diagram for Litestar app startup using corrected byte_api factory

flowchart TD
  A["Start API service container"] --> B["Load environment configuration ('.env' / '.env.example')"]
  B --> C{"'LITESTAR_APP' set to 'byte_api.app:create_app'?"}
  C -->|"Yes"| D["Run 'alembic upgrade head' via shell CMD"]
  C -->|"No"| E["Startup fails: Litestar app reference invalid"]
  D --> F["Invoke 'uvicorn byte_api.app:create_app --factory --host 0.0.0.0 --port 8000 --workers 2'"]
  F --> G["Uvicorn imports module 'byte_api.app'"]
  G --> H["Call factory function 'create_app()' (because of '--factory')"]
  H --> I["Litestar app instance created"]
  I --> J["Uvicorn binds to port 8000 and starts event loop"]
  J --> K["API service is ready and serving HTTP requests"]
Loading

File-Level Changes

Change Details Files
Update runtime entrypoint to use the Litestar app factory instead of the old app object and ensure Docker starts the correct API service module.
  • Change uvicorn CMD to invoke byte_api.app:create_app instead of byte_api.app:app
  • Add the --factory flag so uvicorn treats create_app as an app factory
  • Keep existing Alembic migration step while adjusting only the module path and invocation style
services/api/Dockerfile
Align environment configuration and documentation with the new byte_api module layout instead of legacy byte_bot paths.
  • Update LITESTAR_APP example value to byte_api.app:create_app so local/dev setups import the correct app factory
  • Refresh README service description to reference byte_api/app.py, byte_api/domain, and byte_api/lib in place of old byte_bot paths
.env.example
services/api/README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@railway-app railway-app bot temporarily deployed to byte (byte / byte-pr-129) November 23, 2025 22:41 Destroyed
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions
Copy link

Documentation preview will be available shortly at https://jacobcoffee.github.io/byte-docs-preview/129

@JacobCoffee JacobCoffee merged commit d77f5d3 into main Nov 23, 2025
5 checks passed
@JacobCoffee JacobCoffee deleted the fix/api-startup branch November 23, 2025 22:44
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