A Retrieval-Augmented Generation (RAG) sample project using Azure OpenAI, FastAPI, and React. This repository demonstrates a workflow for uploading documents, converting them into embeddings, storing them in a vector store (ChromaDB), and answering user questions via a RAG pipeline.
- Backend: FastAPI (Python) — exposes endpoints for health, upload, and query
- RAG logic:
src/rag/implements document processing, vector store integration, and the RAG chain - Vector store: ChromaDB (local persistence under
data/chroma_db/) - Frontend: React app under
frontend/(dev server onhttp://localhost:3000)
rag-azure-mlops/
├── config/
│ └── settings.py # Configuration (pydantic settings)
├── data/
│ └── chroma_db/ # ChromaDB persistence (ignored in git)
├── frontend/
│ ├── package.json
│ └── src/
│ ├── App.js # Main React component
│ └── services/api.js # Frontend API client
├── notebooks/
│ └── test.ipynb
├── requirements.txt # Python dependencies
├── src/
│ ├── api/
│ │ └── main.py # FastAPI entrypoint
│ └── rag/
│ ├── document_processor.py
│ ├── rag_chain.py
│ └── vector_store.py
├── tests/
│ └── test_rag.py
├── .env # Local environment variables (not committed)
├── .gitignore
└── README.md
The following diagram shows a minimal Azure-based deployment for this RAG MLOps sample. It uses Azure Container Apps (or Container Instances) for the application layer, an Azure Storage Account for documents and vector persistence (ChromaDB), Azure OpenAI for LLM inference, and Azure monitoring tooling for observability.
If you want to regenerate the diagram locally the repository includes a small diagrams script at docs/architechture.py which uses the diagrams Python package. The script outputs docs/architecture_minimal.png when run. Example:
# from the repo root
python docs\architechture.py
# or run the diagrams CLI if you have it installedNotes:
- The diagram in
docs/architechture.pngis a minimal, illustrative architecture — adapt for production (VNet, private endpoints, managed identity, key vault access policies, storage lifecycle rules). - Recommended production changes: use managed identities, restrict Key Vault access, store vector DB in a managed store or dedicated service, and enable private networking between components.
- Python 3.8+
- Node.js 14+
- An Azure OpenAI resource (API key, endpoint, deployment names)
- Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Create a
.envfile in the repo root (example):
# Azure OpenAI
AZURE_OPENAI_API_KEY=your_azure_openai_api_key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-ada-002
AZURE_OPENAI_API_VERSION=2024-02-15-preview
# Vector DB
CHROMA_PERSIST_DIRECTORY=./data/chroma_db
# App
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
TOP_K_RESULTS=5
LOG_LEVEL=INFO
# CORS - comma separated
CORS_ALLOW_ORIGINS=http://localhost:3000,http://127.0.0.1:3000NOTE: If your app uses
graphvizfor rendering diagrams, install the Graphviz system binaries and add thedotexecutable to your PATH on Windows.
Start backend:
.venv\Scripts\activate
uvicorn src.api.main:app --reloadStart frontend:
cd frontend
npm install
npm startFrontend: http://localhost:3000
Backend: http://localhost:8000 (OpenAPI docs at /docs)
- CORS: The backend reads
CORS_ALLOW_ORIGINSfrom.envand converts comma-separated values to a list. For production, restrict origins. - LangChain/Chroma: You may see deprecation warnings for
langchain.Chroma. Consider migrating tolangchain-chromaif required by your runtime. - Graphviz: If you see
ExecutableNotFound: failed to execute WindowsPath('dot'), install Graphviz and add thebinfolder to PATH.
Run tests:
.venv\Scripts\activate
pytest -qOpen issues or PRs. Add tests for new features and keep changes small.
MIT
If you want this README shortened, add badges, or include CI examples (GitHub Actions), tell me which parts to expand or remove and I will update it.
