|
| 1 | +# API Platform Dashboard Integration Demo |
| 2 | + |
| 3 | +A Next.js application demonstrating how to integrate Outpost with an API platform or SaaS API dashboard. This example shows how API platforms can seamlessly embed Outpost's event destination management capabilities into their existing user dashboards. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **API Platform Dashboard**: Complete user dashboard for an API/SaaS platform |
| 8 | +- **Integrated Event Management**: Seamless Outpost integration for webhook/event destinations |
| 9 | +- **Automatic Tenant Provisioning**: Users get Outpost tenants created automatically when they sign up |
| 10 | +- **Unified User Experience**: Event destination management feels like a native part of the platform |
| 11 | +- **Production-Ready Patterns**: Demonstrates real-world integration patterns for API platforms |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +- Node.js 18+ |
| 16 | +- Docker and Docker Compose |
| 17 | +- Git |
| 18 | + |
| 19 | +## Setup |
| 20 | + |
| 21 | +1. **Clone and navigate to the project**: |
| 22 | + ```bash |
| 23 | + cd examples/demos/dashboard-integration |
| 24 | + ``` |
| 25 | + |
| 26 | +2. **Install dependencies**: |
| 27 | + ```bash |
| 28 | + npm install |
| 29 | + ``` |
| 30 | + |
| 31 | +3. **Set up environment variables**: |
| 32 | + ```bash |
| 33 | + # Dashboard application configuration |
| 34 | + cp .env.example .env.local |
| 35 | + |
| 36 | + # Outpost configuration |
| 37 | + cp .env.outpost.example .env.outpost |
| 38 | + ``` |
| 39 | + |
| 40 | + The default configurations should work for local development. For production, update the secrets in both files. |
| 41 | + |
| 42 | +4. **Start the complete stack** (PostgreSQL, Redis, RabbitMQ, and Outpost): |
| 43 | + ```bash |
| 44 | + docker-compose up -d |
| 45 | + ``` |
| 46 | + |
| 47 | + This will start: |
| 48 | + - `postgres` - PostgreSQL with separate databases for dashboard and Outpost (port 5432) |
| 49 | + - `redis` - Redis for Outpost (port 6379) |
| 50 | + - `rabbitmq` - Message queue for Outpost (port 5672, management UI on 15672) |
| 51 | + - `outpost-api` - Outpost API service (port 3333) |
| 52 | + - `outpost-delivery` - Outpost delivery service |
| 53 | + - `outpost-log` - Outpost log service |
| 54 | + |
| 55 | +5. **Wait for services to be healthy**: |
| 56 | + ```bash |
| 57 | + docker-compose ps |
| 58 | + ``` |
| 59 | + Wait until all services show "healthy" status. This may take 1-2 minutes on first startup. |
| 60 | + |
| 61 | +6. **Run the dashboard application**: |
| 62 | + ```bash |
| 63 | + npm run dev |
| 64 | + ``` |
| 65 | + |
| 66 | +7. **Access the application**: |
| 67 | + - Dashboard: [http://localhost:4000](http://localhost:4000) |
| 68 | + - Outpost API: [http://localhost:3333](http://localhost:3333) |
| 69 | + - RabbitMQ Management: [http://localhost:15672](http://localhost:15672) (guest/guest) |
| 70 | + |
| 71 | +## Usage |
| 72 | + |
| 73 | +1. **Sign up for the API platform** - Register as a new user of the fictitious API platform |
| 74 | +2. **Access your platform dashboard** - View your API usage, account info, and available features |
| 75 | +3. **Manage Event Destinations** - Click "Event Destinations" to configure webhooks for your API events |
| 76 | +4. **Seamless Portal Experience** - Get redirected to Outpost's full-featured destination management interface |
| 77 | + |
| 78 | +## Use Case |
| 79 | + |
| 80 | +This demo represents a common integration scenario where: |
| 81 | + |
| 82 | +- **API Platform**: Your SaaS provides APIs that generate events (user signups, payments, data processing, etc.) |
| 83 | +- **Customer Need**: Your customers need to receive these events via webhooks to their own systems |
| 84 | +- **Outpost Integration**: Instead of building webhook infrastructure from scratch, you integrate Outpost |
| 85 | +- **User Experience**: Your customers manage event destinations through what feels like your native platform |
| 86 | + |
| 87 | +## Architecture |
| 88 | + |
| 89 | +- **Platform Frontend**: Next.js application representing your API platform's dashboard |
| 90 | +- **User Management**: Auth.js with PostgreSQL for platform user accounts |
| 91 | +- **Outpost Integration**: Official TypeScript SDK for tenant and portal management |
| 92 | +- **Seamless Handoff**: Server-side route handlers for transparent portal access |
| 93 | + |
| 94 | +## Environment Variables |
| 95 | + |
| 96 | +### Dashboard Application (.env.local) |
| 97 | + |
| 98 | +| Variable | Description | Example | |
| 99 | +|----------|-------------|---------| |
| 100 | +| `DATABASE_URL` | Dashboard PostgreSQL connection | `postgresql://dashboard:dashboard@localhost:5432/dashboard_integration` | |
| 101 | +| `NEXTAUTH_SECRET` | Auth.js secret key | `your-secret-here` | |
| 102 | +| `OUTPOST_BASE_URL` | Outpost base URL | `http://localhost:3333` | |
| 103 | +| `OUTPOST_API_KEY` | Outpost API key | `demo-api-key-change-in-production` | |
| 104 | + |
| 105 | +### Outpost Configuration (.env.outpost) |
| 106 | + |
| 107 | +| Variable | Description | Example | |
| 108 | +|----------|-------------|---------| |
| 109 | +| `API_KEY` | Outpost API key | `demo-api-key-change-in-production` | |
| 110 | +| `API_JWT_SECRET` | JWT signing secret | `demo-jwt-secret-change-in-production` | |
| 111 | +| `POSTGRES_URL` | Outpost PostgreSQL connection | `postgres://outpost:outpost@postgres:5432/outpost` | |
| 112 | +| `REDIS_HOST` | Redis hostname | `redis` | |
| 113 | +| `RABBITMQ_SERVER_URL` | RabbitMQ connection | `amqp://guest:guest@rabbitmq:5672` | |
| 114 | +| `PORTAL_ORGANIZATION_NAME` | Portal branding | `API Platform Demo` | |
| 115 | + |
| 116 | +## Docker Services |
| 117 | + |
| 118 | +The docker-compose.yml includes the complete stack: |
| 119 | + |
| 120 | +- **postgres** (port 5432): Single PostgreSQL instance with separate databases for dashboard (`dashboard_integration`) and Outpost (`outpost`) |
| 121 | +- **redis** (port 6379): Redis for Outpost caching and sessions |
| 122 | +- **rabbitmq** (ports 5672, 15672): Message queue for Outpost event processing |
| 123 | +- **outpost-api** (port 3333): Outpost API service |
| 124 | +- **outpost-delivery**: Outpost delivery service for processing webhooks |
| 125 | +- **outpost-log**: Outpost log service for event logging |
| 126 | + |
| 127 | +## Development |
| 128 | + |
| 129 | +- `npm run dev` - Start development server |
| 130 | +- `npm run build` - Build for production |
| 131 | +- `npm run start` - Start production server |
| 132 | +- `npm run lint` - Run ESLint |
| 133 | +- `docker-compose up -d` - Start all services |
| 134 | +- `docker-compose down` - Stop all services |
| 135 | +- `docker-compose logs [service]` - View logs for a specific service |
| 136 | + |
| 137 | +## Troubleshooting |
| 138 | + |
| 139 | +### Services not starting |
| 140 | +```bash |
| 141 | +# Check service status |
| 142 | +docker-compose ps |
| 143 | + |
| 144 | +# View logs for a specific service |
| 145 | +docker-compose logs outpost-api |
| 146 | +docker-compose logs dashboard-postgres |
| 147 | + |
| 148 | +# Restart services |
| 149 | +docker-compose restart |
| 150 | +``` |
| 151 | + |
| 152 | +### Database connection issues |
| 153 | +```bash |
| 154 | +# Check PostgreSQL is ready |
| 155 | +docker-compose exec postgres pg_isready -U dashboard -d dashboard_integration |
| 156 | +docker-compose exec postgres pg_isready -U outpost -d outpost |
| 157 | +``` |
| 158 | + |
| 159 | +### Outpost API not responding |
| 160 | +```bash |
| 161 | +# Check if Outpost API is healthy |
| 162 | +curl http://localhost:3333/healthz |
| 163 | + |
| 164 | +# View Outpost logs |
| 165 | +docker-compose logs outpost-api |
| 166 | +``` |
| 167 | + |
| 168 | +## Integration Points |
| 169 | + |
| 170 | +1. **User Onboarding** → Platform user registration automatically provisions Outpost tenant |
| 171 | +2. **Dashboard Overview** → Display event/webhook statistics from Outpost API in platform dashboard |
| 172 | +3. **Destination Management** → "Event Destinations" nav item seamlessly redirects to Outpost portal |
| 173 | +4. **Branded Experience** → Users experience webhook management as part of your platform, not a separate tool |
| 174 | + |
| 175 | +## Key Integration Patterns |
| 176 | + |
| 177 | +This demo illustrates several important patterns for API platform integration: |
| 178 | + |
| 179 | +- **Transparent Tenant Management**: Outpost tenants are created automatically and hidden from users |
| 180 | +- **Single Sign-On Experience**: Users don't need separate Outpost accounts |
| 181 | +- **Embedded Navigation**: Event destinations appear as a natural part of the platform navigation |
| 182 | +- **Contextual Data Display**: Platform dashboard shows relevant Outpost data (destination counts, recent events) |
| 183 | +- **Seamless Handoff**: Clicking "Event Destinations" feels like navigating to another page in your app |
0 commit comments