How injamul3798/swiftme_mini works
Project Type and Purpose
• Full-stack, AI-driven web application.
• Purpose: Accept a freelancer’s profile, analyze incoming job postings, retrieve relevant profile chunks via RAG, invoke GPT-4o through LangChain LCEL chains, stream a personalized proposal back to the client, and persist history in MySQL.
Main Components
a. Frontend
‑ Static assets served at “/”: index.html, app.js, styles.css.
‑ UI issues POST to /api/v1/profile/setup and /api/v1/proposal/generate (SSE).
b. FastAPI Application (app/main.py)
‑ HTTP server (Uvicorn) receives requests.
‑ Routers/controllers in app/api:
• profile.py → profile setup endpoint
• proposal.py → SSE streaming generator
• history.py → history retrieval
c. Service Layer (app/services)
‑ vector_store.py → wraps ChromaDB operations
‑ profile_matcher.py → RAG retrieval, chunk selection
‑ job_analyzer.py → LangChain chain to parse job description
‑ proposal_generator.py → LangChain LCEL chain for streaming GPT-4o output
d. Data Layer
‑ ChromaDB (persistent vector store) for profile embeddings.
‑ MySQL 8.0+ via async SQLAlchemy (app/database/base.py + alembic migrations) for history.
e. Models & Validation
‑ Pydantic schemas (app/models/schemas.py) for request/response.
‑ SQLAlchemy ORM models (app/models/db_models.py).
f. External Services
‑ OpenAI API (GPT-4o).
g. Infrastructure & Cross-cutting
‑ Configuration: Pydantic settings (app/config.py) reading .env.
‑ Logging: Loguru with structured JSON, correlation IDs (app/logging_config.py).
‑ Dependency Injection: app/dependencies.py.
‑ Migrations: Alembic (alembic/env.py, versions).
‑ Running scripts: run.py / uvicorn CLI.
Relationships & Data Flows
1. User → Frontend UI → POST /api/v1/profile/setup
• Frontend JS calls FastAPI → profile service → embed & store in ChromaDB → record chunk counts → response.
2. User → Frontend UI → POST /api/v1/proposal/generate (Accept: text/event-stream)
• FastAPI → profile_matcher (ChromaDB) for relevant chunks → job_analyzer (LangChain) → proposal_generator (LangChain + OpenAI GPT-4o) streams SSE.
• Intermediary: Streaming SSE events (“status”, “proposal_chunk”, “complete”).
• Persist generation metadata and summary to MySQL history.
3. User → GET /api/v1/proposal/history → FastAPI → query MySQL → return paginated history.
Architectural Patterns & Principles
• Layered architecture: Presentation (frontend, routers) → Business logic (services) → Data access (vector store, ORM) → External APIs.
• RAG pattern: retrieval from ChromaDB followed by generation.
• Async / non-blocking I/O end-to-end (FastAPI async, aiomysql, SSE).
• Single responsibility per service, clear separation of concerns.
• Dependency injection for testability.
Essential Elements
• Clear labels: e.g., “Frontend UI”, “FastAPI Endpoints”, “ProfileMatcher Service”.