Codebase cleanup: deduplicate, remove dead code, fix structure#97
Merged
Conversation
Language endpoints: - Extract shared extract_text_from_file() and chat handler logic into language_chat.py; reduce 5 near-identical files (~500 lines) to thin one-liners via make_language_blueprint() factory - Apply same pattern to gtm.py financeGPT/chatbot_endpoints.py: - Remove 18 pass-through wrapper functions (e.g. add_message_to_db, retrieve_chats_from_db) and replace with direct re-export aliases - Remove redundant service function re-assignments that were never used within the module backend/app.py: - Remove demo-only endpoints: /process-message-pdf-demo, /ingest-pdf-demo, /download-chat-history-demo and their global state - Remove commented-out /reset-chat-demo block - Remove /temp-test development endpoint - Remove stale TODO comment Package structure: - Add missing __init__.py to 13 backend packages so they are importable as proper Python packages Docker: - backend/Dockerfile: combine two apt-get RUN layers into one, remove redundant separate tokenizers/anthropic pip install (already covered by requirements.txt), upgrade to python:3.12-slim - frontend/Dockerfile: remove npm install --force (no longer needed), upgrade to node:22-alpine Redux: - Remove unused lastFetchTime state and selectLastFetchTime selector from ChatSlice Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deletes test_demo_routes_work, test_demo_download_route_error_branch, and the /temp-test assertion from test_add_model_key_and_temp_test (renamed to test_add_model_key) since those endpoints were removed in the codebase cleanup commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Language endpoints (~500 lines → thin wrappers)
extract_text_from_file()and all chat handler logic into a singlelanguage_chat.pywith amake_language_blueprint()factoryarabic,spanish,chinese,japanese,korean,gtm) is now a one-liner that passes its model ID, system prompt, and language-specific strings to the factoryfinanceGPT/chatbot_endpoints.pyadd_message_to_db,retrieve_chats_from_db) that did nothing but delegate todatabase.dbDead code removed from
app.py/process-message-pdf-demo,/ingest-pdf-demo,/download-chat-history-demoendpoints and their global state/reset-chat-demoblock/temp-testdevelopment endpointTODO: COMMENT OUT WHEN DEPLOY TO PRODcommentPackage structure
__init__.pyto 13 backend packages so they are importable as proper Python packagesDocker
backend/Dockerfile: combined two separateapt-getRUN layers into one (fewer image layers, faster builds), removed redundant separatepip install tokenizers anthropicstep, upgraded topython:3.12-slimfrontend/Dockerfile: removednpm install --force(no longer needed), upgraded tonode:22-alpineRedux
lastFetchTimestate andselectLastFetchTimeselector fromChatSliceTest plan
docker compose up --buildsucceeds with new Dockerfiles/api/chat/arabic,/api/chat/spanish, etc.)🤖 Generated with Claude Code