Provides an overview of the Flare Stack Blog architecture...
This project is a modern full-stack TypeScript blog built on the Cloudflare ecosystem, integrating TanStack Start with Hono for high performance and type safety.
The project deeply integrates multiple Cloudflare services:
| Service | Binding | Purpose |
|---|---|---|
| Compute/Hosting | - | Cloudflare Workers |
| Database | DB |
Cloudflare D1 (SQLite) with Drizzle ORM |
| Object Storage | R2 |
Media assets storage |
| KV Storage | KV |
Persistent caching layer |
| Durable Objects | RATE_LIMITER, PASSWORD_HASHER |
Distributed rate limiting, password hashing |
| Workflows | Various | Async tasks (email, post-processing, moderation) |
| Queues | QUEUE |
Message queue (email notifications) |
| AI | AI |
Cloudflare Workers AI |
| Authentication | - | Better Auth (D1 integrated) |
The project uses a two-tier routing architecture with clear responsibilities:
/api/auth/*)/images/*)src/routes/The project uses a layered dependency injection pattern:
src/server.ts): Only env and executionCtx are injected via Register['server']['requestContext']lib/middlewares.ts): db, auth, and session are injected progressively through TanStack middlewaresglobal.d.ts)| Type | Contents | Usage |
|---|---|---|
BaseContext |
env |
Minimal context for env-only operations |
DbContext |
env, db |
Database operations |
SessionContext |
env, db, auth, session (nullable) |
Session-aware but not requiring auth |
AuthContext |
env, db, auth, session (required) |
Authenticated operations |
| Layer | Location | Purpose |
|---|---|---|
| Hono | lib/hono/middlewares.ts |
Global control: rate limiting, cache headers |
| TanStack | lib/middlewares.ts |
DI + Business-level: db, auth, session, caching |
src/)| Directory | Responsibility |
|---|---|
src/features/ |
Feature modules. Each contains api/, services/, data/, and schemas.ts (validation + cache key factories) |
src/routes/ |
TanStack file routes with page components and loaders |
src/lib/ |
Infrastructure: database (db/), env (env/), middlewares |
src/components/ |
Shared UI components: ui/ (atomic), common/, layout/ |
src/server.ts)/api/auth/*, /images/*); everything else proxied to TanStack Startdb, auth, session into contextFor full tech stack details, directory structure, and deployment, see
README.md.