Codapult ships three infrastructure modules — file storage, background jobs, and notifications — each using the adapter pattern. Switch implementations via a single environment variable; no code changes required.
File Storage
Upload and serve files through a unified API with local, S3, or Cloudflare R2 adapters. See the dedicated File Storage documentation for provider setup, env vars, and programmatic usage.
Background Jobs
Offload work to background jobs with in-memory or BullMQ (Redis) adapters. See the dedicated Background Jobs documentation for job types, cron schedules, and production setup.
Notifications
In-app notifications with real-time delivery. The transport is selected by NOTIFICATION_TRANSPORT.
| Transport | Env Value | Description |
|---|---|---|
| Polling | poll (default) | Periodic HTTP requests — works everywhere, zero config |
| Server-Sent Events | sse | One-way real-time stream from server to client |
| WebSocket | ws | Full-duplex real-time — requires a separate WS server |
Dashboard Integration
The NotificationBell component in the dashboard header shows unread count and a dropdown list. It works with all three transports automatically.
Creating Notifications
import { createNotification } from '@/lib/notifications';
await createNotification({
userId: 'user_abc',
type: 'info', // 'info' | 'success' | 'warning' | 'error'
title: 'Deployment complete',
message: 'Your app was deployed to production.',
link: '/dashboard/deployments/42',
});
Operations
| Function | Description |
|---|---|
createNotification() | Create and deliver a notification |
getUserNotifications() | List notifications (newest first) |
getUnreadCount() | Count unread notifications |
markAsRead() | Mark a single notification as read |
markAllAsRead() | Mark all notifications as read |
WebSocket Configuration
When using the ws transport, configure the WebSocket server URL and port:
NOTIFICATION_TRANSPORT="ws"
NEXT_PUBLIC_WS_URL="ws://localhost:3001"
WS_PORT="3001"
Choosing a Transport
- Polling — simplest option, no infrastructure dependencies. Good for low-traffic apps.
- SSE — real-time without extra servers. One-way (server → client). Good default for production.
- WebSocket — full-duplex, lowest latency. Requires running a separate WS server process.