Welcome to the Tome project documentation! This directory contains comprehensive guides for understanding, developing, and maintaining the application.
If you're an AI coding assistant (Claude Code, GitHub Copilot, Cursor, etc.), start here!
- Coding Patterns →
AI_CODING_PATTERNS.md⭐ START HERE - Architecture →
ARCHITECTURE.md- System design, patterns, and code examples - Detailed Patterns →
../.specify/memory/patterns.md- Implementation patterns - Testing Guide →
../__tests__/README.md
AI_CODING_PATTERNS.md is your primary reference - it contains all critical patterns, code styles, and rules including:
- Database factory pattern (THE most important pattern)
- Test isolation patterns
- Code style guidelines
- What to DO and what NOT to do
MongoDB to SQLite migration details
Covers:
- Why we migrated from MongoDB to SQLite
- Why Drizzle ORM over Prisma
- Schema design and constraints
- Repository pattern implementation
- Migration process (6 phases)
- User migration guide
When to read:
- Understanding the current database architecture
- Before working with the database
- When curious about the migration decision
Complete architecture, patterns, and code examples
Covers:
- System overview and technology stack
- Database schemas with detailed field definitions
- Calibre integration and sync mechanism
- Complete API endpoint reference
- Frontend architecture (Next.js App Router)
- Key features (re-reading, progress, streaks, rating sync)
- Development patterns with code examples
- Data flow examples
- File organization
When to read:
- Before making architectural changes
- When adding new features
- When troubleshooting system-level issues
- To understand data relationships
- Looking for code examples
Reusable implementation patterns with working code
Covers:
- 10 production-tested implementation patterns
- Database factory pattern
- Repository pattern examples
- Service layer patterns
- Test isolation patterns
- Complete code examples from the codebase
When to read:
- Implementing similar features
- Need copy-paste ready code examples
- Understanding established patterns
Single source of truth for coding patterns and styles ⭐
Covers:
- Critical database factory pattern (SQLite driver abstraction)
- Test isolation patterns and anti-patterns
- Code style guidelines (TypeScript, React, naming)
- Common imports and database patterns
- What to DO and what NOT to do
- API route patterns
- Typical workflows for common tasks
When to read:
- ALWAYS read this before writing any code
- When unsure about code style
- When adding tests
- When working with databases
- Before suggesting architectural changes
How to write and maintain documentation
Covers:
- Documentation structure and organization
- When to update docs
- Writing standards and best practices
- Documentation maintenance
When to read:
- Before adding or updating documentation
- When documentation feels unclear
- To understand doc organization
Dark mode implementation details
Covers:
- How dark mode is implemented
- Theme switching mechanism
- CSS variable usage
When to read:
- Working on UI theme features
- Troubleshooting dark mode issues
Comprehensive deployment guide
Covers:
- Docker deployment options (GHCR, Docker Compose, build from source)
- Environment variables and configuration
- Volume management and backups
- Database migrations in production
- Production best practices and security
- Monitoring and common issues
When to read:
- Deploying Tome to production
- Setting up Docker containers
- Configuring production environments
- Troubleshooting deployment issues
Database management and operations
Covers:
- Database commands (migrations, backups, restore)
- Data models and schema details
- Backup strategies and maintenance
- Migration system details
- Advanced operations (export, import, querying)
- Best practices
When to read:
- Managing database schema
- Creating backups
- Running migrations
- Understanding data models
- Database troubleshooting
Common issues and solutions
Covers:
- Calibre database issues
- Tome database problems
- Port conflicts
- Docker-specific issues
- Development issues
- Preventive measures
When to read:
- Encountering errors or issues
- Database not found errors
- Migration failures
- Permission problems
- Before deploying to production
Maintenance and cleanup procedures
Covers:
- Database cleanup operations
- Data maintenance tasks
- System housekeeping
When to read:
- Performing database maintenance
- Cleaning up test data
- System administration tasks
Database factory pattern implementation
Covers:
- Why we need both bun:sqlite and better-sqlite3
- Database factory pattern design
- Implementation details and code reduction metrics
- Testing results
When to read:
- Understanding SQLite driver architecture
- Before modifying database connection logic
- When curious about dual-driver approach
Located at: ../__tests__/README.md
Comprehensive testing guide
Covers:
- Test structure (99 tests across 7 files)
- Test isolation best practices
- Database testing with mongodb-memory-server
- Common pitfalls and solutions
When to read:
- Before writing new tests
- When tests are failing
- To understand test patterns
- Read the architecture: Start with
ARCHITECTURE.mdsections 1-3 - Check environment: Review section 8 "Key Configuration Files"
- Run the app: Follow section 12 "Development Workflow"
- Find relevant docs: Use this index to locate documentation
- Read existing patterns: Check
ARCHITECTURE.mdSection 8 or.specify/memory/patterns.md - Make changes: Follow established patterns
- Update docs: If you changed architecture or patterns
- Test: Run
bun testto ensure 99 tests pass
| Task | Documentation |
|---|---|
| Add a new API endpoint | ARCHITECTURE.md Section 4 |
| Add a new database model | ARCHITECTURE.md Section 3 |
| Work with Calibre data | ARCHITECTURE.md Section 3 |
| Add a new page | ARCHITECTURE.md Section 4 |
| Write tests | ../__tests__/README.md |
| Update documentation | DOCUMENTATION_GUIDE.md |
| Deploy to production | DEPLOYMENT.md |
| Manage database | DATABASE.md |
| Fix issues | TROUBLESHOOTING.md |
Understanding these is essential for working on Tome:
| Technology | Purpose | Documentation |
|---|---|---|
| Next.js 14 | Framework (App Router) | ARCHITECTURE.md Section 4 |
| SQLite | Tracking data storage | ADR-001-MONGODB-TO-SQLITE-MIGRATION.md |
| SQLite | Calibre library (read-only) | ARCHITECTURE.md Section 3 |
| Drizzle ORM | Type-safe SQLite ORM | ADR-001-MONGODB-TO-SQLITE-MIGRATION.md |
| Database Factory | SQLite driver abstraction | ARCHITECTURE.md Section 6 |
| Bun | Package manager & runtime | ARCHITECTURE.md Section 2 |
| Repository Pattern | Data access layer | ADR-001-MONGODB-TO-SQLITE-MIGRATION.md |
- Start:
ARCHITECTURE.md- Overview and Sections 1-2 - Understand data:
ARCHITECTURE.md- Section 3 (Database Models) - Learn Calibre:
ARCHITECTURE.md- Section 3 (Calibre Database) - API structure:
ARCHITECTURE.md- Section 4 - Code examples:
ARCHITECTURE.md- Section 8 or.specify/memory/patterns.md - Testing:
../__tests__/README.md
Adding a Feature:
ARCHITECTURE.md(relevant sections).specify/memory/patterns.md(similar examples)../__tests__/README.md(testing patterns)
Fixing a Bug:
ARCHITECTURE.md(understand affected component).specify/memory/patterns.md(check patterns)
Documentation Updates:
DOCUMENTATION_GUIDE.md(standards and structure)
- Start with this index to locate the right document
- Use your editor's search (
Ctrl+ForCmd+F) within documents - Check the Quick Reference for code examples
- Refer to Architecture for design decisions
| Looking for... | Check... |
|---|---|
| "How do I query books?" | .specify/memory/patterns.md |
| "API endpoint structure" | ARCHITECTURE.md Section 4 |
| "Database schema" | ARCHITECTURE.md Section 3 |
| "Calibre sync flow" | ARCHITECTURE.md Section 3 |
| "Component patterns" | .specify/memory/patterns.md |
| "Test examples" | ../__tests__/README.md |
| "Docker deployment" | DEPLOYMENT.md |
| "Database management" | DATABASE.md |
| "Error troubleshooting" | TROUBLESHOOTING.md |
Documentation should evolve with the codebase:
- Architecture changes → Update
ARCHITECTURE.md - New patterns → Add to
.specify/memory/patterns.md - Test changes → Update
../__tests__/README.md - New features → Update relevant sections
See DOCUMENTATION_GUIDE.md for:
- Writing standards
- Structure guidelines
- Update process
- Review checklist
- Check if there's a related doc you missed
- Search for keywords across documentation files
- Ask for clarification (human developers or AI assistants)
- Suggest documentation improvements
If you notice gaps:
- Document the missing information
- Follow patterns in
DOCUMENTATION_GUIDE.md - Submit updates
Use this when making significant changes:
- Read relevant architecture documentation
- Understand existing patterns
- Make your changes following patterns
- Update documentation if architecture changed
- Run tests (
bun test) - Verify documentation accuracy
# View documentation
cat docs/README.md # This file
cat docs/ARCHITECTURE.md # Architecture
cat .specify/memory/patterns.md # Code patterns
# Development
bun install # Install dependencies
bun run dev # Start dev server
bun test # Run tests (99 tests)
bun run build # Build production
# Documentation location
docs/ # All documentation
__tests__/README.md # Test documentation
.claude/instructions.md # Claude Code guidance
.github/copilot-instructions.md # Copilot guidanceLast Updated: 2025-11-27 Documentation Version: 1.2 (Documentation Reorganization) Project: Tome (Book Tracker)
Major Changes in v1.2:
- Added DEPLOYMENT.md for comprehensive deployment guide
- Added DATABASE.md for database management operations
- Added TROUBLESHOOTING.md for common issues and solutions
- Streamlined main README.md to focus on getting started
- Organized documentation into clear user/operations guides