refactor: migrate DI to Wire, replace startup registries with on-demand DB queries
- Add google/wire; generate wire_gen.go from wire.go injector - Move all constructor wiring out of main.go into providers.go / wire.go - Export recognition.IngredientRepository (was unexported, blocked Wire binding) - Delete units/cuisine/tag registry.go files (global state + unused NameFor helpers) - Replace List handlers with NewListHandler(pool) using COALESCE SQL queries - Remove units/cuisine/tag LoadFromDB from server startup; locale.LoadFromDB kept (locale.Supported is used by language middleware on every request) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/food-ai/backend/internal/middleware"
|
||||
)
|
||||
|
||||
// ingredientRepo is the subset of ingredient.Repository used by this handler.
|
||||
type ingredientRepo interface {
|
||||
// IngredientRepository is the subset of ingredient.Repository used by this handler.
|
||||
type IngredientRepository interface {
|
||||
FuzzyMatch(ctx context.Context, name string) (*ingredient.IngredientMapping, error)
|
||||
Upsert(ctx context.Context, m *ingredient.IngredientMapping) (*ingredient.IngredientMapping, error)
|
||||
UpsertTranslation(ctx context.Context, id, lang, name string) error
|
||||
@@ -24,11 +24,11 @@ type ingredientRepo interface {
|
||||
// Handler handles POST /ai/* recognition endpoints.
|
||||
type Handler struct {
|
||||
gemini *gemini.Client
|
||||
ingredientRepo ingredientRepo
|
||||
ingredientRepo IngredientRepository
|
||||
}
|
||||
|
||||
// NewHandler creates a new Handler.
|
||||
func NewHandler(geminiClient *gemini.Client, repo ingredientRepo) *Handler {
|
||||
func NewHandler(geminiClient *gemini.Client, repo IngredientRepository) *Handler {
|
||||
return &Handler{gemini: geminiClient, ingredientRepo: repo}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user