A modern web dashboard for managing and monitoring AI token usage across Zededa enterprises. Built with Next.js, TypeScript, and Okta authentication.
Don't have Okta access yet? No problem! Run the dashboard in testing mode:
npm install
npm run devOpen http://localhost:3000 and click "Continue to Dashboard"
✅ Testing mode is already configured in .env
✅ Uses hardcoded bearer token
✅ No Okta setup needed
See QUICKSTART.md for detailed instructions.
- Okta Authentication: Secure authentication for Zededa employees only
- Token Limits Management: Set and update token limits per enterprise
- Real-time Usage Monitoring: Track token consumption with visual charts
- Auto-refresh: Automatic data refresh every 30 seconds
- Usage Visualization: Interactive charts showing token consumption
- Reset Functionality: Reset token usage for enterprises
- Frontend: Next.js 14, React 18, TypeScript
- Styling: Tailwind CSS
- Authentication: Okta (OAuth 2.0 / OIDC)
- Charts: Recharts
- Icons: Lucide React
- HTTP Client: Axios
- Date Formatting: date-fns
- Node.js 20 or higher
- npm or yarn
- Okta account with admin access
- Access to Zededa AI Agents backend API
cd zededa-agent-uinpm install-
Log in to your Okta admin console
-
Create a new application:
- Application Type: Single-Page Application (SPA)
- Grant Types: Authorization Code with PKCE
- Sign-in redirect URIs:
http://localhost:3000/login/callback - Sign-out redirect URIs:
http://localhost:3000 - Trusted Origins: Add
http://localhost:3000
-
Note down:
- Okta domain (e.g.,
your-domain.okta.com) - Client ID
- Okta domain (e.g.,
Create a .env file in the root directory:
cp .env.example .envEdit .env with your values:
# Okta Configuration
NEXT_PUBLIC_OKTA_DOMAIN=your-okta-domain.okta.com
NEXT_PUBLIC_OKTA_CLIENT_ID=your-okta-client-id
# Backend API Configuration
NEXT_PUBLIC_API_BASE_URL=http://localhost:8080/api/v1
# Zededa Configuration
ZEDCLOUD_BASE_URL=https://zedcloud.zededa.netnpm run devOpen http://localhost:3000 in your browser.
# Build the image
docker build -t zededa-token-dashboard .
# Run the container
docker run -p 3000:3000 \
-e NEXT_PUBLIC_OKTA_DOMAIN=your-okta-domain.okta.com \
-e NEXT_PUBLIC_OKTA_CLIENT_ID=your-client-id \
-e NEXT_PUBLIC_API_BASE_URL=http://localhost:8080/api/v1 \
zededa-token-dashboard# Start the dashboard
docker-compose up -d
# Stop the dashboard
docker-compose downThe dashboard integrates with the Zededa AI Agents backend API:
-
GET /api/v1/tokens/limits
- Fetch current token limits for an enterprise
- Query param:
enterprise_id
-
POST /api/v1/tokens/limits
- Set or update token limits
- Body:
{ enterprise_id, token_limit, refill_interval }
-
GET /api/v1/tokens/usage
- Get token usage statistics
- Query param:
enterprise_id
-
DELETE /api/v1/tokens/usage
- Reset token usage for an enterprise
- Query param:
enterprise_id
The dashboard uses Okta for user authentication. After login, the Okta access token is used to authenticate API requests to the backend.
Note: In production, you should implement a token exchange mechanism to convert Okta tokens to Zedcloud bearer tokens on the backend.
- Click "Sign in with Okta" on the login page
- Enter your Zededa Okta credentials
- You'll be redirected to the dashboard after successful authentication
-
Navigate to the "Usage Monitor" tab
-
Enter an enterprise ID
-
Click "Fetch Usage" to view:
- Tokens used vs. limit
- Usage percentage
- Refill interval and timestamp
- Visual charts
-
Enable "Auto-refresh" for real-time monitoring
- Navigate to the "Manage Limits" tab
- Enter an enterprise ID
- Click "Fetch Current" to load existing limits
- Update the token limit and refill interval
- Click "Save Token Limits" to apply changes
- Go to the "Usage Monitor" tab
- Fetch usage for an enterprise
- Click "Reset Usage" button
- Confirm the action
- Usage will be reset to zero
zededa-agent-ui/
├── app/ # Next.js app directory
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Home page with auth logic
│ ├── globals.css # Global styles
│ └── login/
│ └── callback/
│ └── page.tsx # Okta callback handler
├── components/ # React components
│ ├── Dashboard.tsx # Main dashboard layout
│ ├── LoginPage.tsx # Login UI
│ ├── TokenLimitsManager.tsx # Limits management
│ ├── TokenUsageMonitor.tsx # Usage monitoring
│ └── UsageChart.tsx # Usage visualization
├── lib/ # Utilities and configurations
│ ├── api.ts # API client
│ └── oktaConfig.ts # Okta configuration
├── public/ # Static assets
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── next.config.js # Next.js configuration
├── tailwind.config.ts # Tailwind CSS configuration
└── tsconfig.json # TypeScript configuration
- Okta Domain Restriction: The application should be configured in Okta to only allow users from the Zededa organization
- API Authentication: All API requests require valid bearer tokens
- HTTPS: Use HTTPS in production environments
- Environment Variables: Never commit
.envfiles to version control - Token Storage: Access tokens are stored in localStorage (consider more secure alternatives for production)
-
Update redirect URIs in Okta:
- Sign-in:
https://your-domain.com/login/callback - Sign-out:
https://your-domain.com
- Sign-in:
-
Add production domain to Trusted Origins
Update .env for production:
NEXT_PUBLIC_OKTA_DOMAIN=your-okta-domain.okta.com
NEXT_PUBLIC_OKTA_CLIENT_ID=your-production-client-id
NEXT_PUBLIC_API_BASE_URL=https://api.your-domain.com/api/v1
ZEDCLOUD_BASE_URL=https://zedcloud.zededa.netnpm run build
npm startdocker build -t zededa-token-dashboard:production .
docker push your-registry/zededa-token-dashboard:production- Verify Okta domain and client ID are correct
- Check redirect URIs match in Okta configuration
- Ensure Trusted Origins are configured in Okta
- Verify backend API is running
- Check
NEXT_PUBLIC_API_BASE_URLis correct - Ensure CORS is properly configured on the backend
- Verify bearer token is valid
- Clear
.nextfolder:rm -rf .next - Delete
node_modulesand reinstall:rm -rf node_modules && npm install - Check Node.js version:
node --version(should be 20+)
- Create feature branch:
git checkout -b feature/your-feature - Make changes and test locally
- Commit changes:
git commit -m "Add your feature" - Push and create PR:
git push origin feature/your-feature
- TypeScript for type safety
- Use functional components with hooks
- Follow React best practices
- Use Tailwind CSS for styling
Copyright © 2024 Zededa. All rights reserved.
For issues or questions:
- Create an issue in the repository
- Contact the Zededa DevOps team
- Email: [email protected]