How envoyx/envoy-mindpalace works
1. Overall shape
- This is a full-stack TanStack app built around file-based routing in src/routes, with both UI routes and API routes in the same repository.
- It mixes static/content-driven pages, database-backed features, authenticated dashboard/admin tooling, AI chat endpoints, and media upload workflows.
2. Routing and layout boundaries
- src/router.tsx, src/routeTree.gen.ts, and src/routes/__root.tsx define the app shell.
- Route groups such as _general, _auth, _chat, and dashboard separate public pages, auth flows, chat experiences, and protected product/admin areas.
- The root layout likely owns global providers, nav, theme, and shared error/pending handling via components like DefaultErrorComponent and DefaultPendingComponent.
3. Public content and blog system
- Blog/article content is source-managed in src/blog as markdown files and described by src/collections/*.ts.
- content-collections.ts plus .content-collections/generated/* indicate build-time generation of typed content indexes and collection accessors.
- Public content routes like src/routes/blog/$slug.index.tsx and src/routes/article/$slug.tsx render this generated content rather than querying the database.
4. Database layer and Prisma
- Persistent application data is modeled with Prisma in prisma/schema.prisma, with generated client code under src/generated/prisma.
- The schema supports multiple domains: users, auth sessions/accounts, posts/comments/likes, albums/images, chats/messages, follows, tasks/task lists, and Quran tracking.
- src/db.ts and src/lib/db.ts are the likely DB access entry points used by data-layer modules in src/data/*.
5. Feature-oriented data layer
- src/data/* is the main server-side domain layer, separating route components from database and service logic.
- Modules such as blog.ts, post.ts, album.ts, image.ts, user.ts, session.ts, follow.ts, and task-tracker.ts organize CRUD and query logic by feature.
- src/data/query-options/* suggests TanStack Query-style query definitions are centralized for reuse across pages and dashboards.
6. Authentication and route protection
- Authentication is split between src/lib/auth.ts, src/lib/auth-client.ts, and middleware in src/middlewares/auth.ts.
- src/routes/_auth/* handles login flows, while dashboard and other protected routes likely depend on middleware or server checks.
- The Prisma models for Session, Account, Verification, and User imply a full auth system with persisted sessions and external provider accounts.
7. Dashboard and admin surface
- src/routes/dashboard/* is a large internal workspace for managing blog posts, images, albums, profile/settings, task tracking, and admin views.
- Components under src/components/web/dashboard, src/components/web/admin, src/components/web/image, and src/components/web/album are the UI layer for those operations.
- The dashboard appears to be the primary “back office” for editing content and managing platform data stored in Prisma.
8. AI chat subsystem
- The _chat route group and src/routes/api/chat-gemini, chat-groq, and chat-openrouter expose chat experiences backed by different model providers.
- src/data/chat-ai.ts and components like src/components/ai-elements/* indicate a reusable chat UI coupled to provider-specific server routes.
- The path structure under _chat/chat/_chatbox suggests per-chat or per-adapter routing, with provider selection as an architectural boundary.
9. Media upload and image handling
- Upload and media management run through src/server/uploadthing.ts, src/server/uploadthing.action.ts, src/server/utapi.ts, and src/utils/uploadthing.ts.
- Routes such as src/routes/api/uploadthing.ts, src/routes/api/proxy-image.ts, and dashboard image pages coordinate upload, proxying, import, and album assignment.
- Image-related UI is split across dialogs, dropzones, galleries, lightboxes, and bulk-edit tools, showing that media is a first-class domain.
10. State, query, and client-side interaction
- src/components/web/query-provider.tsx plus src/data/query-options/* suggest TanStack Query is used for client/server data synchronization.
- Local interaction state is handled with TanStack Store in src/store/* for UI concerns like sidebar, blog editor, image upload, photo gallery, and profile settings.
- This separates durable server data from ephemeral client state, which is important for understanding render/update flows.
11. Shared UI system
- src/components/ui/* is a reusable design-system layer, likely built from shadcn-style primitives on top of Tailwind CSS.
- Feature components in src/components/web/* compose those primitives into app-specific experiences: nav, sidebar, cards, dialogs, markdown rendering, comments, and profile flows.
- src/lib/theme-provider.tsx and src/components/web/theme-toggle.tsx indicate theme state is handled globally at the client boundary.
12. Supporting infrastructure and deployment
- The app is built with Vite, TanStack Router, TanStack Query, Prisma, Tailwind CSS, and is configured for Netlify deployment via netlify.toml.
- Validation and typed configuration are centralized in src/schemas/* and src/env.ts, while utility code lives in src/utils/* and src/lib/*.
- For an architecture diagram, the key external integrations to show are the database, auth providers/sessions, upload service, AI model providers, and the Netlify-hosted app/API surface.
Main entry points: dashboard/route.tsx Dashboard Shell · blog.ts Domain Data · __root.tsx Root Layout · _general/route.tsx General Routes
Components 23
App Shell
Routing, providers, and global layout boundaries.
- Router · App router entry and route registration.
src/router.tsx - Root Layout · Global app shell, providers, and shared boundaries.
src/routes/__root.tsx
Public Content
Public pages, blog/article rendering, and shared content presentation.
- General Routes · Public site routes for content and profiles.
src/routes/_general/route.tsx - Blog Index · Public blog listing page.
src/routes/_general/blog.index.tsx - Blog Post · Rendered blog article by slug.
src/routes/blog/$slug.index.tsx - Article Page · Public article/content route.
src/routes/article/$slug.tsx - Collections · Collection definitions for generated markdown content.
content-collections.ts - Blog MD · Source-managed blog articles.
src/blog/announcing-tanstack-form-v1.md
Dashboard
Protected back-office workspace for managing app data.
- Dashboard Shell · Protected dashboard layout and navigation boundary.
src/routes/dashboard/route.tsx - Dashboard Home · Main internal workspace landing page.
src/routes/dashboard/index.tsx - Blog Admin · Blog management and editor routes.
src/routes/dashboard/blog/index.tsx - Image Admin · Image management and upload routes.
src/routes/dashboard/images/index.tsx - Album Admin · Album management routes.
src/routes/dashboard/albums/index.tsx
AI Chat
Chat routes, provider adapters, and shared chat UI.
- Chat Routes · Chat experience boundary with nested adapters.
src/routes/_chat/chat/index.tsx - Chat APIs · Provider-specific chat endpoints.
src/routes/api/chat-gemini/route.ts - Chat UI · Reusable chat conversation and input components.
src/components/ai-elements/Chat.tsx
Data Layer
Domain services, persistence, and generated client access.
- DB Client · Database access entry point.
src/db.ts - Prisma Schema · Persistence schema for users, content, media, chat, and tasks.
prisma/schema.prisma - Domain Data · Feature-oriented server-side data modules.
src/data/blog.ts - Auth · Authentication and session integration.
src/lib/auth.ts - Uploads · UploadThing/UT API integration for media workflows.
src/server/uploadthing.ts
Shared UI
Reusable components, stores, and client-side interaction primitives.
- Query State · Client query and store coordination.
src/components/web/query-provider.tsx - Web UI · Feature UI built on shared primitives.
src/components/web/navbar.tsx
Connections 27
- Router → Root Layout: loads · Router bootstraps the root layout and nested routes.
- Root Layout → General Routes: hosts · Root layout provides the public route group.
- Root Layout → Dashboard Shell: hosts · Root layout includes protected dashboard boundaries.
- Root Layout → Chat Routes: hosts · Root layout includes nested chat flows.
- General Routes → Blog Index: routes · Public blog listing is part of the general route group.
- General Routes → Blog Post: routes · General routes render individual blog posts.
- General Routes → Article Page: routes · General routes render article pages.
- Blog Index → Collections: reads · Blog listing is driven by generated content collections.
- Blog Post → Blog MD: renders · Blog slug page renders markdown-backed content.
- Article Page → Collections: reads · Article pages rely on content collection metadata.
- Dashboard Shell → Dashboard Home: contains · Dashboard shell contains workspace entry pages.
- Dashboard Shell → Blog Admin: contains · Dashboard shell exposes blog management.
- Dashboard Shell → Image Admin: contains · Dashboard shell exposes image management.
- Dashboard Shell → Album Admin: contains · Dashboard shell exposes album management.
- Blog Admin → Domain Data: uses · Blog admin relies on domain data services.
- Image Admin → Uploads: uploads · Image admin coordinates upload workflows.
- Album Admin → Domain Data: uses · Album admin uses feature data services.
- Chat Routes → Chat UI: composes · Chat routes compose reusable chat UI.
- Chat Routes → Chat APIs: calls · Chat experiences connect to provider API routes.
- Chat APIs → Domain Data: uses · Chat endpoints may persist or query app data.
- Domain Data → DB Client: queries · Feature services access the shared database client.
- DB Client → Prisma Schema: generated from · Database client is generated from Prisma schema.
- Auth → DB Client: stores · Auth persists sessions and accounts through the database.
- Uploads → DB Client: records · Upload workflows persist media metadata in the database.
- Query State → Web UI: supports · Client state feeds interactive web components.
- Web UI → Domain Data: queries · Feature UI is backed by domain services and queries.
- Web UI → Auth: guards · Some UI surfaces depend on authenticated user state.