link-stack/apps/bridge-frontend/README.md

133 lines
3.3 KiB
Markdown
Raw Permalink Normal View History

2025-05-23 13:20:07 +02:00
# Bridge Frontend
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
Frontend application for managing communication bridges between various messaging platforms and the CDR Link system.
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
## 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
2024-03-04 13:52:20 +01:00
```bash
2025-05-23 13:20:07 +02:00
# Install dependencies
npm install
# Run database migrations
npm run migrate:latest
# Run development server
2024-03-04 13:52:20 +01:00
npm run dev
2025-05-23 13:20:07 +02:00
# Build for production
npm run build
# Start production server
npm run start
2024-03-04 13:52:20 +01:00
```
2025-05-23 13:20:07 +02:00
### Environment Variables
Required environment variables:
- `DATABASE_URL` - PostgreSQL connection string
- `DATABASE_HOST` - Database host
- `DATABASE_NAME` - Database name
- `DATABASE_USER` - Database username
- `DATABASE_PASSWORD` - Database password
- `NEXTAUTH_URL` - Application URL
- `NEXTAUTH_SECRET` - NextAuth.js secret
- `GOOGLE_CLIENT_ID` - Google OAuth client ID
- `GOOGLE_CLIENT_SECRET` - Google OAuth client secret
### Available Scripts
- `npm run dev` - Start development server
- `npm run build` - Build for production
- `npm run start` - Start production server
- `npm run lint` - Run ESLint
- `npm run migrate:latest` - Run all pending migrations
- `npm run migrate:down` - Rollback last migration
- `npm run migrate:up` - Run next migration
- `npm run migrate:make` - Create new migration
## Architecture
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
### Database Schema
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
The application manages the following main entities:
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
- **Bots**: Communication channel bot configurations
- **Webhooks**: Webhook endpoints for external integrations
- **Settings**: Channel-specific configuration settings
- **Users**: User accounts with role-based permissions
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
### API Routes
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
- `/api/auth` - Authentication endpoints
- `/api/[service]/bots` - Bot management for each service
- `/api/[service]/webhooks` - Webhook configuration
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
### Page Structure
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
- `/` - 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:
```typescript
import { db } from '@link-stack/database'
const bots = await db
.selectFrom('bots')
.selectAll()
.execute()
```
### Authentication
Integrated with NextAuth.js using database adapter:
```typescript
import { authOptions } from '@link-stack/auth'
```
## Docker Support
```bash
# Build image
docker build -t link-stack/bridge-frontend .
# Run with docker-compose
docker-compose -f docker/compose/bridge.yml up
```
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
## Related Services
2024-03-04 13:52:20 +01:00
2025-05-23 13:20:07 +02:00
- **bridge-worker**: Processes messages from configured channels
- **bridge-whatsapp**: WhatsApp-specific integration service
- **bridge-migrations**: Database schema management