Directory Overview
Your Bible follows a clear, organized structure that separates concerns and follows framework conventions.Source Directory (src/)
src/actions/ - Server Actions
Server-side functions that run exclusively on the backend. These actions handle sensitive operations and API calls.
- Purpose
- Usage
- Files
Server actions provide secure backend functionality:
- Authentication: Login, signup, session management
- API Integration: Bible API requests, AI story generation
- Rate Limiting: Check and enforce rate limits
- Data Fetching: Server-side data retrieval
src/components/ - React Components
Organized by feature and purpose for easy navigation and maintenance.
src/components/bible/ - Bible Reading Components
src/components/bible/ - Bible Reading Components
Components for displaying Bible content:
- ChapterDisplay: Renders Bible chapter text
- VerseHighlight: Highlights selected verses
- BibleNavigation: Chapter navigation controls
- TranslationSelector: Bible version dropdown
src/components/collections/ - Collection Management
src/components/collections/ - Collection Management
Components for verse collections feature:
- CollectionList: Display user collections
- CollectionForm: Create/edit collection
- VerseCard: Individual verse display
- AddToCollection: Add verse button/modal
src/components/search/ - Search Functionality
src/components/search/ - Search Functionality
Search interface components:
- SearchBar: Input and controls
- SearchResults: Paginated results display
- SearchFilters: Translation and options
- HighlightedVerse: Results with highlighted terms
src/components/stories/ - Story Management
src/components/stories/ - Story Management
AI story generation interface:
- StoryForm: Story creation parameters
- StoryDisplay: Show generated story
- StoryList: User’s stories dashboard
- StoryComparison: Side-by-side Bible text and story
src/components/forms/ - Form Components
src/components/forms/ - Form Components
Reusable form components with TanStack Form:
- Form wrappers
- Input components
- Validation displays
- Submit handlers
src/components/ui/ - Reusable UI Components
src/components/ui/ - Reusable UI Components
Shadcn/ui components and custom UI primitives:
- Buttons
- Dialogs
- Dropdowns
- Inputs
- Tabs
- Cards
- Tooltips
src/components/skeletons/ - Loading States
src/components/skeletons/ - Loading States
Skeleton screens for loading states:
- DefaultSkeleton: Router-level loading
- ChapterSkeleton: Bible chapter loading
- SearchSkeleton: Search results loading
- ListSkeleton: List view loading
Component Organization: The component directory uses feature-based organization, making it easy to find related components and maintain feature boundaries.
src/routes/ - File-Based Routing
TanStack Router uses file-based routing conventions. Each file represents a route in the application.
__root.tsx
Root Layout ComponentDefines:
- HTML document structure
- Global head tags (meta, links, title)
- Root-level data loading (session)
- Context providers (Convex, Query)
- Shared layout (Header, Toaster)
Route Structure
Common route patterns:
index.tsx- Home page (/)bible.tsx- Bible reading (/bible)search.tsx- Search page (/search)collections.tsx- Collections (/collections)stories.tsx- Stories (/stories)auth/- Auth routes (/auth/*)
Route Features
Route Features
Each route file can export:
component: The React component to renderbeforeLoad: Server-side data loading (like session check)loader: Async data fetching before renderhead: Page-specific meta tags and titleerrorComponent: Error boundary for the route
src/hooks/ - Custom React Hooks
Reusable React hooks for common functionality:
- useBible: Bible data fetching and caching
- useCollections: Collection management operations
- useAuth: Authentication state and helpers
- useNotes: Notes CRUD operations
- useStories: Story generation and management
src/lib/ - Utility Libraries
Helper functions and utility modules:
utils.ts: Common utilities (className merging, formatters)api.ts: API client configuration (Axios instances)constants.ts: Application-wide constantshelpers.ts: Pure helper functions
src/queries/ - TanStack Query Configurations
Pre-configured query and mutation options:
src/schemas/ - Zod Validation Schemas
Type-safe validation schemas using Zod:
auth.ts: Login/signup form validationcollection.ts: Collection creation validationstory.ts: Story generation parameterssearch.ts: Search query validation
src/server/ - Server-Side Utilities
Server-only utility functions:
- Configuration helpers
- Server-side data transformations
- Backend integrations
src/styles/ - Global Styles
Global CSS and Tailwind configuration:
app.css: Global styles, Tailwind directives, custom CSS- Font imports
- CSS variables
- Theme configurations
src/types/ - TypeScript Type Definitions
Shared TypeScript types and interfaces:
- API response types: Bible API, Gemini AI
- Database types: Convex schema types
- Component prop types: Shared interfaces
- Utility types: Generic type helpers
Convex Backend (convex/)
The Convex directory contains backend logic and database schema.
schema.ts
Database Schema DefinitionDefines tables and their structure:
- Collections table
- Notes table
- Stories table
- Verse collections table
*.ts Files
Queries and MutationsEach file exports:
- Queries: Read data from database
- Mutations: Write/update/delete data
collections.ts- Collection CRUDnotes.ts- Notes operationsstories.ts- Story management
Convex File Structure
Convex File Structure
Configuration Files
- vite.config.ts
- tsconfig.json
- package.json
Vite build configuration:
- Development server on port 3000
- TanStack Start plugin configured for Vercel
- Path aliases via tsConfigPaths
- SSR configuration for external packages
Code Organization Patterns
Feature-Based Organization
Components organized by feature rather than type:Makes it easy to find and maintain related code.
Colocation
Related files are kept together:
- Component and its styles
- Hooks with their components
- Types with their modules
Path Aliases
Use Cleaner imports and easier refactoring.
@/ prefix for absolute imports:Separation of Concerns
Clear boundaries between:
- Frontend: Components, hooks, UI
- Backend: Actions, Convex functions
- Shared: Types, schemas, utilities
Import Patterns
Recommended Import Order
Recommended Import Order