Skip to content

Commit

Permalink
refactor: reorder imports for improved readability
Browse files Browse the repository at this point in the history
  • Loading branch information
areebahmeddd committed Feb 22, 2025
1 parent dcc12d0 commit 1815ffa
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions server/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from flask import Flask, jsonify
from config import FLASK_KEY
from auth import auth_blueprint
from search import search_blueprint
from gemini import ai_blueprint
from user import user_blueprint
from chat import chat_blueprint
from config import FLASK_KEY
from flask import Flask, jsonify
from flask_cors import CORS
from middleware import auth_handler, error_handler

Expand Down
4 changes: 2 additions & 2 deletions server/auth.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from flask import Blueprint, Response, jsonify, request, session
from firebase_admin import auth
from database import (
register_user_profile,
remove_user_profile,
runtime_error,
user_reference,
validate_user_profile,
)
from firebase_admin import auth
from flask import Blueprint, Response, jsonify, request, session

# Blueprint for the authentication routes
auth_blueprint = Blueprint("auth", __name__)
Expand Down
2 changes: 1 addition & 1 deletion server/chat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests
from database import runtime_error, user_reference
from flask import Blueprint, Response, jsonify, request
from database import runtime_error, user_reference

# Blueprint for the chat routes
chat_blueprint = Blueprint("chat", __name__)
Expand Down
2 changes: 1 addition & 1 deletion server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import firebase_admin
from firebase_admin import credentials, firestore
from werkzeug.security import check_password_hash, generate_password_hash
from fuzzywuzzy import fuzz
from models import AccountInfo, ScanHistory, SearchHistory
from werkzeug.security import check_password_hash, generate_password_hash

# Initialize the Firebase Admin SDK with the service account key
credential = credentials.Certificate("firebase-config.json")
Expand Down
9 changes: 4 additions & 5 deletions server/gemini.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os

import google.generativeai as genai
import requests
import google.generativeai as genai
from google.generativeai import GenerativeModel
from config import GEMINI_KEY
from database import runtime_error
from flask import Blueprint, Response, jsonify, request
from google.generativeai import GenerativeModel
from werkzeug.utils import secure_filename
from models import ChatHistory
from utils import chat_history, health_profile
from werkzeug.utils import secure_filename
from database import runtime_error

# Blueprint for the ai routes
ai_blueprint = Blueprint("ai", __name__)
Expand Down
2 changes: 1 addition & 1 deletion server/middleware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from database import runtime_error, validate_user_profile
from flask import Response, jsonify, request
from database import runtime_error, validate_user_profile


def auth_handler() -> Response:
Expand Down
1 change: 0 additions & 1 deletion server/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime

from config import DEFAULT_NAME, DEFAULT_PHOTO


Expand Down
6 changes: 3 additions & 3 deletions server/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import sys
from datetime import datetime

from database import database_history, database_search, product_not_found, runtime_error
from flask import Blueprint, Response, jsonify, request
from gemini import lumi, swapr
from mapping import additive_name, grade_color, nova_name, score_assessment
from openfoodfacts import API, APIVersion, Country, Environment, Flavor
from utils import (
filter_additive,
Expand All @@ -14,6 +11,9 @@
filter_ingredient,
filter_nutriment,
)
from mapping import additive_name, grade_color, nova_name, score_assessment
from gemini import lumi, swapr
from database import database_history, database_search, product_not_found, runtime_error

# Blueprint for the search routes
search_blueprint = Blueprint("search", __name__)
Expand Down
6 changes: 3 additions & 3 deletions server/user.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from flask import Blueprint, Response, jsonify, request
from firebase_admin import auth, firestore
from models import FavoriteProduct, HealthProfile
from database import (
flagged_reference,
runtime_error,
save_health_profile,
user_reference,
)
from firebase_admin import auth, firestore
from flask import Blueprint, Response, jsonify, request
from models import FavoriteProduct, HealthProfile

# Blueprint for the user routes
user_blueprint = Blueprint("user", __name__)
Expand Down
2 changes: 1 addition & 1 deletion server/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import re

from database import user_reference
from mapping import food_icon
from database import user_reference

# with open('metadata/nutrient_limits.json') as file:
# nutrient_limits = json.load(file)
Expand Down

0 comments on commit 1815ffa

Please sign in to comment.