This project is part of the series on Youtube
Your autonomous AI assistant for email and calendar management. ExecOS uses Claude AI to analyze incoming emails, draft replies, extract action items, and create calendar events — all running on autopilot.
Huge shoutout to Clerk for sponsoring this video.
- AI Email Analysis — Processes unread emails using Claude Sonnet 4, extracting summaries, priorities, action items, and categories
- Smart Draft Replies — Automatically generates context-aware email drafts in Gmail
- Calendar Integration — Detects meeting requests and time references in emails, creates Google Calendar events automatically
- Task Extraction — Pulls action items from emails and creates prioritized tasks with due dates
- Autonomous Agent — Runs on a 15-minute cron schedule via Vercel, processing emails without manual intervention
- Monitoring Dashboard — View agent run history, email processing details, and performance metrics
- Secure OAuth — AES-256-GCM encrypted token storage for all Google integrations
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript 5 |
| Auth | Clerk |
| AI | Anthropic Claude (Sonnet 4) |
| Database | PostgreSQL + Drizzle ORM |
| Integrations | Gmail API, Google Calendar API |
| UI | Tailwind CSS 4 + shadcn/ui + Radix UI |
| Deployment | Vercel |
app/
├── (auth)/ # Sign-in / sign-up pages (Clerk)
├── (main)/ # Protected app pages
│ ├── dashboard/ # Onboarding, stats, agent status
│ ├── monitoring/ # Agent run history & email details
│ └── settings/ # Integration management
├── api/
│ ├── agents/run/ # Agent execution endpoint (manual + cron)
│ └── auth/google/ # OAuth initiation & callback
├── layout.tsx # Root layout with ClerkProvider
└── page.tsx # Landing page
lib/
├── agent.ts # Agent orchestration logic
├── agents/
│ ├── gmail.ts # Gmail API operations
│ ├── calendar.ts # Google Calendar operations
│ └── process-email.ts # AI email analysis with Claude
├── encryption.ts # AES-256-GCM token encryption
├── google-client.ts # OAuth client & token refresh
└── google.ts # Google scopes & auth URLs
db/
├── schema.ts # Database schema (users, integrations, tasks, agent_runs)
├── queries.ts # Database query functions
└── index.ts # Drizzle client instance
components/
├── agents/ # Agent-specific components
└── ui/ # shadcn/ui component library
- Node.js 18+ (or Bun)
- PostgreSQL database
- Clerk account
- Google Cloud project with Gmail and Calendar APIs enabled
- Anthropic API key
git clone <repo-url>
cd exec-osbun install
# or
npm installCreate a .env.local file in the project root:
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_...
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/dashboard
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/dashboard
# Database
DATABASE_URL=postgresql://user:password@host:5432/exec_os
# Google OAuth
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Encryption (32-byte hex string for AES-256-GCM)
ENCRYPTION_KEY=your-64-char-hex-string
# AI
AI_GATEWAY_API_KEY=your-anthropic-api-key
# Cron (used to authenticate scheduled agent runs)
CRON_SECRET=your-cron-secretnpx drizzle-kit pushbun dev
# or
npm run devOpen http://localhost:3000.
| Table | Purpose |
|---|---|
users |
User profiles synced from Clerk, subscription status, preferences |
integrations |
Encrypted OAuth tokens for Gmail and Google Calendar |
tasks |
Action items extracted from emails by the AI agent |
agent_runs |
Execution history with per-email action logs and metrics |
- Trigger — Runs via Vercel cron (every 15 min) or manual button press
- Fetch Emails — Retrieves unread emails from Gmail (last 7 days, max 10 per run)
- Load Context — Fetches upcoming calendar events (next 24 hours) for scheduling awareness
- AI Analysis — Each email is processed by Claude Sonnet 4, producing:
- Summary, priority level, and category
- Action items with descriptions and due dates
- Whether a reply is needed + draft reply text
- Calendar events to create
- Take Actions — Creates tasks, drafts replies in Gmail, adds calendar events
- Mark Read — Processed emails are marked as read
- Log Results — Full execution details stored in
agent_runsfor monitoring
| Method | Route | Description |
|---|---|---|
POST |
/api/agents/run |
Execute agent (auth required, or cron with CRON_SECRET) |
GET |
/api/auth/google |
Initiate Google OAuth flow |
GET |
/api/auth/google/callback |
Handle OAuth callback and store tokens |
bun dev # Start development server
bun run build # Production build
bun start # Start production server
bun run lint # Run ESLintThe app is configured for Vercel with a cron job that triggers the agent every 15 minutes:
{
"crons": [
{
"path": "/api/agents/run",
"schedule": "*/15 * * * *"
}
]
}Set all environment variables in your Vercel project settings, and ensure CRON_SECRET is configured for secure cron execution.
- Token encryption — All OAuth tokens encrypted at rest with AES-256-GCM
- Automatic refresh — Tokens refreshed before expiry with a 5-minute buffer
- CSRF protection — OAuth flow uses state parameter stored in HTTP-only cookies
- Route protection — Clerk middleware secures all app routes
- Cron authentication — Bearer token validation on scheduled agent runs