๐ค๐ AI-powered toolkit for generating, editing, and publishing books. Create outlines, chapters, covers, and export EPUB/PDF ready for Amazon KDP. ๐โก๏ธ๐
๐ค๐ AI Book Generator
Status: Complete autonomous book creation pipeline from concept to publication - generating professional manuscripts with AI-powered authoring and design.
Automated book authoring, editing and compilation toolkit.
This repository contains a set of shell scripts and helper tools that together can:
- Pick topics and book titles (AI-assisted)
- Generate detailed outlines
- Generate, extend and edit chapters
- Run optional quality & plagiarism checks
- Produce front/back covers (ImageMagick or AI-assisted where available)
- Assemble a complete manuscript with title pages, Table of Contents, copyright pages,
- Export the final book in EPUB, PDF and other common ebook formats ready for platforms
โจ Key Points
- Designed to use free tools and services where possible. When AI APIs are used, the
- Created the final front/back covers and an author picture manually using the free
- Conducted a proof-of-concept to test whether a high-quality book could be
๐๏ธ Published Books
- The Playful Path: Unlocking Your Child's Potential Through Joyful, Play-Based Learning for Ages 3-8 โ https://a.co/d/hAg2DWe
- The Micro-Influence Advantage: Building Your Niche Brand and Monetizing Your Passion Online โ https://a.co/d/3zwHBZJ
๐ Amazon Links
- The Playful Path โ https://a.co/d/hAg2DWe
- The Micro-Influence Advantage โ https://a.co/d/3zwHBZJ
Everything required to generate and compile a book is included as scripts and helper utilities. Some features require external programs or optional API keys for best results (Gemini, Ollama, Groq, OpenAI). When not available the workflow still works for basic generation and compilation using local tools.
๐ ๏ธ Quick Overview of Main Scripts
compile_book.shโ Combine an outline and chapter files into a manuscript and
optimizedchapterhandler.shโ Provide quality checks and chapter length handling. It
generate_appendices.shโ Generate preface, introduction, dedication, acknowledgments,
multiprovideraisimple.shโ Multi-provider helper andsmartapi_callwrapper.
kdpmarketanalyzer.sh,topicmarketresearch.sh,market_analyzer.pyand
add_animations.shโ Helper to add terminal animations to long-running steps.testextractchapters.shโ Small test harness for chapter extraction logic.migratebookoutputs.shโ Helps organize loose outline files into structured
book_outputs/.
โ๏ธ Prerequisites
Install the following to get full functionality (macOS / Linux):
- Pandoc (required for EPUB/HTML/PDF pipeline)
- A LaTeX distribution (TeX Live, MacTeX) for best PDF output (pdflatex/xelatex/lualatex)
- ImageMagick (
convert/magick) for cover generation and image resizing - Jq (JSON parsing helpers used by AI cover generation code)
- Curl
- Python3 + pip packages: requests, beautifulsoup4 (used by market research tools)
brew install pandoc imagemagick jq
Install MacTeX (large) or use BasicTeX for smaller footprint:
brew install --cask mactex
pip3 install requests beautifulsoup4
๐ Environment Variables / API Keys
The scripts support multiple AI providers. Set the corresponding environment variables to enable them:
GEMINIAPIKEYโ (recommended) Use Gemini for text-generation tasks (outlines,
OPENAIAPIKEYโ Optional, used by some cover-generation and provider fallbacks.GROQAPIKEYโ Optional alternative provider.OLLAMAโ If you run Ollama locally the scripts will try to call it for local
If none of the above keys are present the generator will still run but rely on local tools and the basic ImageMagick cover-generator fallback.
๐ Typical Workflow (High-level)
- Prepare a book outline file in a directory under
book_outputs/or create a new
bookoutline*.md (the scripts offer auto-detection of the most recent book if you omit the path). - Use the multi-provider helpers and
optimizedchapterhandler.shto generate or
generatechapterwithsmartapi helpers are in the multiproviderai_simple.sh script and are used by higher-level generation workflows. - Optionally run
generate_appendices.sh /path/to/bookto auto-create Preface,
GEMINIAPIKEY set for full automation. - Run
./compilebook.sh [bookdirectory] [output_format] [version] [options]to
๐งญ Examples โ Common Commands
# Compile the most recent book in all formats (auto detect): ./compile_book.sh
Compile a specific book directory as EPUB only with a custom author:
./compilebook.sh ./bookoutputs/my-book epub --author "Jane Doe"
Compile a given book as final version, attach a local cover and back cover:
./compilebook.sh ./bookoutputs/my-book all 3 --cover "/path/to/cover.png" --backcover "/path/to/back.png" --isbn "978-1-2345-6789-7"
Generate appendices and extras for a book (requires GEMINIAPIKEY):
./generateappendices.sh ./bookoutputs/my-book
Run a quick provider status and tests using the multi-provider helper:
./multiproviderai_simple.sh status
./multiproviderai_simple.sh test
Run market research for a topic (creates analysis files in research data folder):
./kdpmarketanalyzer.sh "digital minimalism"
๐ Notes on compile_book.sh Options
book_directoryโ Path to a book folder (if omitted the script auto-detects the
book_outputs/). output_formatโ One ofall|epub|pdf|html|markdown|mobi|azw3(defaultall).versionโ Manuscript version selector:1original,2edited,3final (default 3).--author,--cover,--backcover,--isbn,--publisher,--yearโ Set
--generate-coverโ Ask the script to attempt an AI-generated cover (requires
OPENAIAPIKEY or other image API keys and jq), otherwise an ImageMagick fallback Will create a simple cover. --fastโ Skip slow conversions (mobi/azw3) and some post-processing.
When compilation completes an
exports_<TIMESTAMP>/ directory will be created inside the book directory. It typically includes:
- The generated manuscript markdown file (manuscriptfinal*.md)
- Metadata.yaml used for pandoc conversions
book.cssfor ebook styling- Generated
.epub,.pdf, and other requested formats - Used images: cover/back-cover/author-photo/publisher logo
- Create or generate an outline:
bookoutline.mdinbookoutputs/<book>/. - Generate chapter drafts using the chapter handler/smart API calls.
- Run chapter reviews/quality checks and extend chapters to target lengths.
- Generate appendices and extras.
- Create or provide a cover image. If you want to avoid API costs you can use
cover.png, back-cover.png, or pass --cover.
- Run
./compile_book.shto export final manuscript files and ebook formats.
I built this project to test whether a high-quality, KDP-acceptable book could be created end-to-end with AI and free/open tools. The toolkit proved capable: I used It to create, proof and publish two books on Amazon. This repo collects the Automation I used and the market research utilities that helped choose topics. I do not intend to market those books; they were a research project to see what's possible.
๐๏ธ Files of Interest (Quick Map)
compile_book.shโ Main compilation pipeline (manuscript -> epub/pdf/html)optimizedchapterhandler.shโ Extensions, reviews, and quality helpersgenerate_appendices.shโ Creates prefatory and back-matter contentmultiprovideraisimple.shโ Provider selection, smartapi_call, status/testkdpmarketanalyzer.sh,marketanalyzer.py,trendsanalyzer.pyโ Market researchadd_animations.shโ Small helper to add terminal animationsmigratebookoutputs.shโ Organize loose outlines into book directoriestestextractchapters.shโ Test harness for chapter extraction logic- Assets:
cover.png,back-cover.png,author-photo.png(example/placeholder files)
Please ensure that the content you generate and publish follows all legal and platform rules. AI can accelerate content creation but you are responsible for copyright, rights clearance, originality, and any platform-specific policies.
๐ค Contributing & Improvements
If you'd like to contribute improvements (tests, tighter formatting for KDP, better LaTeX templates, or integrations with publishing tools), open an issue or submit a pull request. Small, focused changes that improve reliability or add tests are easiest to accept.
๐ Project Status
Status: โ Production Proven - Two Books Successfully Published on Amazon KDP Tech Stack: Shell scripts, Pandoc, LaTeX, AI providers (Gemini/OpenAI/Ollama), ImageMagick Achievement: Complete AI-assisted authoring pipeline that passes Amazon's quality standards
This toolkit represents a successful proof-of-concept that AI can create publication-quality books. Both generated books passed KDP's strict quality checks and are available for purchase, demonstrating the viability of AI-assisted authoring when properly executed.
Current Achievements
- โ 2 Live Amazon Books - "The Playful Path" and "The Micro-Influence Advantage" published and available
- โ Multi-Provider AI Integration - Gemini, OpenAI, Ollama, Groq support with smart fallbacks
- โ Professional Publishing Pipeline - Outline โ Chapters โ Quality Review โ Format Export โ KDP Upload
- โ Cost-Effective Approach - Primarily free tools with minimal API costs
- โ Quality Assurance - Plagiarism detection, consistency checking, formatting validation
- โ Market Research Tools - KDP analyzer, trend analysis, keyword optimization
- โ Production Formats - EPUB, PDF, MOBI, AZW3 export with professional metadata
Performance Metrics
- Book Generation Time: 3-5 days from outline to published book
- Quality Score: 100% KDP acceptance rate (2/2 books approved)
- Cost Per Book: <$50 (primarily API costs for text generation)
- Format Support: 6+ export formats (EPUB, PDF, MOBI, AZW3, HTML, Markdown)
- Automation Level: 85% automated (manual review and cover design recommended)
2026-2027 Roadmap
Q1 2026 โ Enhanced Quality & Automation
- Advanced fact-checking integration with real-time verification
- Improved continuity analysis for multi-chapter consistency
- Automated grammar and style optimization
- Enhanced plagiarism detection with similarity scoring
- Cross-platform GUI application (Electron/Tauri)
- Book series management and character tracking
- Template marketplace for different genres
- Batch processing for multiple book generation
- Direct Amazon KDP API integration (when available)
- Print-on-demand service connections (IngramSpark, CreateSpace)
- Automated ISBN acquisition and metadata management
- Marketing content generation (blurbs, social posts, ads)
- Multi-modal book creation (images, charts, diagrams)
- Voice-to-book generation with speech recognition
- AI-powered market trend prediction
- Automated competitor analysis and positioning
- Real-time sales analytics and optimization
- AI book marketing agent with A/B testing
- Community platform for AI authors
- Publishing consultancy automation
- Cross-language book translation and localization
Next Steps
For Authors & Creators:
- Study the published book examples for quality benchmarks
- Run market research before committing to a topic
- Start with shorter books (under 100 pages) to learn the workflow
- Focus on niche topics where AI can add genuine value
- Contribute to quality assurance improvements
- Add support for new AI providers and models
- Create specialized templates for technical/educational content
- Develop better error handling and recovery mechanisms
- Analyze the ethical implications of AI-generated content
- Study reader reception and satisfaction metrics
- Research optimal human-AI collaboration workflows
- Evaluate impact on traditional publishing industry
Why This Toolkit Leads AI Publishing?
Proven Results: Not just a proof-of-conceptโactual books earning revenue on Amazon marketplace.
Cost-Effective: Primarily free tools with strategic API usage, making publishing accessible to anyone.
Quality-First: Built-in review processes ensure content meets professional publishing standards.
Ethically Designed: Emphasizes human oversight, originality checking, and responsible AI usage practices.
๐ License
This repo contains example scripts for demonstration and research purposes. Add your own license file at the repository root to declare terms if you plan to publish or share this code widely.
โ๏ธ Contact
If you need clarifications about usage or want to share results from running the toolkit, feel free to open an issue in this repository or reach out in the project channels.
Enjoy exploring what automated tools can build โ responsibly.