Internal operations dashboard for monitoring incoming/outgoing company email traffic.
- Next.js App Router (
/app) for UI and server routes - PostgreSQL + Prisma for persistence
- Worker runs inside Next.js process (production mode)
- Tailwind CSS + lightweight UI primitives
- TanStack React Table for the message explorer
- SSE endpoint for near-realtime UI refresh
- Single admin auth (
ADMIN_USERNAME/ADMIN_PASSWORD) - Mailbox CRUD with encrypted IMAP credentials
- Manual sync queueing + background scheduled sync
- Unified searchable message feed (
Inbox= incoming,Sent= outgoing) - Message detail page with audit logging
- Dashboard + system status pages
Use .env with at least:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/monitor_email
APP_ENCRYPTION_KEY=<openssl rand -base64 32>
ADMIN_USERNAME=admin
ADMIN_PASSWORD=<strong-password>
SESSION_SECRET=<strong-session-secret>
SYNC_POLL_INTERVAL_MS=60000
EVENTS_POLL_INTERVAL_MS=3000
IMAP_SYNC_BATCH_SIZE=100Production runtime rejects placeholder values for APP_ENCRYPTION_KEY, ADMIN_PASSWORD, and SESSION_SECRET.
Polling intervals must be positive integers with minimum values:
SYNC_POLL_INTERVAL_MS >= 5000EVENTS_POLL_INTERVAL_MS >= 1000IMAP_SYNC_BATCH_SIZE >= 1
IMAP_SYNC_BATCH_SIZE controls how many messages per folder are imported in each sync job. Lower values reduce the chance of large-mailbox timeouts at the cost of more continuation jobs.
pnpm install
pnpm prisma:generate
pnpm dev
pnpm build
pnpm start
pnpm testNote: In development (pnpm dev), the worker doesn't run. Use pnpm dev for UI testing, or set NODE_ENV=production to test the full stack.
Build image:
docker build -t monitor-email .Run container:
docker run --rm -p 3000:3000 --env-file .env monitor-emailFor Dokploy, deploy a single service. The worker runs inside the Next.js process automatically.
- The worker runs inside the Next.js process in production mode only.
- Worker requires a reachable Postgres instance and valid mailbox IMAP credentials.
- Outgoing visibility depends on mailbox clients writing sent mail into
Sent.