This folder contains the backend API for the ShopAssistant project, built with FastAPI and designed for integration with Semantic Kernel (SK) and Azure services. The backend provides secure authentication, business logic, and AI-powered orchestration for the frontend React app.
-
Set up Python environment
- Install Python 3.9 or newer from python.org.
- (Recommended) Create a virtual environment:
python -m venv .venv .venv\Scripts\Activate.ps1
-
Install dependencies
- In this
backendfolder, run:pip install -r requirements.txt
- In this
-
Set environment variables
- Configure your database, Azure, and secret settings in a
.envfile or via environment variables. Seecore/config.pyfor details.
- Configure your database, Azure, and secret settings in a
-
Create the database tables
- Run the SQL in
db/create_tables.sqlagainst your PostgreSQL database.
- Run the SQL in
-
Start the FastAPI server
- Run:
uvicorn main:app --reload - The API will be available at http://localhost:8000
- Run:
main.py— FastAPI entry point, includes all routers.api/— Route definitions for chat, user, order, cart, offers, etc.agents/— Semantic Kernel agents/skills for cart, order, personalization, and orchestration.db/— SQLAlchemy models, Pydantic schemas, CRUD logic, and SQL scripts.core/— Configuration, security, and logging utilities.services/— Azure OpenAI, Cognitive Search, and Key Vault integration stubs.
- FastAPI: Modern, async Python web framework for building APIs.
- Semantic Kernel (SK): Orchestrates AI skills/agents for intent classification and dynamic routing.
- JWT Authentication: Secure token-based authentication for all API requests.
- SQLAlchemy: ORM for database models and queries.
- Pydantic: Data validation and serialization for API requests/responses.
- Azure Integration: Stubs for OpenAI, Cognitive Search, and Key Vault.
Learn more:
- Use
uvicorn main:app --reloadfor hot-reloading during development. - Test endpoints with http://localhost:8000/docs (FastAPI’s interactive Swagger UI).
- Update
.envor environment variables for secrets and connection strings. - Use the
db/create_tables.sqlscript to initialize or reset your database schema.
Happy coding! If you have questions, check the docs above or ask for help.