This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Install dependencies
bundle install
# Install JavaScript dependencies
yarn install
# Setup database
rake db:setup # Creates and seeds the database
rake db:migrate # Apply all pending migrations# Start the Rails server
rails server
# Or
rails s
# Start Sidekiq for background jobs
bundle exec sidekiq
# Start the development server with both web and worker processes
RAILS_GROUPS=web,worker rails server# Run all tests
rails test
# Run a specific test file
rails test path/to/test.rb
# Run specific test
rails test path/to/test.rb:LINE_NUMBER# Reset database (CAUTION: Destroys all data)
rake db:reset
# Migrate database
rake db:migrate
# Rollback last migration
rake db:rollback# Compile assets
rails assets:precompile# Run in production mode
RAILS_ENV=production rails serverNotebook.ai is a Rails application for writers and roleplayers to create and manage fictional universes and their components. The application follows standard Rails MVC architecture with some specific design patterns.
-
Content Types: The application revolves around different content types like Universe, Character, Location, etc. Each represents a different entity within a user's fictional world.
-
Content Pages: All content types inherit from a shared ContentPage concern, which provides common functionality like attributes, privacy settings, and image uploads.
-
Universes: The top-level organizational unit. Users create universes and add various content types within them.
-
Attributes System: The application uses a flexible attributes system to store custom fields for each content type, allowing for extensibility without schema changes.
-
Privacy & Sharing: Content can be private, public, or shared with specific collaborators.
- Universe: The top-level container for all world-building elements
- Character, Location, Item: Core content types that are available to all users
- Premium Content Types: Many additional content types (Creature, Planet, Religion, etc.) available to premium users
BelongsToUniverse: Associates content with universesIsContentPage: Provides shared content page functionalityHasAttributes: Handles dynamic attributes for content typesHasPrivacy: Manages content privacy settingsHasImageUploads: Handles image attachment functionalityContentPage: Base behavior for all content pages
- Sidekiq is used for background job processing
- Document analysis, exports, and other intensive tasks run asynchronously
- Users create universes to contain their fictional worlds
- Within universes, users create various content types (characters, locations, etc.)
- Content types can be linked together with relationships (e.g., a character can be linked to locations)
- Users can collaborate on universes, allowing multiple people to contribute to the same world
Beyond the standard Rails structure, notable directories include:
app/models/page_types/: Contains all content type modelsapp/models/page_groupers/: Contains relationship models between content typesconfig/attributes/: Configuration for content type attributesapp/authorizers/: Authorization logic for content access
config/initializers/content_types.rb: Defines all available content typesapp/models/content_page.rb: Base functionality for all content pagesapp/controllers/content_controller.rb: Base controller for all content types
The application uses a content type system with these types of pages:
- Universe (top-level container)
- Character, Location, Item (core types)
- Many premium content types like Creature, Planet, Religion, etc.
Creating a new content type requires following the process in docs/content_types.md.