A comprehensive Microsoft Teams PSTN call usage tracking and billing application for enterprise cost management.
Built with AI: This application was created with the assistance of Claude by Anthropic.
CallCulator helps organizations track, analyze, and manage their Microsoft Teams PSTN calling costs. Upload Teams usage reports and carrier rate matrices to gain insights into call spending across users, locations, and time periods.
- Summary Cards: Total cost, calls, minutes, and unique users at a glance
- Average Metrics: Cost per user and cost per call
- Monthly Cost Trend: 12-month area chart visualization
- Top Destinations: Countries ranked by cost with visual distribution bars
- Top 10 Users: Users ranked by cost with detailed metrics
- Export Reports: Download CSV or PDF reports for any period
- Manage multiple carriers (Verizon, Operator Connect Fusion, etc.)
- Separate rate matrices per carrier
- Filter all views by carrier
- Automatic carrier creation during rate upload
- Search users by email address
- Complete call history with sortable columns (date, duration, cost, destination)
- Cost breakdown by destination (pie chart)
- Most called and costliest numbers
- Monthly cost trend analysis
- Date range presets: Previous Year, Previous Month, This Month, This Year, Last 30/90 Days
- Custom date range picker
- Export user data to CSV
- Interactive World Map: Choropleth visualization with cost intensity coloring
- Hover Tooltips: Country details on hover
- Location Table: Sortable metrics per location (users, calls, minutes, cost)
- Visual Comparison: Cost distribution bars for easy comparison
- Scenario Planning: Project costs for new sites or changes
- Historical Templates: Pre-fill estimates based on existing country patterns
- Destination Distribution: Configure percentage breakdown by destination
- Detailed Results: Monthly/yearly costs with per-destination breakdown
- Missing Rate Warnings: Alerts for destinations without configured rates
- Upload carrier rate matrices (Excel format)
- Associate rates with specific carriers
- Manual rate entry and editing
- Search and filter rates by origin/destination
- Pagination for large rate sets
- Rate lookup for specific origin/destination pairs
- Support for Verizon geographic termination format
- Teams Report Upload: CSV, XLSX, XLS support
- Real-Time Progress Bar: Live processing status with record counts
- Rate Matrix Upload: Excel files with carrier association
- Upload History: Track all uploads with timestamps and record counts
- Gap Detection: Automatic detection of missing date ranges in your data
- Coverage Timeline: Visual representation of uploaded data periods
- Data Management: Clear all records with confirmation
- User Management: Create, edit, and delete users
- Role Assignment: Admin and user roles
- Password Reset: Admin can reset user passwords
- Registration Control: Toggle public registration on/off
- First User: First registered user automatically becomes admin
- Dark Mode: Full dark theme with toggle button
- Currency Toggle: Switch between USD and CHF with live exchange rates
- Responsive Design: Works on desktop and mobile devices
- Session Persistence: Filters and search results preserved across navigation
- Loading States: Clear feedback during data loading
- Sortable Tables: Click column headers to sort
- React 18 with TypeScript
- Vite for build tooling
- Tailwind CSS for styling
- Recharts for charts and graphs
- React Simple Maps for geographic visualization
- Axios for API communication
- Node.js with Express
- TypeScript
- Prisma ORM
- PostgreSQL database
- JWT authentication
- Server-Sent Events (SSE) for real-time upload progress
# Clone the repository
git clone https://github.com/clucraft/phusage.git
cd phusage
# Start with Docker Compose
docker-compose up -d
# Access the app at http://localhost:3000The first user to register becomes the admin.
- Node.js 18+
- PostgreSQL 14+
- npm or yarn
-
Clone the repository
git clone https://github.com/clucraft/phusage.git cd phusage -
Install dependencies
npm install cd client && npm install && cd ..
-
Configure environment
cp .env.example .env
Edit
.envwith your settings:DATABASE_URL="postgresql://user:password@localhost:5432/callculator" JWT_SECRET="your-secret-key-here" PORT=3000
-
Run database migrations
npx prisma migrate deploy
-
Start development servers
npm run dev
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
Navigate to Rates and upload your carrier rate Excel file.
Verizon Format - expects a sheet named "Usage Geographic Termination" with columns:
| Column | Description |
|---|---|
| Originating Country | Call origin country |
| Destination | Destination (e.g., "Afghanistan-Mobile") |
| Call Type | Outbound/Inbound |
| Price | Price per minute |
Navigate to Upload and upload your Microsoft Teams PSTN usage export.
Supported formats: CSV, XLSX, XLS
Expected columns:
| Column | Description |
|---|---|
| Display Name | User's display name |
| UPN | User's email address |
| Start time | Call start timestamp |
| Duration (seconds) | Call duration |
| Caller Number | Source phone number |
| Callee Number | Destination phone number |
| Call Direction | Filters for "Outbound" only |
The Dashboard provides:
- Total cost, calls, and minutes for selected month/year
- Average cost per user and per call
- Monthly cost trend chart (12 months)
- Top 10 users by cost
- Top 5 destinations by cost
Use User Search to find individual users:
- View complete call history
- See cost breakdown by destination
- Analyze monthly trends
- Export data to CSV
The Locations page shows:
- World map with cost intensity
- Per-location statistics
- Compare costs across regions
Use the Estimator to:
- Project costs for new sites
- Use templates from historical data
- Configure destination distributions
- View detailed cost breakdowns
| Endpoint | Method | Description |
|---|---|---|
/api/auth/login |
POST | User login |
/api/auth/register |
POST | User registration |
/api/auth/registration-status |
GET | Check if registration enabled |
| Endpoint | Method | Description |
|---|---|---|
/api/usage/summary |
GET | All users summary |
/api/usage/top10 |
GET | Top 10 users by cost |
/api/usage/user/:email |
GET | Individual user details |
/api/usage/user/:email/trend |
GET | User monthly trend |
/api/usage/monthly-costs |
GET | Monthly cost data |
/api/usage/dashboard-stats |
GET | Dashboard statistics |
/api/usage/top-destinations |
GET | Top destinations |
/api/usage/locations |
GET | Location-based data |
| Endpoint | Method | Description |
|---|---|---|
/api/rates |
GET | List rates with filtering |
/api/rates |
POST | Add/update a rate |
/api/rates/:id |
DELETE | Delete a rate |
/api/rates/lookup |
GET | Look up specific rate |
/api/rates/origins |
GET | List origin countries |
/api/rates/destinations |
GET | List destination countries |
/api/rates/stats |
GET | Rate statistics |
| Endpoint | Method | Description |
|---|---|---|
/api/upload/teams-report |
POST | Upload Teams report |
/api/upload/verizon-rates |
POST | Upload rate matrix |
/api/upload/progress/:jobId |
GET | SSE progress stream |
/api/upload/history |
GET | Upload history |
/api/upload/history/:id |
DELETE | Delete history entry |
/api/upload/call-records |
DELETE | Clear all records |
| Endpoint | Method | Description |
|---|---|---|
/api/export/csv |
GET | Download CSV report |
/api/export/pdf |
GET | Download PDF report |
| Endpoint | Method | Description |
|---|---|---|
/api/carriers |
GET | List all carriers |
/api/carriers/with-rates |
GET | Carriers with rates |
| Endpoint | Method | Description |
|---|---|---|
/api/estimator/templates |
GET | Available templates |
/api/estimator/template/:country |
GET | Template data |
/api/estimator/calculate |
POST | Calculate estimate |
/api/estimator/origins |
GET | Origin countries |
/api/estimator/destinations |
GET | Destination countries |
| Endpoint | Method | Description |
|---|---|---|
/api/admin/users |
GET | List all users |
/api/admin/users |
POST | Create user |
/api/admin/users/:id/role |
PATCH | Update user role |
/api/admin/users/:id/password |
PATCH | Reset password |
/api/admin/users/:id |
DELETE | Delete user |
/api/admin/settings |
GET | Get app settings |
/api/admin/settings |
PATCH | Update settings |
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with assistance from Claude by Anthropic
- World map data from Natural Earth
- Exchange rates from Frankfurter API















