Spaces:
Sleeping
title: SmaFit FastApi
emoji: ποΈ
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
Capstone Backend API (FastAPI)
This is the Python-based backend that handles authentication (JWT), PostgreSQL database operations (SQLModel/Alembic), API requests, and the RAG Chatbot powered by ChromaDB & Gemini.
π οΈ Prerequisites
- Python 3.10+
- PostgreSQL database installed and running locally
π Setup Instructions
Create Virtual Environment It is highly recommended to isolate dependencies. Create and activate a virtual environment:
# Windows python -m venv venv venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activateInstall Dependencies Install FastAPI, SQLModel, Alembic, and all required packages:
pip install -r requirements.txtConfigure Environment Variables Sensitive credentials are never pushed to the repository.
- Copy the template file:
cp .env.example .env - Open
.envand fill in your actual PostgreSQL password (DATABASE_URL) and generate aSECRET_KEY. - Note: The backend will not start if the
SECRET_KEYis missing!
- Copy the template file:
Run Database Migrations (Alembic) Apply all migrations to set up the database schema:
alembic upgrade headTo create a new migration after changing
models.py:alembic revision --autogenerate -m "describe_your_change" alembic upgrade headSetup GenAI & Knowledge Base Your
.envfile must contain yourGEMINI_API_KEY. Run the ingestion script to populate the ChromaDB vector store with RAG data:python ingest.pyRun the Server Start the FastAPI development server:
fastapi dev main.py(Or alternatively,
uvicorn main:app --reload)Once running, the API will be available at
http://127.0.0.1:8000. You can view the interactive auto-generated documentation athttp://127.0.0.1:8000/docs.