Skip to content

Comments

Architecture improvements & refactors#30

Draft
Xitee1 wants to merge 6 commits intomainfrom
code-quality-improvements
Draft

Architecture improvements & refactors#30
Xitee1 wants to merge 6 commits intomainfrom
code-quality-improvements

Conversation

@Xitee1
Copy link
Owner

@Xitee1 Xitee1 commented Feb 16, 2026

Prompt:
This project has been vibe coded with AI and also has been heavily refactored and restructured in the meantime. Analyze the code of this project and find areas that can be improved. I mainly want to address the overall architecture and for things to follow best practices and good conventions. Also make use of official documentations by fetching them with context7. You MUST do that if using new libraries or change functions of those. Only analyze the backend. Exclude tests from analyzing. I want you to find the most severe issue and then only work on that, nothing else. Also feel free to suggest adding new libraries if appropriate. The prompt will be looped multiple times until the code is in good shape. This is run X.

To replace:

  • Only analyze the backend, Exclude tests from analyzing.
  • This is run X

…ayer

The orders API route handlers contained all business logic inline — direct ORM
operations, query building, and order merging logic — bypassing the service
layer. This moves all domain logic into order_service.py, making routes thin
HTTP wrappers that only handle request parsing and error translation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Xitee1 Xitee1 changed the title refactor: extract order business logic from API routes into service l… Architecture improvements & refactors Feb 16, 2026
Xitee1 and others added 5 commits February 16, 2026 21:49
Replace 43 duplicated unsafe error-handling blocks (using TypeScript `as`
casts) across 19 files with type-safe getApiErrorMessage/getApiErrorStatus
utilities that use axios.isAxiosError(). Extract 5 duplicated formatDate,
3 formatAmount, and formatTimeAgo/formatTimeUntil functions into shared
utils/format.ts module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dlers

The IMAP test_connection and list_folders endpoints used synchronous
imaplib, which blocked the entire asyncio event loop during network I/O.
Extract shared async IMAP utilities (connect, test, list folders, parse)
into _shared/email/imap_utils.py using aioimaplib, eliminating both the
event loop blocking bug and the duplicated IMAP logic between email-user
and email-global routers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Eliminate ~350 lines of duplicated IMAP watching logic between email_user
and email_global services by extracting generic watch/idle/poll/fetch
functions that accept provider-specific behavior via a callbacks dataclass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move EmailAnalysis/EmailItem to shared schemas so the core service layer
no longer depends on a specific plugin module. Analysis is now routed
through the module registry via a new `analyze` hook on ModuleInfo,
consistent with how `notify` already works for notifiers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…fallback

- Rename EmailAnalysis→AnalysisResult, EmailItem→ExtractedItem,
  email_type→document_type across all files
- Rename email_analysis.py→analysis.py (shared schema)
- Change get_active_analyser() to get_active_analysers() returning all
  enabled analysers in priority order (ordered by ModuleConfig.priority)
- Queue worker now tries each analyser in priority order, falling back
  to the next on failure
- Update SYSTEM_PROMPT to use generic "data" language instead of "email"
- Clean up email_item_names→extracted_item_names variable naming

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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