Changed Dockerfiles for bridge-frontend, link, and leafcutter to copy the entire installer directory instead of selective copying. This ensures all workspace packages (including @link-stack/logger) are available at runtime, fixing the 'Cannot find package' error in Docker containers. |
||
|---|---|---|
| .. | ||
| app | ||
| public | ||
| .eslintrc.json | ||
| .gitignore | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| middleware.ts | ||
| next.config.js | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
Bridge Frontend
Frontend application for managing communication bridges between various messaging platforms and the CDR Link system.
Overview
Bridge Frontend provides a web interface for configuring and managing communication channels including Signal, WhatsApp, Facebook, and Voice integrations. It handles bot registration, webhook configuration, and channel settings.
Features
- Channel Management: Configure Signal, WhatsApp, Facebook, and Voice channels
- Bot Registration: Register and manage bots for each communication platform
- Webhook Configuration: Set up webhooks for message routing
- Settings Management: Configure channel-specific settings and behaviors
- User Authentication: Secure access with NextAuth.js
Development
Prerequisites
- Node.js >= 20
- npm >= 10
- PostgreSQL database
- Running bridge-worker service
Setup
# Install dependencies
npm install
# Run database migrations
npm run migrate:latest
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm run start
Environment Variables
Required environment variables:
DATABASE_URL- PostgreSQL connection stringDATABASE_HOST- Database hostDATABASE_NAME- Database nameDATABASE_USER- Database usernameDATABASE_PASSWORD- Database passwordNEXTAUTH_URL- Application URLNEXTAUTH_SECRET- NextAuth.js secretGOOGLE_CLIENT_ID- Google OAuth client IDGOOGLE_CLIENT_SECRET- Google OAuth client secret
Available Scripts
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run migrate:latest- Run all pending migrationsnpm run migrate:down- Rollback last migrationnpm run migrate:up- Run next migrationnpm run migrate:make- Create new migration
Architecture
Database Schema
The application manages the following main entities:
- Bots: Communication channel bot configurations
- Webhooks: Webhook endpoints for external integrations
- Settings: Channel-specific configuration settings
- Users: User accounts with role-based permissions
API Routes
/api/auth- Authentication endpoints/api/[service]/bots- Bot management for each service/api/[service]/webhooks- Webhook configuration
Page Structure
/- Dashboard/home page/login- Authentication page/[...segment]- Dynamic routing for CRUD operations@create- Create new entities@detail- View entity details@edit- Edit existing entities
Integration
Database Access
Uses Kysely ORM for type-safe database queries:
import { db } from '@link-stack/database'
const bots = await db
.selectFrom('bots')
.selectAll()
.execute()
Authentication
Integrated with NextAuth.js using database adapter:
import { authOptions } from '@link-stack/auth'
Docker Support
# Build image
docker build -t link-stack/bridge-frontend .
# Run with docker-compose
docker-compose -f docker/compose/bridge.yml up
Related Services
- bridge-worker: Processes messages from configured channels
- bridge-whatsapp: WhatsApp-specific integration service
- bridge-migrations: Database schema management