A Val Town application for receiving Notion webhooks, processing data, and integrating with external services.
├── backend/
│ ├── controllers/ # Business logic
│ ├── routes/ # HTTP handlers
│ │ ├── api/ # API endpoints
│ │ ├── tasks/ # Webhook handlers
│ │ ├── views/ # User-facing views
│ │ └── authCheck.ts # Auth middleware
│ └── services/ # External API integrations
├── frontend/ # React frontend
│ ├── components/ # React components
│ ├── index.html # HTML shell
│ └── index.tsx # React entry point
├── shared/ # Shared types and utilities
│ ├── types.ts # TypeScript interfaces
│ └── utils.ts # Shared utility functions
├── main.http.tsx # Application entry point (Hono)
├── CLAUDE.md # Development guidelines
├── AGENTS.md # Val Town platform guidelines
└── deno.json # Deno configuration
This application follows a strict 3-layer MVC architecture:
Request → Route → Controller → Service → External API
Never skip layers! See CLAUDE.md for detailed guidelines.
Required environment variables (set in Val Town):
NOTION_API_KEY - Notion integration token (required)WEBHOOK_SECRET - Shared secret for API and webhook authentication (required for production, optional for development)RECENT_PAGES_LOOKBACK_HOURS - Hours to look back for recent pages (optional, defaults to 24)FIRECRAWLER_API_KEY)Set environment variables in Val Town settings
Add routes in backend/routes/:
api/tasks/views/Create controllers in backend/controllers/:
pageController.ts for generic Notion page operations{success, data, error, details?} formatIntegrate services in backend/services/:
notionService.ts for Notion API callsMount routes in main.http.tsx:
import { apiRoutes } from './backend/routes/api/index.ts';
app.route('/api', apiRoutes);
SCAFFOLD.md - One-time setup guide for creating a new val from scratchCLAUDE.md - Ongoing development guidelines and architectural patternsAGENTS.md - Val Town platform patterns (triggers, redirects, standard library, React config)/backend/README.md - Complete backend architecture documentation/frontend/README.md - Frontend structure and React patterns/shared/README.md - Shared code guidelinesQuick Links:
SCAFFOLD.mdCLAUDE.mdAGENTS.mdAll controllers return:
{
success: boolean,
data: any | null,
error: string | null,
details?: string
}
pageId, not task/project-specific IDs/api/tasks/:id)MIT