How ahmetcolak251113/yzta_bootcamp_team35 works
1. Repository purpose
- This is a FastAPI backend for the “Akıllı Dolap” app, focused on two AI-backed capabilities: LLM chatbot and outfit recommendation.
- The system is designed around three main concerns: API orchestration, persistent wardrobe storage, and Google Gemini integration.
2. Top-level runtime boundary
- The running service is started with Uvicorn against main:app.
- From the outside, there are two main clients:
- a browser-based test panel at /
- API consumers via FastAPI endpoints and /docs Swagger UI
3. main.py as the application entry and orchestration layer
- main.py is the central integration point.
- It exposes the REST endpoints for:
- wardrobe CRUD
- category management
- chat
- outfit recommendation
- It sits between the HTTP layer, the database module, and the Gemini client, so the architecture is a classic controller/orchestrator pattern.
4. database.py as the persistence boundary
- database.py owns all SQLite access.
- The repo is intentionally structured so the storage backend can later move to PostgreSQL by changing the connection layer in this file, without rewriting the API layer.
- This means main.py should be diagrammed as depending on a storage abstraction, not directly on SQL details.
5. Domain data model in the database
- The backend stores two key domain tables:
- kategoriler: editable option lists for clothing attributes such as fabric, cut, collar type, sleeve type, pattern, season, style tag, and usage frequency
- kiyafetler: the actual wardrobe inventory
- kategoriler is important architecturally because these values are not hardcoded enums; they are managed through API endpoints and persist in the database.
6. Wardrobe management flow
- CRUD endpoints on kiyafetler handle add, list, detail, update, and delete operations.
- Each clothing item is scoped by user_id, so the wardrobe is effectively multi-user even though the database is local SQLite.
- Clothing records include both required fields (tur, renk) and richer optional metadata like marka, beden, kumas, kesim, yaka_tipi, kol_tipi, desen, mevsim, stil_etiketi, kullanim_sikligi, kombin_notu, temiz, and foto_url.
7. gemini_client.py as the external AI boundary
- This module isolates all interaction with Google Gemini API.
- It likely contains the system prompts and request/response handling for two separate AI behaviors:
- chatbot conversation
- outfit generation
- Architecturally, this keeps LLM-specific logic out of the API and database layers.
8. Chatbot data flow
- The /chat endpoint accepts a user message and a user_id, then delegates to Gemini through gemini_client.py.
- The chatbot is designed to collect missing context through follow-up questions until it can mark the situation as ready (hazir_mi).
- This is a conversational workflow, not just a single prompt/response call.
9. Outfit recommendation data flow
- The /kombin/oner endpoint combines:
- user wardrobe data from SQLite
- event context such as occasion, weather, and style preference
- Gemini-generated reasoning/recommendation
- The response includes a secilen_kiyafetler list with clothing IDs and foto_url values, which is a deliberate downstream integration boundary for AR or social-media modules.
10. index.html as a lightweight browser test surface
- index.html is not a separate application tier; it is a simple UI for testing the backend from the browser.
- It exposes four functional areas: wardrobe, categories, chatbot, and outfit recommendation.
- In the architecture diagram, this should be shown as a client-side test/ops interface talking to the FastAPI backend.
11. Configuration and environment
- Secrets and model selection are externalized through environment variables, with .env.example documenting the required settings.
- The backend depends on a Gemini API key and a model name, so model availability is a real runtime dependency.
- The README explicitly warns that older model names may fail, which makes Gemini model selection part of operational configuration.
12. Important system boundaries to show in a diagram
- Browser/UI layer: index.html and Swagger /docs
- API layer: main.py
- Persistence layer: database.py + SQLite
- AI integration layer: gemini_client.py + Google Gemini
- Shared domain boundary: editable clothing categories and user-scoped wardrobe records
13. What is intentionally not in the repo
- There is no separate frontend SPA, message queue, background worker, or auth service.
- The architecture is a relatively compact monolith: one FastAPI process coordinating local persistence and remote AI calls.
Main entry points: main.py App Entry · database.py Storage Layer · gemini_client.py Gemini Client · env.example Env Config
Components 15
Client/UI
Browser-facing test surfaces for exercising the backend.
- Test Panel · Lightweight browser surface for wardrobe, categories, chat, and outfit recommendation.
index.html - API Docs · FastAPI interactive docs surface for exploring endpoints.
FastAPI Backend
Single-process API orchestration layer.
- App Entry · Central orchestration layer exposed through Uvicorn as the main HTTP service.
main.py - Wardrobe API · Add, list, detail, update, and delete clothing items scoped by user.
- Category API · Manages editable clothing attribute lists persisted in the database.
- Chat API · Accepts user messages and coordinates Gemini-powered chatbot flow.
- Recommend API · Combines wardrobe data and context to generate outfit recommendations.
- Uvicorn · Process host that launches the FastAPI app.
Persistence
Local database boundary and domain tables.
- Storage Layer · Owns database connections and isolates the persistence backend from the API layer.
database.py - Categories · Editable option lists for fabric, cut, collar, sleeve, pattern, season, style, and usage frequency.
- Wardrobe · User-scoped clothing inventory with core fields and rich metadata.
- SQLite Store · Current persistence engine backing wardrobe and category data.
AI Integration
Gemini-backed conversational and recommendation capabilities.
- Gemini Client · Encapsulates all Google Gemini request, response, and prompt handling.
gemini_client.py - Gemini API · Remote Google Gemini service used for chat and outfit reasoning.
Config
Externalized runtime settings and secrets.
- Env Config · Documents required environment variables such as API key and model name.
env.example
Connections 18
- Uvicorn → App Entry: serves · Uvicorn starts the application entrypoint.
- Test Panel → App Entry: calls · Browser test panel sends requests to the backend API.
- API Docs → App Entry: explores · Swagger UI is generated from the FastAPI app.
- App Entry → Wardrobe API: routes · Main application exposes wardrobe CRUD endpoints.
- App Entry → Category API: routes · Main application exposes category management endpoints.
- App Entry → Chat API: routes · Main application exposes the chatbot endpoint.
- App Entry → Recommend API: routes · Main application exposes outfit recommendation endpoints.
- Wardrobe API → Storage Layer: reads/writes · Wardrobe operations persist through the storage boundary.
- Category API → Storage Layer: reads/writes · Category values are loaded and updated via the storage layer.
- Chat API → Gemini Client: delegates · Chat flow delegates conversational reasoning to Gemini adapter.
- Recommend API → Storage Layer: loads · Recommendation flow reads the user's wardrobe from storage.
- Recommend API → Gemini Client: delegates · Recommendation flow uses Gemini for ranking and explanation.
- Storage Layer → SQLite Store: uses · Storage layer currently persists to local SQLite.
- Storage Layer → Categories: owns · Database module manages editable clothing-category records.
- Storage Layer → Wardrobe: owns · Database module manages user-scoped wardrobe records.
- Gemini Client → Gemini API: calls · Adapter sends prompts and receives model responses.
- Env Config → Gemini Client: configures · Environment variables provide API key and model selection.
- Env Config → App Entry: configures · Runtime settings are externalized from the application code.