How ninja1420/trendify_agent works
Project Type & Purpose
• This is a full-stack, AI-powered fashion assistant.
• Frontend: Interactive web UI built with Streamlit.
• Backend: REST API built on FastAPI.
• Core functionality: Accepts user queries, forwards them to an AI agent, and returns personalized fashion advice.
• External services: Groq, OpenAI for model inference; Tavily for web search.
Top-Level Components
a. Client / User Interface
• Browser running the Streamlit App (streamlit_App.py).
• Streams user inputs (model choice, query, toggles) to backend.
b. Web Server / API Layer
• FastAPI application (backend.py) exposing /chat endpoint.
• Listens on a port (e.g., 8000) for JSON requests.
c. Business Logic / AI Agent
• ai_agent.py: orchestrates prompt construction, model calls.
• constants.py: holds system prompts, default settings.
d. External AI & Search Services
• Groq API
• OpenAI API
• Tavily Search API
e. Configuration & Environment
• .env file with API keys loaded at runtime.
• requirements.txt drives dependency installation.
Interactions & Data Flows
1. User opens Streamlit UI on http://localhost:8501.
2. User submits a fashion query + settings.
3. Streamlit App issues an HTTP POST to FastAPI /chat.
4. FastAPI handler validates payload, calls ai_agent.
5. AI agent builds prompt (using constants) and:
a. Optionally calls Tavily API for real-time web search.
b. Routes the prompt to the chosen model via Groq or OpenAI SDK.
6. AI model returns generated advice.
7. Backend formats the response JSON and returns to Streamlit.
8. Streamlit displays the advice to the user.
Architectural Patterns & Key Principles
• Clear separation of concerns:
• UI (Streamlit)
• API (FastAPI)
• Core logic (AI agent module)
• Environment-based configuration for secrets.
• Stateless API: each request is handled independently.