| name | python-stack |
| description | Python stacks for FastAPI, Streamlit, Gradio, LangChain, scraping (BeautifulSoup/Playwright), typed code and venv/requirements. Use for AI/RAG, data apps, API servers, automation — not for Node.js web MVPs. Trigger: .py, requirements.txt. |
Python — AI, Data, Automation
Do not apply to Node.js web-only projects.
Verify stack matches PROJECT_RULES.md. Record architecture decisions in docs/ai-dev/.
Stack by Project Type
| Type | Stack | Install |
|---|
| AI/RAG/Chatbot | FastAPI + LangChain + ChromaDB | pip install fastapi uvicorn langchain openai chromadb |
| Data analysis | Streamlit + Pandas + Plotly | pip install streamlit pandas plotly |
| API server | FastAPI + SQLAlchemy | pip install fastapi uvicorn sqlalchemy |
| Automation | BeautifulSoup/Playwright | pip install beautifulsoup4 requests playwright |
Initial Setup
python -m venv venv
source venv/bin/activate
venv\Scripts\activate
pip install -r requirements.txt
Always provide the correct activation command for the user's OS.
FastAPI Pattern
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/api/hello")
async def hello():
return {"message": "Hello!"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
Streamlit Pattern
import streamlit as st
import pandas as pd
st.title("Dashboard")
uploaded = st.file_uploader("Upload CSV", type="csv")
if uploaded:
df = pd.read_csv(uploaded)
st.dataframe(df)
st.bar_chart(df)
SQLite + SQLAlchemy
from sqlalchemy import create_engine, Column, String, DateTime
from sqlalchemy.orm import declarative_base, sessionmaker
engine = create_engine("sqlite:///dev.db")
Base = declarative_base()
SessionLocal = sessionmaker(bind=engine)
Environment Variables
from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
Code Conventions
- snake_case (functions, variables), PascalCase (classes)
- Type hints required:
def get_user(user_id: str) -> User:
- f-strings:
f"Hello {name}"
- Pin versions in requirements.txt