Attack Capital Assignment: A production-grade unified communication platform built with Next.js 14, TypeScript, and Prisma.
A centralized communication hub that aggregates messages from SMS (Twilio), WhatsApp (Twilio API), Email, and social media platforms into a single collaborative inbox for teams.
- Unified Inbox: Threaded messages by contact across all channels
- Multi-Channel Support: SMS, WhatsApp, Email, Twitter/X, Facebook Messenger
- Team Collaboration: Real-time presence, notes, and @mentions
- Message Scheduling: Automated follow-ups and campaign scheduling
- Analytics Dashboard: Engagement metrics, response times, conversion funnels
- Contact Management: Unified profiles with history and notes
- Role-Based Access: Viewer, Editor, Admin roles via Better Auth
| Layer | Technology |
|---|---|
| Framework | Next.js 14+ (App Router) |
| Language | TypeScript |
| Database | PostgreSQL via Prisma ORM |
| Authentication | Better Auth (Google + Credentials) |
| Styling | Tailwind CSS |
| State Management | React Query (TanStack Query) |
| Real-time | WebSockets + Y.js |
| Integrations | Twilio SDK, Resend, Twitter API v2, Facebook Graph API |
| Code Quality | ESLint, Prettier, Husky |
- Node.js 18+ and npm
- PostgreSQL database (local or cloud)
- Twilio account (sign up here)
- Optional: Google OAuth credentials
# Clone the repository
git clone <your-repo-url>
cd multi-channel-customer-outreach
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your credentials
# Run database migrations
npx prisma migrate dev
# Start development server
npm run devVisit http://localhost:3000
βββ app/ # Next.js App Router pages
β βββ api/ # API routes & webhooks
β βββ (auth)/ # Authentication pages
β βββ (dashboard)/ # Protected dashboard pages
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ ui/ # Reusable UI components
β βββ inbox/ # Inbox-specific components
β βββ analytics/ # Analytics components
βββ lib/ # Core utilities
β βββ integrations/ # Channel integrations (Twilio, etc.)
β βββ db.ts # Prisma client
β βββ utils.ts # Helper functions
βββ hooks/ # Custom React hooks
βββ types/ # TypeScript types
βββ prisma/ # Database schema & migrations
β βββ schema.prisma # Database schema
βββ public/ # Static assets
- User: Team members with roles
- Team: Multi-tenant team structure
- Contact: Unified contact profiles
- Message: Normalized messages across channels
- Note: Internal team notes on contacts
- Channel: Configuration for each communication channel
- ScheduledMessage: Automated message queue
- Analytics: Engagement metrics
erDiagram
User ||--o{ Team : belongs_to
Team ||--o{ Contact : manages
Contact ||--o{ Message : receives
Contact ||--o{ Note : has
User ||--o{ Message : sends
User ||--o{ Note : creates
Message ||--|| Channel : via
| Channel | Status | Latency | Cost | Reliability |
|---|---|---|---|---|
| Twilio SMS | β Core | ~1-3s | $0.0075/msg | 99.95% |
| Twilio WhatsApp | β Core | ~1-2s | $0.005/msg | 99.9% |
| Email (Resend) | π§ Optional | ~2-5s | Free tier | 99% |
| Twitter/X DMs | π§ Optional | ~3-7s | Free | 95% |
| Facebook Messenger | π§ Optional | ~2-4s | Free | 97% |
- Twilio: Use trial number for testing; sandbox for WhatsApp
- Social APIs: Require OAuth app setup and webhook verification
- Email: IMAP polling vs. webhook-based (Resend recommended)
Powered by Better Auth with:
- Providers: Google OAuth, Email/Password
- Roles:
viewer: Read-only accesseditor: Can send messages and edit contactsadmin: Full system access
| Action | Viewer | Editor | Admin |
|---|---|---|---|
| View Inbox | β | β | β |
| Send Messages | β | β | β |
| Manage Contacts | β | β | β |
| Schedule Messages | β | β | β |
| View Analytics | β | β | β |
| Manage Team | β | β | β |
| Configure Channels | β | β | β |
Tracked engagement metrics:
- Response Time: Average time to first response
- Channel Volume: Messages per channel
- Conversion Funnel: Lead β Response β Conversion
- Open Rates: Message read receipts (WhatsApp, Email)
- Team Performance: Messages sent per user
npm run dev # Start dev server
npm run build # Production build
npm run start # Start production server
npm run lint # Lint code
npm run format # Format with Prettier
npm run type-check # TypeScript validationmain: Production-ready codedevelop: Integration branch- Feature branches:
feature/inbox-ui,feature/twilio-integration, etc.
feat: add WhatsApp integration
fix: resolve message threading issue
docs: update setup instructions
chore: upgrade dependencies
See .env.example for all required environment variables.
Critical Variables:
DATABASE_URL="postgresql://..."
TWILIO_ACCOUNT_SID="ACxxxxxxxxx"
TWILIO_AUTH_TOKEN="your_token"
BETTER_AUTH_SECRET="min-32-chars"Created a unified ChannelSender interface to normalize message sending across platforms:
interface ChannelSender {
send(payload: MessagePayload): Promise<MessageResult>;
validate(payload: MessagePayload): boolean;
}Rationale: Enables adding new channels without modifying core logic.
Centralized webhook handler at /api/webhooks with provider-specific routing and signature validation.
Rationale: Security and maintainability for multiple webhook sources.
Single Message table with channelType and polymorphic metadata JSON field.
Rationale: Simplifies querying while preserving channel-specific data.