CallSphere is an end-to-end logistics and last-mile delivery platform that empowers customers to interact with their shipments through both chat and voice interfaces, while providing operations teams with comprehensive monitoring, issue management, and escalation workflows.
CallSphere combines traditional logistics management with modern AI-powered customer service. The platform features a customer dashboard that supports both text-based chat agents and browser-based voice agents, enabling customers to track shipments, report issues, and request delivery changes using their preferred communication method. On the operations side, dispatchers, managers, and administrators have access to real-time dashboards for monitoring shipments, managing routes, handling delivery issues, and configuring system metrics.
- Multi-Modal Customer Interface: Unified chat and voice agents powered by OpenAI, allowing customers to interact naturally with the system
- Real-Time Monitoring: WebSocket-based updates for shipment tracking, issue management, and escalation workflows
- Role-Based Access Control: Comprehensive RBAC system with five distinct roles (customer, driver, dispatcher, manager, admin)
- Intelligent Escalation System: Automated escalation workflows with acknowledgment tracking
- Metrics Dashboard: Configurable KPIs and performance metrics with snapshot history
- Multi-Agent AI Architecture: Specialized AI agents for tracking, issue reporting, delivery changes, escalations, and analytics
- Framework: NestJS 11
- Database: PostgreSQL with Prisma 7 ORM
- Real-Time: WebSockets (Socket.IO)
- Authentication: JWT with Passport.js
- AI/ML: OpenAI Agents API and OpenAI Realtime API
- Framework: React 18 with TypeScript
- Build Tool: Vite
- Styling: TailwindCSS with Radix UI components
- State Management: TanStack Query (React Query)
- Real-Time: Socket.IO Client
- Charts: Recharts
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- PostgreSQL (v12 or higher)
- npm or yarn
- OpenAI API Key (for AI agents and voice functionality)
git clone <repository-url>
cd CallSphereCreate a PostgreSQL database:
# Using psql
createdb callsphere
# Or using SQL
psql -U postgres
CREATE DATABASE callsphere;Navigate to the backend directory and install dependencies:
cd backend
npm installCreate a .env file in the backend directory:
DATABASE_URL="postgresql://username:password@localhost:5432/callsphere"
JWT_SECRET="your-secret-key-change-in-production"
OPENAI_API_KEY="sk-your-openai-api-key"
PORT=3000
FRONTEND_URL="http://localhost:5173"Run database migrations:
npx prisma migrate deploySeed the database with sample data:
npx prisma db seedThe seed script creates:
- 30-50 sample shipments with scan history
- Routes and route stops
- Sample delivery issues
- Escalation contacts
- Metric definitions
- Default dashboard configurations
- Test users for all roles
Start the backend development server:
npm run start:devThe backend API will be available at http://localhost:3000
Navigate to the frontend directory and install dependencies:
cd frontend
npm installCreate a .env file in the frontend directory (if needed for API URL):
VITE_API_URL=http://localhost:3000Start the frontend development server:
npm run devThe frontend application will be available at http://localhost:5173
The seed script creates the following test accounts (password for all: password123):
- Admin:
admin@callsphere.com- Full system access - Manager:
manager@callsphere.com- Dispatcher capabilities + escalation management - Dispatcher:
dispatch@callsphere.com- Regional shipment and issue management - Customer:
customer@callsphere.com- Customer portal access - Driver:
driver@callsphere.com- Route and stop management
Additional users are created during seeding with various roles and assignments.
- Log in as a customer (
customer@callsphere.com) - Navigate to the Customer Dashboard
- Use the chat interface to ask: "Where is my package ABC123?"
- The AI agent will retrieve and display shipment status, last scan location, and ETA
- Follow up with: "I want to report that my package arrived damaged"
- The agent will collect details and create a delivery issue
- Check the Admin/Ops dashboard to see the issue appear in real-time
- Log in as a customer
- Navigate to the Customer Dashboard
- Click the microphone button to start a voice session
- Say: "I need to reschedule my delivery for tomorrow afternoon"
- The voice agent will process your request, validate availability, and confirm the change
- View the updated delivery information in your shipment details
- Log in as an admin or manager
- Navigate to the Admin/Ops Dashboard
- View the Metrics Overview to identify shipments with high SLA risk scores
- Navigate to the Issues queue and filter by severity
- When a high-severity issue is created, the escalation system automatically triggers
- View the escalation in the Escalations section
- As a manager, acknowledge the escalation with notes
- Observe the escalation status update in real-time
CallSphere/
├── backend/ # NestJS backend application
│ ├── prisma/ # Database schema and migrations
│ │ ├── schema.prisma # Prisma schema definition
│ │ ├── migrations/ # Database migration files
│ │ └── seed.ts # Database seeding script
│ ├── src/
│ │ ├── agent-sessions/ # AI session management
│ │ ├── ai/ # OpenAI agents and orchestration
│ │ ├── auth/ # Authentication and authorization
│ │ ├── delivery-changes/ # Delivery change requests
│ │ ├── escalations/ # Escalation workflow management
│ │ ├── events/ # WebSocket gateway and events
│ │ ├── issues/ # Delivery issue management
│ │ ├── metrics/ # Metrics computation and snapshots
│ │ ├── routes/ # Route and stop management
│ │ ├── shipments/ # Shipment tracking and management
│ │ └── users/ # User management
│ └── package.json
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── contexts/ # React contexts
│ │ ├── hooks/ # Custom React hooks
│ │ ├── pages/ # Page components
│ │ ├── services/ # API service layer
│ │ └── types/ # TypeScript type definitions
│ └── package.json
└── README.md
All API requests (except login/register) require a JWT token in the Authorization header:
Authorization: Bearer <token>
POST /auth/login- User authenticationGET /shipments- List shipments (filtered by role)GET /shipments/:id- Get shipment detailsGET /routes- List routesGET /issues- List delivery issuesPOST /issues- Create a delivery issueGET /metrics/overview- Get metrics overviewPOST /ai/chat- Send chat message to AI agentPOST /ai/voice/session- Create voice session
The application uses WebSocket connections for real-time updates. Connect to ws://localhost:3000 with a valid JWT token.
Available channels:
shipment:<trackingNumber>- Shipment updatesroutes:<routeCode>- Route updatesissues- Delivery issue updatesescalations- Escalation eventsmetrics:overview- Metric snapshot updates
Event types:
shipment.scan.createdshipment.status.updatedissue.createdissue.updatedescalation.triggeredescalation.advancedescalation.acknowledgedmetrics.snapshot.created
The system implements five roles with distinct permissions:
- Track own shipments
- Create issues for own shipments
- Request delivery changes for own shipments
- View assigned routes and stops
- Update stop status (completed/failed)
- View/update shipments and issues within assigned region
- Manage route adjustments (within policy)
- Read metrics
- All dispatcher capabilities
- Escalation acknowledgments
- Read metrics and edit certain thresholds
- Full system access
- Edit metric definitions, thresholds, dashboard layouts
- Manage escalation ladders
- System configuration
CallSphere uses a multi-agent architecture powered by OpenAI:
- LogisticsRouterAgent: Classifies user intent and routes to specialist agents
- ShipmentTrackingAgent: Retrieves shipment status, scans, and ETA information
- DeliveryIssueAgent: Collects issue details, classifies severity, and creates issues
- DeliveryChangeAgent: Validates and applies delivery change requests
- LogisticsEscalationAgent: Triggers and manages escalation workflows
- LogisticsAnalyticsAgent: Answers operational questions using metrics data
All agents use backend API tools to ensure data accuracy and consistency.
Backend tests:
cd backend
npm run test # Unit tests
npm run test:e2e # End-to-end tests
npm run test:cov # Test coverageCreate a new migration:
cd backend
npx prisma migrate dev --name your-migration-nameApply migrations in production:
npx prisma migrate deployBackend:
cd backend
npm run format
npm run lintEnsure all environment variables are properly configured for production:
- Use a strong
JWT_SECRET - Set
DATABASE_URLto your production database - Configure
OPENAI_API_KEYwith your production API key - Set appropriate
FRONTEND_URLfor CORS
Backend:
cd backend
npm run build
npm run start:prodFrontend:
cd frontend
npm run build
# Serve the dist/ directory with your web server- Verify PostgreSQL is running
- Check
DATABASE_URLformat:postgresql://user:password@host:port/database - Ensure database exists and user has proper permissions
- Verify
OPENAI_API_KEYis set correctly - Check API key has sufficient credits
- Ensure API key has access to Agents API and Realtime API
- Verify backend is running on the expected port
- Check CORS configuration in
main.ts - Ensure JWT token is valid and not expired
This project is private and proprietary.
For issues and questions, please contact the development team.