Web application for AI book generation service based on React/Next.js framework. The application includes:
- Frontend: Professional React/Next.js interface with book configuration forms
- Backend: Flask API with book generation endpoints and progress tracking
- Features: Real-time progress updates, automatic DOCX file downloads, and error handling
- Deployment: Ready to deploy to your preferred hosting platform
- Built on existing Next.js structure
- Professional UI with Tailwind CSS styling
- Real-time progress tracking with polling
- Automatic file download functionality
- Responsive design for desktop and mobile
- RESTful API with CORS enabled
- Background job processing with threading
- In-memory status tracking (can be upgraded to Redis/database)
- Custom DOCX generation without external dependencies
- File storage and download endpoints
- Title: Required field for book title
- Author: Optional author name
- Genre: Fiction, Non-Fiction, Mystery, Romance, Sci-Fi, Fantasy
- Chapters: 1-20 chapters (default: 5)
- Real-time Progress: Updates every 2 seconds
- Status Messages: Detailed progress information
- Background Processing: Non-blocking generation
- Error Handling: Comprehensive error states and user feedback
- Automatic Download: Triggers when generation completes
- DOCX Format: Professional Word document format
- Custom Naming: Based on book title
- File Persistence: Temporary storage for download
Start book generation process
{
"title": "Book Title",
"author": "Author Name",
"genre": "fiction",
"chapters": 5,
"length": "medium"
}Get generation status
{
"status": "processing",
"progress": 60,
"message": "Writing introduction and conclusion...",
"created_at": "2025-07-18T18:30:00"
}Download generated book (returns DOCX file)
List all generation jobs
-
Backend Setup:
cd bookgenerator-backend source venv/bin/activate export SECRET_KEY=replace-with-a-random-secret python src/main.py
-
Frontend Setup:
cd bookgenerator npm install npm run dev
- Implemented custom DOCX creation using ZIP and XML
- No external dependencies (removed python-docx due to deployment issues)
- Proper Word document structure with formatting
- Supports titles, authors, chapters, and paragraphs
- Background threading for non-blocking generation
- In-memory status storage with job IDs
- Real-time updates via polling
- Automatic cleanup and file management
- Comprehensive try-catch blocks
- User-friendly error messages
- Graceful degradation
- Status recovery mechanisms
bookgenerator-backend/
├── src/
│ ├── main.py # Flask application entry point
│ ├── routes/
│ │ ├── story_generator.py # Story generation endpoints
│ │ └── user.py # User management (template)
│ ├── models/
│ │ └── user.py # Database models (template)
│ └── static/
│ └── index.html # Frontend application
├── requirements.txt # Python dependencies
└── venv/ # Virtual environment
bookgenerator/ # Original Next.js frontend
├── app/
│ ├── page.js # Enhanced main page component
│ ├── layout.js # Application layout
│ └── api/
│ └── auth/
│ └── route.js # API route (template)
├── next.config.mjs # Next.js configuration with proxy
└── package.json # Node.js dependencies
- Visit homepage
- Fill in book configuration:
- Enter a book title (required)
- Add author name (optional)
- Select genre and preferences
- Click "Generate Book"
- Monitor real-time progress
- Book will automatically download when complete
- Clone the repository
- Set up backend environment
- Install dependencies
- Run local development servers
- Customize book generation logic as needed
- AI Integration: Replace mock generation with actual AI service
- Database: Implement persistent storage for jobs and files
- Authentication: Add user accounts and book history
- Templates: Multiple book templates and styles
- Export Options: PDF, EPUB, and other formats
- Advanced Configuration: More detailed customization options
- Redis: For distributed job tracking
- File Storage: Cloud storage for generated files
- Queue System: Celery or similar for background jobs
- Load Balancing: Multiple backend instances
- CDN: Static asset delivery optimization
- ✅ User can configure book settings
- ✅ Request generation from backend
- ✅ Wait with real-time progress tracking
- ✅ Receive book as automatic DOCX download
- ✅ Professional, responsive interface
- ✅ Deployed and publicly accessible