Skip to content

fix: API imports and update system message content#38

Merged
GTPSHAX merged 3 commits into
NgodingCik:mainfrom
GTPSHAX:dev
May 6, 2026
Merged

fix: API imports and update system message content#38
GTPSHAX merged 3 commits into
NgodingCik:mainfrom
GTPSHAX:dev

Conversation

@GTPSHAX
Copy link
Copy Markdown
Contributor

@GTPSHAX GTPSHAX commented May 6, 2026

Summary

This PR focuses on optimizing the Web application's architecture through dynamic route loading and refining the AI Autofill logic. These changes reduce the initial bundle size of the web app and significantly improve the precision of AI-generated suggestions by enforcing stricter output constraints.

Key Changes

  • Dynamic API Routing: Refactored apps/web/index.js to use a dynamic await import() for the @repo/api routes. This allows the application to load the API layer conditionally, improving startup efficiency.
  • Dependency Cleanup: Removed the @repo/api package from the apps/web dependencies list, shifting toward a more decoupled workspace relationship.
  • Prompt Engineering: Enhanced the system prompt for the AI Autofill handler. The AI is now explicitly instructed to provide exactly one theme and one subtheme, supported by "Few-Shot" examples (correct vs. incorrect formats) to minimize token waste and parsing errors.

Why this is necessary

  1. Reduced Overhead: By moving to dynamic imports, the apps/web service doesn't need to eagerly load the entire API routing tree, which is beneficial for memory management and faster cold starts.
  2. Output Reliability: The previous AI prompt was prone to verbose or multi-option responses. Forcing a singular selection (one theme, one subtheme) ensures the frontend receives exactly what it needs for the UI without additional filtering.
  3. Workspace Decoupling: Removing static dependencies between apps within the monorepo prevents circular dependency issues and simplifies the build graph.

How to Test

  1. Route Verification: Start the web application and navigate to an endpoint that triggers the built-in API. Ensure the dynamic import resolves correctly and the routes are accessible.
  2. AI Precision Check: Use the Autofill feature in the UI. Verify that the AI now returns a single, concise pair of "Theme" and "Subtheme" instead of a list or a paragraph of text.
  3. Build Audit: Run npm list in apps/web to confirm that @repo/api is no longer listed as a direct dependency.

@GTPSHAX GTPSHAX self-assigned this May 6, 2026
@GTPSHAX GTPSHAX added the enhancement New feature or request label May 6, 2026
@GTPSHAX GTPSHAX merged commit e5785bd into NgodingCik:main May 6, 2026
1 check passed
@GTPSHAX GTPSHAX deleted the dev branch May 6, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant