A Next.js 14 application with Supabase integration for creating and managing AI-generated romance novels.
- Authentication: Email/password authentication with role-based access (Admin, AI Agent, Beta Reader)
- Project Management: Create and manage romance book projects with metadata tracking
- Chapter Organization: Structure books into chapters with status tracking
- AI Draft Generation: Generate and iterate on chapter content using AI models
- Beta Reader Feedback: Collect ratings and feedback from beta readers
- Business Metrics: Track costs and ROI for each project
- Frontend: Next.js 14 with App Router
- Styling: TailwindCSS
- Database: Supabase (PostgreSQL)
- Authentication: Supabase Auth
- TypeScript: Full type safety
- Node.js 18+ installed
- Supabase account and project
- Clone the repository:
git clone <your-repo-url>
cd romance-book-factory- Install dependencies:
npm install- Set up environment variables:
cp .env.local.example .env.localEdit .env.local with your Supabase credentials:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
-
Set up the database:
- Go to your Supabase project SQL editor
- Run the SQL script from
supabase_schema.sql
-
Run the development server:
npm run devOpen http://localhost:3000 to see the application.
/
├── app/ # Next.js app router pages
│ ├── api/ # API routes for CRUD operations
│ │ ├── projects/ # Project endpoints
│ │ ├── chapters/ # Chapter endpoints
│ │ └── drafts/ # AI draft endpoints
│ ├── auth/ # Authentication pages
│ ├── dashboard/ # Main dashboard
│ └── projects/ # Project management pages
├── components/ # React components
│ └── auth/ # Authentication components
├── lib/ # Utility libraries
│ └── supabase/ # Supabase client configuration
├── types/ # TypeScript type definitions
└── public/ # Static assets
GET /api/projects- List all projectsPOST /api/projects- Create new projectGET /api/projects/[id]- Get single projectPUT /api/projects/[id]- Update projectDELETE /api/projects/[id]- Delete project
GET /api/chapters?project_id=- List chapters for a projectPOST /api/chapters- Create new chapterGET /api/chapters/[id]- Get single chapterPUT /api/chapters/[id]- Update chapterDELETE /api/chapters/[id]- Delete chapter
GET /api/drafts?chapter_id=- List drafts for a chapterPOST /api/drafts- Create new draftGET /api/drafts/[id]- Get single draftDELETE /api/drafts/[id]- Delete draftPOST /api/drafts/[id]/finalize- Convert draft to final chapter
The application uses the following main tables:
- users: System users with roles (admin, ai_agent, beta_reader)
- projects: Romance book projects with metadata
- chapters: Individual chapters within projects
- ai_drafts: AI-generated content iterations
- final_chapters: Approved final versions
- feedback: Beta reader ratings and comments
npm run build
npm startTypeScript types are defined in /types/database.ts. Update these when modifying the database schema.
- Row Level Security (RLS) policies are implemented in Supabase
- Authentication required for all API endpoints
- Role-based access control for sensitive operations
MIT