Enterprise-grade construction safety management platform powered by a Multi-Agent AI pipeline and real-time data analytics.
Built by HayHunt Solutions LLC
Transform construction safety management from checkbox compliance into intelligent risk prevention. Safety Companion V3 empowers Project Managers and Foremen to generate professional Job Hazard Analysis (JHA) reports in minutes, not hours—combining real-time weather data, OSHA compliance standards, and AI-powered 4-agent risk assessment.
| Agent | Role | Output |
|---|---|---|
| Agent 1 - Validator | Data quality & OSHA gap analysis | Completeness score, critical gaps |
| Agent 2 - Risk Assessor | Hazard identification & ranking | Top 3 hazards with severity/probability |
| Agent 3 - Swiss Cheese | Barrier analysis & incident prediction | Layer vulnerabilities, failure pathways |
| Agent 4 - Synthesizer | Final report generation | GO/NO-GO decision, action plan |
- Real-time weather integration with geolocation
- Location-aware risk assessment
- OSHA compliance tracking with visual indicators
- Weekly JHA submission trends and analytics
- 4-step progressive form (Project → Equipment → Hazards → Crew)
- AI-powered analysis with real-time progress tracking
- Fill Test Data button for quick testing (dev mode)
- Critical risk identification with OSHA citations
- Save to Reports - Explicitly save analyses for later
- Full Markdown Report - Professional narrative format
- Share - Copy link or use Web Share API
- Email - Send formatted report via email
- Download - Export as Markdown or HTML
- Clerk authentication (SSO-ready)
- Role-based access control
- Multi-tenant architecture
- Complete audit trails
frontend/
├── app/
│ ├── page.tsx # Dashboard with weather + stats
│ ├── jha/
│ │ ├── new/ # 4-step JHA wizard
│ │ ├── [id]/ # JHA detail page with agent cards
│ │ └── page.tsx # JHA history list
│ ├── reports/ # Saved reports view
│ └── profile/ # User settings
├── components/
│ ├── analysis/ # Agent cards (Agent1Card, Agent2Card, etc.)
│ ├── dashboard/ # Dashboard widgets
│ ├── jha/ # JHA wizard components
│ └── ui/ # shadcn/ui components
└── hooks/
└── use-api.ts # React Query hooks
Tech Stack:
- Next.js 15 (App Router)
- TypeScript (Strict Mode)
- Tailwind CSS + shadcn/ui
- TanStack Query (React Query)
- Clerk Authentication
backend/
├── app/
│ ├── main.py # FastAPI application
│ ├── api/v1/
│ │ ├── jha.py # JHA endpoints
│ │ ├── reports.py # Reports endpoints
│ │ ├── weather.py # Weather integration
│ │ └── admin.py # Admin endpoints
│ ├── agents/
│ │ ├── orchestrator.py # 4-agent pipeline coordinator
│ │ ├── agent1_validator.py
│ │ ├── agent2_risk_assessor.py
│ │ ├── agent3_swiss_cheese.py
│ │ └── agent4_synthesizer.py
│ ├── services/
│ │ ├── gemini_service.py # Google Gemini 2.0 Flash
│ │ └── jha_service.py # Business logic
│ └── models/
│ └── analysis.py # SQLAlchemy models
└── tests/ # Agent unit tests
Tech Stack:
- FastAPI + Uvicorn
- SQLAlchemy + Alembic
- Neon PostgreSQL (Serverless)
- Grok 4.1 Fast Xai API
- Pydantic v2
- Authentication: Zero-Trust model via Clerk. All API endpoints protected by JWT validation.
- Data Protection:
- SQL Safety: 100% Parameterized queries via SQLAlchemy ORM (No raw SQL).
- Prompt Defense: XML-tagging strategy (
<user_input>) in Agent prompts prevents prompt injection attacks.
- API Hardening: Strict CORS policies (no wildcards) and secure HTTP headers.
- Node.js 20+
- Python 3.11+
- PostgreSQL (or Neon account)
- Grok 4.20
- OpenWeather API key
1. Clone the repository
git clone https://github.com/HeyBattle1/Agent47.git
cd safety-companion-v32. Frontend setup
cd frontend
npm install
cp .env.example .env.local
# Edit .env.local with your keys
npm run dev3. Backend setup
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your database and API keys
uvicorn app.main:app --reload --port 8000Frontend (.env.local):
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_OPENWEATHER_API_KEY=your_keyBackend (.env):
DATABASE_URL=postgresql://user:password@host:5432/safetycompanion
Grok_4_Fast_API
OPENWEATHER_API_KEY=your_openweather_key
ENVIRONMENT=development| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/jha/analyze |
Submit JHA for multi-agent analysis |
| GET | /api/v1/jha/{id} |
Get JHA details with all agent outputs |
| GET | /api/v1/jha/recent |
Get recent JHA analyses |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/reports/save |
Save report to Reports tab |
| GET | /api/v1/reports/saved |
Get explicitly saved reports |
| GET | /api/v1/reports/{id}/download |
Download report (md/html) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/weather/current/{city} |
Get current weather + safety status |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
System health check |
# Frontend
npm run dev # Start dev server (port 3000)
npm run build # Production build
npm run lint # ESLint check
# Backend
uvicorn app.main:app --reload # Start dev server (port 8000)
pytest # Run tests- Go to
/jha/new - Click "🎲 Fill All" button (dev feature)
- Click Next → Next → Next → Analyze
- View results with all 4 agent cards
- Click "Save to Reports" to save
- Go to
/reportsto view saved reports
- 4-Agent AI Pipeline (Validator → Risk Assessor → Swiss Cheese → Synthesizer)
- Next.js 15 frontend with shadcn/ui
- FastAPI backend with Grok 4.1 Fast
- Real-time weather integration with safety thresholds
- 4-step JHA wizard with validation
- Full Report Module with markdown rendering
- Save to Reports functionality
- Share/Email/Download capabilities
- Test data generator for development
- PDF export with branded template
- Email sending via SMTP/SendGrid
- User authentication with Clerk
- Vector database for OSHA regulation search
- Mobile-optimized PWA
- Historical pattern analysis
- Multi-language support (Spanish)
- Voice input for JHA forms
- Predictive analytics
We welcome contributions! See CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file.
Copyright © 2025 HayHunt Solutions LLC
Powered by:
- Xai Grok 4.1 Fast - AI analysis engine
- Neon - Serverless PostgreSQL
- Railway - Cloud deployment
- OpenWeather API - Weather data
Built with:
- Bradlee Burton <Lead Dev
- Claude (Anthropic) - AI pair programming
- The open-source community
⭐ Star this repo if Safety Companion helps keep your crews safe ⭐