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:
dbastrikin
2026-03-15 18:45:21 +02:00
parent 61feb91bba
commit 0ce111fa08
14 changed files with 552 additions and 423 deletions

View File

@@ -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}
}