A Retrieval-Augmented Generation (RAG) system for answering questions from building code documents. This project consists of a React frontend and FastAPI backend that work together to provide intelligent question-answering capabilities for construction and building code documentation.
- Frontend: React 19 with TypeScript, Vite, and Tailwind CSS
- Backend: FastAPI with Python 3.12+ and Pydantic
- API: Auto-generated TypeScript client from OpenAPI specification
- Deployment: Docker containerization with multi-stage builds
- RAG-powered Q&A: Intelligent question answering using building code documents
- Modern UI: Clean, responsive interface built with React and Tailwind CSS
- Type-safe API: Auto-generated TypeScript client ensures type safety
- Real-time Communication: FastAPI backend with CORS support
- Docker Ready: Containerized for easy deployment and scaling
building_code/
βββ frontend/ # React frontend application
β βββ src/
β β βββ components/ui/ # Reusable UI components
β β βββ clients/ # Auto-generated API client
β β βββ App.tsx # Main application component
β βββ package.json
β βββ vite.config.ts
βββ backend/ # FastAPI backend application
β βββ app/
β β βββ api/ # API routes and endpoints
β β βββ schemas/ # Pydantic data models
β β βββ main.py # FastAPI application entry point
β βββ pyproject.toml
β βββ Dockerfile
βββ scripts/ # Utility scripts
β βββ generate_client_types.sh
βββ Dockerfile # Multi-stage production build
- Node.js 24+ and pnpm 10.19.0+
- Python 3.12+
- uv (Python package manager)
- Docker (optional, for containerized deployment)
git clone <repository-url>
cd building_codecd backend
# Install dependencies using uv
uv sync
# Activate virtual environment
source .venv/bin/activate
# Run the development server
python main.pyThe backend will be available at http://localhost:8000
cd frontend
# Install dependencies
pnpm install
# Generate API client types
cd ../scripts
./generate_client_types.sh
cd ../frontend
# Start the development server
pnpm run devThe frontend will be available at http://localhost:5173
Create a .env file in the root directory:
PROJECT_NAME="Building Code RAG System"
FRONTEND_HOST="http://localhost:5173"
BACKEND_CORS_ORIGINS="http://localhost:5173,http://localhost:3000"
ENVIRONMENT="local"# Build and run both services
docker-compose up --build# Build the production image
docker build -t building-code-rag .
# Run the container
docker run -p 80:80 building-code-ragOnce the backend is running, you can access:
- Interactive API Docs:
http://localhost:8000/docs - OpenAPI Schema:
http://localhost:8000/api/v1/openapi.json
The frontend uses auto-generated TypeScript types from the FastAPI OpenAPI specification:
cd scripts
./generate_client_types.shThis script:
- Extracts the OpenAPI schema from the FastAPI backend
- Generates TypeScript types and client code
- Places the generated files in the frontend
Frontend:
pnpm run dev- Start development serverpnpm run build- Build for productionpnpm run preview- Preview production buildpnpm run lint- Run ESLint
Backend:
uv run fastapi dev app/main.py- Start development serveruv run fastapi run app/main.py- Start production server
This system is designed to work with building code documents. The RAG implementation will:
- Ingest building code documents and regulations
- Process and index the content for efficient retrieval
- Answer questions by retrieving relevant code sections
- Generate contextual responses based on the retrieved information
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Vahid Sheigani - v.sheigani@gmail.com
If you encounter any issues or have questions, please:
- Check the Issues page
- Create a new issue with detailed information
- Contact the maintainer directly
Note: This is a development project for RAG-based building code question answering. The system is designed to be extensible and can be adapted for various document types and use cases.