From 5e072485947443edbfaa4798b69b655490529dac Mon Sep 17 00:00:00 2001 From: Aherobo Ovie Victor Date: Tue, 22 Jul 2025 09:46:32 +0100 Subject: [PATCH] code reviewed --- backend/{ => data}/data_utils.py | 0 backend/{ => data}/front_tag_embeddings.index | Bin .../{ => data}/tag_identification_cache.json | 0 backend/{app.py => main.py} | 14 +++++++------- backend/{ => models}/llm_tag_similarity.py | 0 backend/{ => models}/tag_identification.py | 0 backend/{ => models}/tag_match.py | 0 backend/{ => services}/image_similarity.py | 0 backend/{ => services}/image_utils.py | 0 backend/{ => services}/result_aggregation.py | 0 checklist.md | 17 +++++++++++++++++ 11 files changed, 24 insertions(+), 7 deletions(-) rename backend/{ => data}/data_utils.py (100%) rename backend/{ => data}/front_tag_embeddings.index (100%) rename backend/{ => data}/tag_identification_cache.json (100%) rename backend/{app.py => main.py} (96%) rename backend/{ => models}/llm_tag_similarity.py (100%) rename backend/{ => models}/tag_identification.py (100%) rename backend/{ => models}/tag_match.py (100%) rename backend/{ => services}/image_similarity.py (100%) rename backend/{ => services}/image_utils.py (100%) rename backend/{ => services}/result_aggregation.py (100%) create mode 100644 checklist.md diff --git a/backend/data_utils.py b/backend/data/data_utils.py similarity index 100% rename from backend/data_utils.py rename to backend/data/data_utils.py diff --git a/backend/front_tag_embeddings.index b/backend/data/front_tag_embeddings.index similarity index 100% rename from backend/front_tag_embeddings.index rename to backend/data/front_tag_embeddings.index diff --git a/backend/tag_identification_cache.json b/backend/data/tag_identification_cache.json similarity index 100% rename from backend/tag_identification_cache.json rename to backend/data/tag_identification_cache.json diff --git a/backend/app.py b/backend/main.py similarity index 96% rename from backend/app.py rename to backend/main.py index 82a0516..fc8b4f1 100644 --- a/backend/app.py +++ b/backend/main.py @@ -14,13 +14,13 @@ except Exception as e: print("Could not set torch num threads:", e) import json import numpy as np -from image_utils import download_image -from tag_identification import TagIdentification -from tag_match import get_best_match -from data_utils import load_tag_guides, load_expert_data, load_community_data -from image_similarity import load_index, search_similar_images, transform_image -from result_aggregation import aggregate_results -from llm_tag_similarity import LLMTagSimilarity +from services.image_utils import download_image +from models.tag_identification import TagIdentification +from models.tag_match import get_best_match +from data.data_utils import load_tag_guides, load_expert_data, load_community_data +from services.image_similarity import load_index, search_similar_images, transform_image +from services.result_aggregation import aggregate_results +from models.llm_tag_similarity import LLMTagSimilarity from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.metrics.pairwise import cosine_similarity diff --git a/backend/llm_tag_similarity.py b/backend/models/llm_tag_similarity.py similarity index 100% rename from backend/llm_tag_similarity.py rename to backend/models/llm_tag_similarity.py diff --git a/backend/tag_identification.py b/backend/models/tag_identification.py similarity index 100% rename from backend/tag_identification.py rename to backend/models/tag_identification.py diff --git a/backend/tag_match.py b/backend/models/tag_match.py similarity index 100% rename from backend/tag_match.py rename to backend/models/tag_match.py diff --git a/backend/image_similarity.py b/backend/services/image_similarity.py similarity index 100% rename from backend/image_similarity.py rename to backend/services/image_similarity.py diff --git a/backend/image_utils.py b/backend/services/image_utils.py similarity index 100% rename from backend/image_utils.py rename to backend/services/image_utils.py diff --git a/backend/result_aggregation.py b/backend/services/result_aggregation.py similarity index 100% rename from backend/result_aggregation.py rename to backend/services/result_aggregation.py diff --git a/checklist.md b/checklist.md new file mode 100644 index 0000000..f561813 --- /dev/null +++ b/checklist.md @@ -0,0 +1,17 @@ +# Refactoring Checklist: Backend Folder Structure + +## Goal +Restructure the backend code into a more modular, maintainable format. + +## Steps + +- [ ] 1. Create new folders inside `backend/`: `api/`, `data/`, `models/`, `services/`, `utils/` +- [ ] 2. Move `app.py` to `main.py` in `backend/` +- [ ] 3. Move `data_utils.py` to `backend/data/data_utils.py` +- [ ] 4. Move `image_similarity.py` and `image_utils.py` to `backend/services/` +- [ ] 5. Move `llm_tag_similarity.py`, `tag_identification.py`, and `tag_match.py` to `backend/models/` +- [ ] 6. Move `result_aggregation.py` to `backend/services/` +- [ ] 7. Move `front_tag_embeddings.index` and `tag_identification_cache.json` to `backend/data/` +- [ ] 8. Update all import statements to reflect the new structure +- [ ] 9. Test the application to ensure everything works +- [ ] 10. Update documentation if needed \ No newline at end of file