Skip to content

JonathanLink/SmartAllies

Repository files navigation

SmartAllies Incident Reporting System

AI-powered Progressive Web App for workplace incident reporting with three specialized workflows.

๐Ÿ“ Project Structure

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

๐ŸŽฏ Project Goals

Build a chatbot that helps employees report three types of incidents:

  1. Human Incidents - Harassment, discrimination, workplace conflicts
  2. Facility Incidents - Equipment damage, maintenance issues
  3. Emergency Situations - Medical emergencies, immediate dangers

๐Ÿ› ๏ธ Tech Stack

Backend (โœ… Completed)

  • Java 17 with Spring Boot 3.2.0
  • Spring AI for LLM integration
  • Ollama (local LLM - llama3.2)
  • Maven for build management

Frontend (โณ Planned)

  • React 18 with TypeScript
  • Vite for build tooling
  • shadcn/ui component library
  • PWA configuration
  • Voice input support
  • Image upload capability

๐Ÿš€ Quick Start

Backend Setup

  1. Install Prerequisites:

    # Java 17+
    brew install openjdk@17
  2. Configure Remote Ollama: Edit backend/src/main/resources/application.properties:

    spring.ai.ollama.base-url=http://your-ollama-host:11434
  3. Start Backend:

    cd backend
    ./start.sh

    This script will:

    • Check dependencies
    • Build and run Spring Boot app
    • Connect to remote Ollama host
  4. Test API:

    curl http://localhost:8080/api/health

Frontend Setup (Coming Soon)

cd frontend
npm install
npm run dev

๐Ÿ“ก API Overview

Main Endpoint: POST /api/chat

Request:

{
  "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"
  }
}

๐Ÿ”„ Workflow Overview

1. Initial Classification

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

2. Human Incident 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

3. Facility Incident Workflow

Collect: What, Where (floor plan), Picture
  โ†“
Generate maintenance summary
  โ†“
Options: Submit | Submit Anonymously | Cancel

4. Emergency Workflow

๐Ÿšจ IMMEDIATE ACTIVATION
  โ†“
Display Swiss emergency numbers
  โ†“
Collect location (MANDATORY)
  โ†“
Alert company Samaritans
  โ†“
Collect: Person name, Condition
  โ†“
No submission - handled in real-time

๐Ÿ“Š Current Status

โœ… Completed

  • 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

โณ In Progress

  • Frontend React application
  • PWA configuration
  • Voice input integration
  • Image upload endpoint
  • Floor plan component

๐Ÿ”ฎ Future Enhancements

  • 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

๐Ÿงช Testing

Test with Postman

Import backend/postman_collection.json for ready-made API calls:

  • Health check
  • Human incident flow
  • Facility incident flow
  • Emergency flow

Test with cURL

# 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!"
  }'

๐Ÿ“– Documentation

  • Backend Details: BACKEND_IMPLEMENTATION.md
  • Backend Setup: backend/README.md
  • Code Guidelines: .github/copilot-instructions.md
  • API Examples: backend/postman_collection.json

๐Ÿ—๏ธ Architecture Highlights

Conversation State Machine

INITIAL โ†’ AWAITING_CLASSIFICATION_CONFIRMATION 
       โ†’ CLASSIFICATION_CONFIRMED 
       โ†’ COLLECTING_DETAILS 
       โ†’ REPORT_READY 
       โ†’ COMPLETED

(Emergency branch: EMERGENCY_ACTIVE)

LLM Prompt Strategy

  • Versioned prompts for each workflow step
  • Structured JSON outputs for parsing
  • Context-aware responses
  • Field extraction from user messages

Session Management

  • In-memory conversation contexts
  • Session-based state tracking
  • Automatic field collection
  • Context persistence across messages

๐Ÿ” Security Considerations

  • CORS configured for frontend origins
  • Input validation on all endpoints
  • Structured logging (no sensitive data)
  • Anonymous submission support
  • Sanitization ready for user inputs

๐ŸŒ Localization

Swiss emergency numbers pre-configured:

  • Police: 117
  • Ambulance: 144
  • Fire: 118
  • Samaritans: 143

๐Ÿ’ก Key Features

โœจ 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

๐Ÿ‘ฅ Development Team Guidelines

All developers should:

  1. Read .github/copilot-instructions.md for coding standards
  2. Follow single-responsibility principles
  3. Use explicit types (no any in TypeScript)
  4. Write self-documenting code
  5. Include JSDoc/JavaDoc for complex logic
  6. Test before committing

๐Ÿ“ž Support

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.port in application.properties
  • CORS errors: Add frontend URL to cors.allowed-origins
  • Ollama connection: Check spring.ai.ollama.base-url

๐Ÿ“œ License

Proprietary - SmartAllies ยฉ 2025


Next Step: Run the backend with cd backend && ./start.sh and test the API! ๐Ÿš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors