AI-powered Progressive Web App for workplace incident reporting with three specialized workflows.
SmartAllies/
โโโ .github/
โ โโโ copilot-instructions.md # Code maintainability guidelines
โโโ backend/ # โ
COMPLETED
โ โโโ src/main/java/ # Spring Boot application
โ โโโ pom.xml # Maven configuration
โ โโโ docker-compose.yml # Ollama setup
โ โโโ start.sh # Quick start script
โ โโโ README.md # Backend documentation
โโโ frontend/ # โณ TODO
โ โโโ (React + TypeScript PWA)
โโโ BACKEND_IMPLEMENTATION.md # Detailed backend docs
โโโ README.md # This file
Build a chatbot that helps employees report three types of incidents:
- Human Incidents - Harassment, discrimination, workplace conflicts
- Facility Incidents - Equipment damage, maintenance issues
- Emergency Situations - Medical emergencies, immediate dangers
- Java 17 with Spring Boot 3.2.0
- Spring AI for LLM integration
- Ollama (local LLM - llama3.2)
- Maven for build management
- React 18 with TypeScript
- Vite for build tooling
- shadcn/ui component library
- PWA configuration
- Voice input support
- Image upload capability
-
Install Prerequisites:
# Java 17+ brew install openjdk@17 -
Configure Remote Ollama: Edit
backend/src/main/resources/application.properties:spring.ai.ollama.base-url=http://your-ollama-host:11434 -
Start Backend:
cd backend ./start.shThis script will:
- Check dependencies
- Build and run Spring Boot app
- Connect to remote Ollama host
-
Test API:
curl http://localhost:8080/api/health
cd frontend
npm install
npm run devRequest:
{
"sessionId": "unique-session-id",
"message": "I want to report harassment",
"imageUrl": "optional-image-url"
}Response:
{
"message": "I understand this is a human incident...",
"incidentType": "HUMAN",
"workflowState": "AWAITING_CLASSIFICATION_CONFIRMATION",
"suggestedActions": ["Yes", "No"],
"resources": ["Employee Assistance Program: https://..."],
"metadata": {
"confidence": 0.95,
"reasoning": "Keywords indicate workplace harassment"
}
}User: "I'm experiencing harassment"
โ
LLM classifies as HUMAN incident
โ
Bot: "I understand this is a human incident. Is this correct?"
โ
User confirms โ Proceed to workflow
Show empathetic resources
โ
Ask: "Would you like to draft a report?"
โ
Collect: Who, What, When, Where
โ
Generate professional summary
โ
Options: Submit | Submit Anonymously | Cancel
Collect: What, Where (floor plan), Picture
โ
Generate maintenance summary
โ
Options: Submit | Submit Anonymously | Cancel
๐จ IMMEDIATE ACTIVATION
โ
Display Swiss emergency numbers
โ
Collect location (MANDATORY)
โ
Alert company Samaritans
โ
Collect: Person name, Condition
โ
No submission - handled in real-time
- Backend architecture
- Spring Boot setup with Spring AI
- Ollama integration
- Three workflow implementations
- LLM prompt templates
- Conversation state management
- REST API endpoints
- CORS configuration
- Error handling
- Logging
- Documentation
- Postman collection
- Quick start script
- Code maintainability guidelines
- Frontend React application
- PWA configuration
- Voice input integration
- Image upload endpoint
- Floor plan component
- Database persistence (PostgreSQL)
- ChromaDB for RAG
- User authentication
- Real Samaritan alert system
- Report analytics dashboard
- Mobile app (React Native)
- Multi-language support
- Email notifications
- Admin panel
Import backend/postman_collection.json for ready-made API calls:
- Health check
- Human incident flow
- Facility incident flow
- Emergency flow
# Human incident
curl -X POST http://localhost:8080/api/chat \
-H "Content-Type: application/json" \
-d '{
"sessionId": "test-123",
"message": "I want to report workplace harassment"
}'
# Emergency
curl -X POST http://localhost:8080/api/chat \
-H "Content-Type: application/json" \
-d '{
"sessionId": "emergency-456",
"message": "Someone collapsed! We need help!"
}'- Backend Details:
BACKEND_IMPLEMENTATION.md - Backend Setup:
backend/README.md - Code Guidelines:
.github/copilot-instructions.md - API Examples:
backend/postman_collection.json
INITIAL โ AWAITING_CLASSIFICATION_CONFIRMATION
โ CLASSIFICATION_CONFIRMED
โ COLLECTING_DETAILS
โ REPORT_READY
โ COMPLETED
(Emergency branch: EMERGENCY_ACTIVE)
- Versioned prompts for each workflow step
- Structured JSON outputs for parsing
- Context-aware responses
- Field extraction from user messages
- In-memory conversation contexts
- Session-based state tracking
- Automatic field collection
- Context persistence across messages
- CORS configured for frontend origins
- Input validation on all endpoints
- Structured logging (no sensitive data)
- Anonymous submission support
- Sanitization ready for user inputs
Swiss emergency numbers pre-configured:
- Police: 117
- Ambulance: 144
- Fire: 118
- Samaritans: 143
โจ Smart Classification - AI determines incident type automatically
๐ค Empathetic Responses - Tone adapts to incident severity
๐ Guided Workflows - Step-by-step data collection
๐จ Emergency Protocols - Immediate activation for urgent cases
๐ Anonymous Reporting - Optional identity protection
๐ Resource Integration - Context-aware help links
๐ Auto-Summarization - Professional report generation
All developers should:
- Read
.github/copilot-instructions.mdfor coding standards - Follow single-responsibility principles
- Use explicit types (no
anyin TypeScript) - Write self-documenting code
- Include JSDoc/JavaDoc for complex logic
- Test before committing
Backend Issues:
- Check remote Ollama host is accessible
- Test connection:
curl http://your-ollama-host:11434/api/tags - Verify base URL in application.properties
- Review logs:
tail -f logs/application.log
Common Issues:
- Port 8080 in use: Change
server.portin application.properties - CORS errors: Add frontend URL to
cors.allowed-origins - Ollama connection: Check
spring.ai.ollama.base-url
Proprietary - SmartAllies ยฉ 2025
Next Step: Run the backend with cd backend && ./start.sh and test the API! ๐