AI-powered construction compliance with Elastic hybrid search and Vertex AI grounding.
BuildSafe Copilot is a comprehensive construction compliance assistant that leverages Google Cloud's Vertex AI and Elastic's hybrid search capabilities to provide accurate, grounded answers about construction safety regulations and generate compliance documents.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Next.js │ │ FastAPI │ │ Elastic │
│ Frontend │◄──►│ Backend │◄──►│ Cloud │
│ (Chat UI) │ │ (Cloud Run) │ │ (Serverless) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Google Cloud │
│ - Vertex AI │
│ - Gemini 1.5 │
│ - Embeddings │
│ - GCS Bucket │
└─────────────────┘
- Next.js 14 with App Router
- Tailwind CSS for styling
- shadcn/ui for components
- TypeScript for type safety
- FastAPI with Python 3.11
- Google Cloud Run for hosting
- Vertex AI for LLM and embeddings
- Elastic Cloud for hybrid search
- Elastic Cloud Serverless for document storage and search
- Google Cloud Storage for generated PDFs and ZIP files
- Hybrid Search: Combines BM25 text search with vector similarity search
- Grounded AI: All answers are backed by cited sources from compliance documents
- Document Generation: Creates Job Safety Analysis (JSA) PDFs
- Audit Packs: Generates ZIP files with relevant compliance evidence
- Compliance Documents (
cc_docs): Safety regulations, standards, and procedures - Training Materials (
cc_training): Educational content and certification requirements - Incident Reports (
cc_incidents): Safety incidents and corrective actions
- Node.js 18+ and pnpm
- Python 3.11+
- Google Cloud Project with Vertex AI enabled
- Elastic Cloud account
git clone <repository-url>
cd BuildSafeCopilot
pnpm install
cd app/backend && pip install -r requirements.txtCopy and configure environment files:
cp app/backend/.env.example app/backend/.env
cp app/frontend/.env.example app/frontend/.env.local# Create index template and indices
python scripts/elastic/setup_indices.py
# Ingest seed data
python scripts/embed_and_ingest.py --index cc_docs --file scripts/seed/seed_cc_docs.jsonl
python scripts/embed_and_ingest.py --index cc_training --file scripts/seed/seed_cc_training.jsonl
python scripts/embed_and_ingest.py --index cc_incidents --file scripts/seed/seed_cc_incidents.jsonl# Backend (Terminal 1)
cd app/backend
uvicorn main:app --host 0.0.0.0 --port 8080
# Frontend (Terminal 2)
cd app/frontend
pnpm devVisit http://localhost:3000 to use the application.
# Deploy backend
cd app/backend
gcloud run deploy buildsafe-backend --source . --platform managed --region us-central1
# Deploy frontend
cd app/frontend
gcloud run deploy buildsafe-frontend --source . --platform managed --region us-central1cd infra/terraform
terraform init
terraform plan
terraform applyPOST /search- Raw hybrid search resultsPOST /ask- AI-powered compliance answers with citations
POST /action/jsa- Generate Job Safety Analysis PDFPOST /action/audit-pack- Create compliance audit pack ZIP
{
"id": "unique-document-id",
"title": "Document Title",
"source": "OSHA|CSA|Provincial",
"doctype": "regulation|standard|procedure",
"trade": "electrical|plumbing|general",
"jurisdiction": "SK|ON|NS|Federal",
"language": "en|fr",
"published_at": "2024-01-01T00:00:00Z",
"url": "https://source-url.com",
"content": "Full document text...",
"embedding": [0.1, 0.2, ...] // 768-dimensional vector
}- License: Apache 2.0
- Data: All seed data is synthetic and created for demonstration purposes
- No Copyrighted Content: No third-party copyrighted materials are included
- Hackathon Compliance: Uses only Google Cloud AI services and Elastic Cloud
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For questions or issues, please open a GitHub issue or contact the development team.
Built for AI Accelerate Hackathon 2025