Skip to content

btallitsch/chapterflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“– ChapterFlow โ€” Novel Writing Web App

Stack: React 18 ยท Vite ยท TipTap ยท dnd-kit ยท Tailwind CSS ยท Supabase ยท Vercel

A polished, production-grade novel writing application. Manage multiple novel projects, write with a rich text editor, plan scenes on a corkboard, export your manuscript, and sync everything to the cloud.

โœจ Features

  • Authentication โ€” Email/password sign up, login, and password reset via Supabase Auth
  • Cloud Sync โ€” All projects, chapters, and scenes sync to Supabase with a 1-second debounced autosave
  • Project Management โ€” Create and manage multiple novel projects with title, author, genre, synopsis, and accent color
  • Chapter Management โ€” Add, edit, delete, and drag-to-reorder chapters
  • Rich Text Editor โ€” TipTap-powered editor with formatting toolbar (bold, italic, headings, lists, blockquote, alignment, highlight)
  • Notes Panel โ€” Per-chapter notes/outline panel that slides in alongside the editor
  • Word Count Tracking โ€” Live word count, reading time estimate, per-chapter and per-project totals
  • Scene Board โ€” Drag-and-drop scene cards per chapter (like Scrivener's corkboard)
  • Export โ€” PDF (with title page, TOC, page numbers), HTML/Word, and Plain Text
  • Autosave โ€” Persists to both localStorage (fast) and Supabase (cloud)
  • Search & Filter โ€” Search chapter content/notes, filter by status
  • Dark Mode โ€” Full dark/light mode toggle
  • Responsive โ€” Collapsible sidebar, mobile-friendly layout

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • A Supabase account (free tier is fine)
  • A Vercel account for deployment

1. Clone and install

git clone https://github.com/your-username/chapterflow.git
cd chapterflow
npm install

2. Set up Supabase

In your Supabase project, go to SQL Editor and run:

-- PROJECTS
create table public.projects (
  id          uuid primary key,
  user_id     uuid references auth.users not null,
  title       text not null,
  author      text,
  genre       text,
  synopsis    text,
  cover_color text default '#d4a853',
  created_at  timestamptz default now(),
  updated_at  timestamptz default now()
);

-- CHAPTERS
create table public.chapters (
  id          uuid primary key,
  project_id  uuid references public.projects(id) on delete cascade,
  user_id     uuid references auth.users not null,
  title       text not null,
  content     text,
  notes       text,
  status      text default 'draft',
  word_count  integer default 0,
  "order"     integer default 0,
  created_at  timestamptz default now(),
  updated_at  timestamptz default now()
);

-- SCENES
create table public.scenes (
  id          uuid primary key,
  chapter_id  uuid references public.chapters(id) on delete cascade,
  user_id     uuid references auth.users not null,
  title       text not null,
  description text,
  color       text,
  "order"     integer default 0
);

-- Row Level Security
alter table public.projects enable row level security;
alter table public.chapters enable row level security;
alter table public.scenes   enable row level security;

create policy "Users manage own projects"
  on public.projects for all using (auth.uid() = user_id);

create policy "Users manage own chapters"
  on public.chapters for all using (auth.uid() = user_id);

create policy "Users manage own scenes"
  on public.scenes for all using (auth.uid() = user_id);

Then go to Authentication โ†’ URL Configuration and add your allowed redirect URLs:

  • http://localhost:5173 (development)
  • https://your-app.vercel.app (production)

3. Add environment variables

Create a .env.local file in the project root (never commit this):

VITE_SUPABASE_URL=https://your-project-id.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key-here

Get these values from your Supabase dashboard under Settings โ†’ API.

4. Run locally

npm run dev

Open http://localhost:5173.


๐ŸŒ Deploying to Vercel

  1. Push your repo to GitHub
  2. Import the project in Vercel
  3. Go to Project Settings โ†’ Environment Variables and add:
    • VITE_SUPABASE_URL
    • VITE_SUPABASE_ANON_KEY
    • Set both for Production, Preview, and Development
  4. Deploy โ€” Vercel auto-deploys on every push to main

Vite environment variables must be prefixed with VITE_ to be available in the browser bundle.


๐Ÿ›  Tech Stack

Layer Technology
Framework React 18 + Vite
Auth & Database Supabase
State React Context + useReducer
Rich Text TipTap 2
Drag & Drop @dnd-kit
Styling Tailwind CSS
Icons Lucide React
Export (PDF) jsPDF
Local Persistence localStorage
Fonts Playfair Display, Crimson Text, Courier Prime
Hosting Vercel

๐Ÿ“ Project Structure

chapterflow/
โ”œโ”€โ”€ .env.local                      # Your Supabase keys (never commit)
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ vite.config.js
โ”œโ”€โ”€ tailwind.config.js
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ App.jsx                     # Root component, auth gate, sync wiring
    โ”œโ”€โ”€ main.jsx
    โ”œโ”€โ”€ index.css                   # Global styles + TipTap styles
    โ”œโ”€โ”€ lib/
    โ”‚   โ””โ”€โ”€ supabase.js             # Supabase client instance
    โ”œโ”€โ”€ context/
    โ”‚   โ””โ”€โ”€ AppContext.jsx          # Global state (projects, user, UI)
    โ”œโ”€โ”€ hooks/
    โ”‚   โ””โ”€โ”€ useSupabaseSync.js      # Load from + debounced save to Supabase
    โ”œโ”€โ”€ utils/
    โ”‚   โ”œโ”€โ”€ wordCount.js            # Word counting & text utilities
    โ”‚   โ””โ”€โ”€ exportUtils.js         # PDF, HTML, TXT export logic
    โ””โ”€โ”€ components/
        โ”œโ”€โ”€ Auth/
        โ”‚   โ””โ”€โ”€ AuthScreen.jsx      # Login, signup, password reset UI
        โ”œโ”€โ”€ Layout/
        โ”‚   โ”œโ”€โ”€ Sidebar.jsx         # Navigation sidebar with sign out
        โ”‚   โ””โ”€โ”€ Header.jsx          # Breadcrumb & autosave indicator
        โ”œโ”€โ”€ Projects/
        โ”‚   โ”œโ”€โ”€ ProjectDashboard.jsx
        โ”‚   โ”œโ”€โ”€ ProjectCard.jsx
        โ”‚   โ””โ”€โ”€ CreateProjectModal.jsx
        โ”œโ”€โ”€ Chapters/
        โ”‚   โ”œโ”€โ”€ ChapterList.jsx     # Sortable chapter list
        โ”‚   โ”œโ”€โ”€ ChapterItem.jsx     # Draggable chapter row
        โ”‚   โ””โ”€โ”€ ChapterEditor.jsx  # Editor + notes panel
        โ”œโ”€โ”€ Editor/
        โ”‚   โ””โ”€โ”€ RichTextEditor.jsx  # TipTap editor with toolbar
        โ”œโ”€โ”€ Scenes/
        โ”‚   โ””โ”€โ”€ SceneBoard.jsx      # Corkboard scene card organizer
        โ”œโ”€โ”€ Export/
        โ”‚   โ””โ”€โ”€ ExportModal.jsx     # PDF / HTML / TXT export
        โ””โ”€โ”€ UI/
            โ”œโ”€โ”€ Button.jsx
            โ”œโ”€โ”€ Modal.jsx
            โ”œโ”€โ”€ Badge.jsx
            โ”œโ”€โ”€ SearchBar.jsx
            โ””โ”€โ”€ Notifications.jsx

๐Ÿ“ Data Model

Project {
  id, title, author, genre, synopsis, coverColor,
  chapters: Chapter[],
  createdAt, updatedAt
}

Chapter {
  id, title, content (HTML), notes (HTML),
  status, wordCount, order,
  scenes: Scene[],
  createdAt, updatedAt
}

Scene {
  id, title, description, color, order
}

Data is stored in Supabase (source of truth) and mirrored to localStorage for fast initial load and offline resilience.


๐Ÿ” Auth Flow

  1. User lands on app โ†’ supabase.auth.getSession() checks for an existing session
  2. No session โ†’ AuthScreen renders (login / signup / reset)
  3. On login โ†’ session stored by Supabase client automatically
  4. onAuthStateChange listener keeps the app in sync with token refresh and sign out
  5. On sign out โ†’ state cleared, user returned to AuthScreen

๐ŸŽจ Design

The app uses a Literary Noir aesthetic โ€” deep slate backgrounds, warm amber accents, Playfair Display headings, and Crimson Text for body content. The full editor experience is distraction-free with an optional slide-in notes panel.


๐Ÿ”ฎ Future Enhancements

  • Deletion sync to Supabase (currently handled locally only)
  • Version snapshots / chapter history with rollback
  • AI writing suggestions
  • Collaboration / shared projects
  • PWA offline support
  • DOCX export
  • Chapter templates

๐Ÿ“„ License

MIT

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors