Introduction to Heimdall
Welcome to the Heimdall documentation. Heimdall is a comprehensive full-stack platform for managing stream-related data with real-time updates, robust API capabilities, and modern web applications.
What is Heimdall?
Heimdall is a high-performance platform consisting of:
- Rust API Backend - A blazing-fast API server with REST, GraphQL, and WebSocket support
- Backend Dashboard - A Next.js admin dashboard for managing the platform
- Heimdall ID - An identity and authentication service with OAuth support
- Documentation - This comprehensive documentation site
Architecture Overview
┌─────────────────────────────────────────────────────────────────┐
│ Heimdall Platform │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Backend │ │ Heimdall │ │ Docs │ │
│ │ Dashboard │ │ ID │ │ (this) │ │
│ │ (Next.js) │ │ (Next.js) │ │ (Docusaurus)│ │
│ └──────┬──────┘ └──────┬──────┘ └─────────────┘ │
│ │ │ │
│ │ GraphQL │ OAuth │
│ │ REST │ Sessions │
│ │ WebSocket │ │
│ │ │ │
│ ┌──────┴──────────────────┴──────────────────────────┐ │
│ │ Rust API │ │
│ │ (REST + GraphQL + WebSocket + OpenAPI) │ │
│ └─────────────────────────┬──────────────────────────┘ │
│ │ │
│ ┌─────────────────────────┴──────────────────────────┐ │
│ │ PostgreSQL + Redis │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Key Features
API Capabilities
- REST API - Full RESTful API with HATEOAS links and OpenAPI documentation
- GraphQL - Flexible queries with GraphiQL IDE for development
- WebSockets - Real-time bidirectional communication for live updates
- Swagger UI - Interactive API documentation and testing
Authentication & Authorization
- OAuth Support - Twitch OAuth integration via NextAuth
- API Keys - Programmatic access with scopes and permissions
- RBAC - Role-Based Access Control with granular permissions
- Session Management - Secure session handling
Real-time Features
- Live GPS Tracking - Real-time GPS data updates
- WebSocket Channels - Subscribe to GPS, notifications, and stats
- Heartbeat Monitoring - Automatic connection health checks
Developer Experience
- Type Safety - End-to-end type safety from Rust to TypeScript
- Auto-generated Schemas - GraphQL and OpenAPI schemas generated from code
- Interactive Documentation - Swagger UI and GraphiQL for testing
Service URLs
| Service | Production | Development |
|---|---|---|
| API | https://api.elcto.com | http://localhost:3000 |
| Console | https://console.elcto.com | http://localhost:3001 |
| Heimdall ID | https://id.elcto.com | http://localhost:3002 |
| Docs | https://docs.elcto.com | http://localhost:3003 |
All API endpoints use the /v1 prefix (e.g., https://api.elcto.com/v1/gps).
Quick Start
1. Development Setup
# Clone the repository
git clone https://github.com/elcto/heimdall.git
cd heimdall
# Initialize config files
just init
# Start the dev stack (PostgreSQL, Redis, MailDev)
just stack-up
# Run database migrations
just migrate
# Start the API (in one terminal)
just watch-api
# Start the web apps (in separate terminals)
just watch-backend # Admin dashboard at localhost:3001
just watch-id # Identity service at localhost:3002
just watch-docs # Documentation at localhost:3003
2. Explore the API
Visit the interactive documentation:
- Swagger UI - REST API documentation
- GraphiQL - GraphQL playground (development only)
- GraphQL Schema - GraphQL schema in SDL format
3. Get an API Token
Contact your administrator to obtain an API token for programmatic access.
4. Make Your First Request
# Check API health
curl https://api.elcto.com/health
# Get current GPS location (requires authentication)
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://api.elcto.com/v1/gps/current
5. Connect via WebSocket
const ws = new WebSocket('wss://api.elcto.com/v1/ws');
ws.onopen = () => {
// Subscribe to GPS updates
ws.send(JSON.stringify({
type: 'Subscribe',
channel: 'gps'
}));
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === 'Message' && message.channel === 'gps') {
console.log('GPS Update:', JSON.parse(message.data));
}
};
Development Commands
Heimdall uses just as a command runner. Run just to see all available commands.
Common Commands
| Command | Description |
|---|---|
just init | Copy example config files |
just stack-up | Start PostgreSQL, Redis, MailDev |
just stack-down | Stop dev stack services |
just migrate | Run database migrations |
just migrate-fresh | Reset database and run migrations |
just watch-api | Run API with hot reload |
just watch-backend | Run backend dashboard with hot reload |
just watch-id | Run identity service with hot reload |
just schemas | Generate OpenAPI and GraphQL schemas |
Database Commands
| Command | Description |
|---|---|
just migrate-up | Run pending migrations |
just migrate-down | Rollback last migration |
just migrate-reset | Rollback all and re-run migrations |
just migrate-status | Show migration status |
just db-fresh | Drop, create, and migrate database |
Docker Deployment
Heimdall provides Docker images for production deployment:
# Build images locally
docker build -f docker/api.Dockerfile -t heimdall-api .
docker build -f docker/backend.Dockerfile -t heimdall-backend .
docker build -f docker/id.Dockerfile -t heimdall-id .
Container Images
| Image | Port | Description |
|---|---|---|
ghcr.io/elcto/heimdall/api | 3000 | Rust API server |
ghcr.io/elcto/heimdall/backend | 3001 | Admin dashboard |
ghcr.io/elcto/heimdall/id | 3002 | Identity service |
Technology Stack
Backend (Rust API)
| Technology | Purpose |
|---|---|
| Actix-web | High-performance HTTP framework |
| SQLx | Async, type-safe SQL |
| async-graphql | GraphQL implementation |
| utoipa | OpenAPI documentation |
| Redis | Caching and rate limiting |
| PostgreSQL | Primary database |
Frontend (Next.js Apps)
| Technology | Purpose |
|---|---|
| Next.js 16 | React framework with App Router |
| React 19 | UI library |
| TypeScript | Type-safe development |
| TailwindCSS 4 | Utility-first styling |
| NextAuth | Authentication library |
| Apollo Client | GraphQL client |
Project Structure
heimdall/
├── platform/
│ ├── api/ # Rust API backend
│ │ ├── src/
│ │ │ ├── graphql/ # GraphQL schema and resolvers
│ │ │ ├── handlers/ # REST API handlers
│ │ │ ├── middleware/
│ │ │ ├── models/
│ │ │ ├── routes/
│ │ │ └── websocket/
│ │ ├── templates/ # Email templates
│ │ └── Cargo.toml
│ │
│ ├── backend/ # Admin dashboard (Next.js)
│ │ ├── src/
│ │ │ ├── app/ # App Router pages
│ │ │ ├── components/
│ │ │ └── lib/
│ │ └── package.json
│ │
│ ├── id/ # Identity service (Next.js)
│ │ ├── src/
│ │ │ ├── app/ # App Router pages
│ │ │ ├── components/
│ │ │ └── lib/
│ │ └── package.json
│ │
│ ├── docs/ # Documentation (Docusaurus)
│ │ ├── docs/
│ │ └── src/
│ │
│ └── migrations/ # Database migrations (SQL)
│
├── docker/ # Dockerfiles
│ ├── api.Dockerfile
│ ├── backend.Dockerfile
│ └── id.Dockerfile
│
├── dev-stack/ # Development Docker Compose
│ ├── db.docker-compose.yml
│ └── mail.docker-compose.yml
│
├── .github/workflows/ # CI/CD workflows
├── justfile # Command runner
├── Cargo.toml # Rust workspace
└── pnpm-workspace.yaml # pnpm workspace
Next Steps
Ready to dive deeper? Here's where to go next:
- API Overview - Learn about all available APIs
- Authentication - Set up authentication
- REST API Reference - Complete REST endpoint reference
- GraphQL Guide - Learn to use the GraphQL API
- WebSocket Guide - Real-time communication
- Code Examples - Integration examples in multiple languages
- Web Apps - Frontend application documentation
- Architecture - System architecture details