Configuration
The B12 SIS backend is configured through environment variables. This guide covers all available configuration options.
Environment Variables
Database Configuration
Variable |
Description |
Example |
|---|---|---|
|
Primary database connection string |
|
|
Read replica connection (optional) |
Same format as master |
!!! note “Read Replicas”
If DB_SLAVE_DSN is not set, all queries use the master connection. Set this for read-heavy workloads.
Authentication
Variable |
Description |
Default |
|---|---|---|
|
Secret key for signing JWTs (min 32 chars) |
Required |
|
Access token expiration |
|
|
Refresh token expiration |
|
|
Default password for new/reset users |
|
Server Settings
Variable |
Description |
Default |
|---|---|---|
|
HTTP server port |
|
|
Enable development features |
|
|
Run as job scheduler instead of API |
|
AWS S3 Storage
For file uploads (avatars, documents, imports):
Variable |
Description |
|---|---|
|
AWS access key |
|
AWS secret key |
|
AWS region (e.g., |
|
S3 bucket name |
|
Custom S3 endpoint (for S3-compatible storage) |
Canvas LMS Integration
Variable |
Description |
|---|---|
|
Canvas API base URL |
|
Canvas API access token |
|
Canvas root account ID |
|
Enable Canvas sync ( |
Email Configuration
Variable |
Description |
|---|---|
|
SMTP server hostname |
|
SMTP port |
|
SMTP username |
|
SMTP password |
|
Default from email address |
Rate Limiting
Variable |
Description |
Default |
|---|---|---|
|
Enable rate limiting |
|
|
Max requests per window |
|
|
Time window in seconds |
|
Example Configuration
Development (.env)
# Database
DB_MASTER_DSN=root:password@tcp(localhost:3306)/b12_sis_dev?charset=utf8mb4&parseTime=True&loc=Local
# Authentication
JWT_SECRET=development-secret-key-at-least-32-characters-long
JWT_EXPIRES_IN=24h
DEFAULT_PASSWORD=dev123
# Server
PORT=8080
DEV_MODE=true
DEPLOY_AS_JOB=0
# AWS (local MinIO for development)
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_REGION=us-east-1
AWS_BUCKET_NAME=b12-dev
AWS_ENDPOINT=http://localhost:9000
# Canvas (development instance)
CANVAS_API_URL=https://canvas-dev.yourschool.edu
CANVAS_API_TOKEN=dev-token
CANVAS_ACCOUNT_ID=1
CANVAS_SYNC_ENABLED=false
# Rate Limiting (disabled for dev)
RATE_LIMIT_ENABLED=false
Production
# Database (use environment-specific secrets management)
DB_MASTER_DSN=${DB_MASTER_DSN}
DB_SLAVE_DSN=${DB_SLAVE_DSN}
# Authentication
JWT_SECRET=${JWT_SECRET}
JWT_EXPIRES_IN=1h
DEFAULT_PASSWORD=${DEFAULT_PASSWORD}
# Server
PORT=8080
DEV_MODE=false
DEPLOY_AS_JOB=0
# AWS
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
AWS_REGION=ap-southeast-1
AWS_BUCKET_NAME=b12-production
# Canvas
CANVAS_API_URL=https://canvas.yourschool.edu
CANVAS_API_TOKEN=${CANVAS_API_TOKEN}
CANVAS_ACCOUNT_ID=1
CANVAS_SYNC_ENABLED=true
# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW=60
Multi-tenancy Configuration
The system supports multiple tenants (schools/campuses) through the Team model. Each API request must include:
X-Team-ID: <team-uuid>
This header is validated by the TeamMiddleware and used to:
Filter data to only show records belonging to the team
Automatically set
team_idon newly created recordsInclude child teams in queries (hierarchical structure)
Academic Session Configuration
Academic sessions represent school years. The current session is set via:
X-Academic-Session-ID: <session-uuid>
This affects:
Attendance records
Gradebook entries
Timetable schedules
Enrollment records
CORS Configuration
CORS is configured in the middleware. Default settings allow:
All origins in development mode
Configured origins in production
Standard methods: GET, POST, PUT, DELETE, OPTIONS
Headers: Authorization, Content-Type, X-Team-ID, X-Academic-Session-ID
Logging Configuration
Variable |
Description |
Default |
|---|---|---|
|
Log level (debug, info, warn, error) |
|
|
Output format (json, text) |
|
Security Headers
The API automatically adds security headers:
X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 1; mode=block
Next Steps
Quick Start Guide - Make your first API calls
Authentication - Learn about the auth system