wesleyscholl
book-generator
Shell

๐Ÿค–๐Ÿ“š AI-powered toolkit for generating, editing, and publishing books. Create outlines, chapters, covers, and export EPUB/PDF ready for Amazon KDP. ๐Ÿ“–โžก๏ธ๐ŸŒ

Last updated Aug 5, 2026
44
Stars
12
Forks
0
Issues
0
Stars/day
Attention Score
53
Language breakdown
Shell 91.2%
Python 8.8%
โ–ธ Files click to expand
README

๐Ÿค–๐Ÿ“š AI Book Generator

Status: Complete autonomous book creation pipeline from concept to publication - generating professional manuscripts with AI-powered authoring and design.

The Playful Path The Micro-Influence Advantage

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,
epilogue/appendices/acknowledgements/etc.
  • Export the final book in EPUB, PDF and other common ebook formats ready for platforms
such as Amazon KDP.

โœจ Key Points

  • Designed to use free tools and services where possible. When AI APIs are used, the
project supports Gemini (recommended), Ollama, Groq and OpenAI as configurable providers via environment variables. If you do not set API keys the scripts will fall back to purely local tools (ImageMagick, Pandoc, TeX) for compilation and simple auto-generated covers.
  • Created the final front/back covers and an author picture manually using the free
ChatGPT web UI (no paid API) to avoid API costs for the cover artwork.
  • Conducted a proof-of-concept to test whether a high-quality book could be
created by AI and pass Amazon Kindle Direct Publishing quality checks. I used this toolkit to generate and publish two books which passed KDP checks and are live on Amazon. Those books were not marketed โ€” this was an experiment.

๐Ÿ—‚๏ธ 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 The Micro-Influence Advantage

  • The Playful Path โ€” https://a.co/d/hAg2DWe
  • The Micro-Influence Advantage โ€” https://a.co/d/3zwHBZJ
๐Ÿ“Œ Status
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
export EPUB/PDF/MOBI/AZW3/Markdown/HTML. Lots of options (cover, backcover, author, ISBN, publisher, version selection, generate cover, fast mode). See the script usage text for full CLI reference.
  • optimizedchapterhandler.sh โ€” Provide quality checks and chapter length handling. It
Can extend chapters, review for quality, and rewrite chapters when needed.
  • generate_appendices.sh โ€” Generate preface, introduction, dedication, acknowledgments,
epilogue, glossary, discussion guide, further reading, and appendices using an AI provider (Gemini recommended). It extracts context from your outline and sample chapter to produce well-formatted markdown sections.
  • multiprovideraisimple.sh โ€” Multi-provider helper and smartapi_call wrapper.
It detects available AI providers (Gemini, Groq, Ollama, OpenAI) and cycles/falls back as needed. Also includes provider status and quick tests.
  • kdpmarketanalyzer.sh, topicmarketresearch.sh, market_analyzer.py and
other market-research tools โ€” A suite for free-market analysis and KDP opportunity scoring (Amazon scraping, trend guidance, keyword/title suggestions). Useful for validating topic choices before writing.
  • 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 directories under 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)
On macOS you can quickly install essentials via Homebrew:
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,
chapters, appendices, references). The code targets Gemini models and includes rate-limit handling.
  • 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
LLM generations.

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
directory for your book. The outline file should be named like bookoutline*.md (the scripts offer auto-detection of the most recent book if you omit the path).
  • Use the multi-provider helpers and optimizedchapterhandler.sh to generate or
improve chapters. The generatechapterwithsmartapi helpers are in the multiproviderai_simple.sh script and are used by higher-level generation workflows.
  • Optionally run generate_appendices.sh /path/to/book to auto-create Preface,
Introduction, Dedication, Acknowledgments, Glossary, Appendices, etc. This Requires GEMINIAPIKEY set for full automation.
  • Run ./compilebook.sh [bookdirectory] [output_format] [version] [options] to
assemble chapters, generate metadata, include cover/back cover and export EPUB/PDF/HTML/Markdown formats.

๐Ÿงญ 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
Most recent directory under book_outputs/).
  • output_format โ€” One of all|epub|pdf|html|markdown|mobi|azw3 (default all).
  • version โ€” Manuscript version selector: 1 original, 2 edited, 3 final (default 3).
  • --author, --cover, --backcover, --isbn, --publisher, --year โ€” Set
Metadata used during compilation.
  • --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.
๐Ÿ“ฆ Output Layout
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.css for ebook styling
  • Generated .epub, .pdf, and other requested formats
  • Used images: cover/back-cover/author-photo/publisher logo
๐Ÿ” Repro Workflow (Concise)
  • Create or generate an outline: bookoutline.md in bookoutputs/<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
Free ChatGPT web UI (manual) to design cover/back/author photos and drop them into the script directory as cover.png, back-cover.png, or pass --cover.
  • Run ./compile_book.sh to export final manuscript files and ebook formats.
๐Ÿ’ก Why I Built This (Short Personal Note)
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 helpers
  • generate_appendices.sh โ€” Creates prefatory and back-matter content
  • multiprovideraisimple.sh โ€” Provider selection, smartapi_call, status/test
  • kdpmarketanalyzer.sh, marketanalyzer.py, trendsanalyzer.py โ€” Market research
  • add_animations.sh โ€” Small helper to add terminal animations
  • migratebookoutputs.sh โ€” Organize loose outlines into book directories
  • testextractchapters.sh โ€” Test harness for chapter extraction logic
  • Assets: cover.png, back-cover.png, author-photo.png (example/placeholder files)
โš–๏ธ Ethics & Legal
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
Q2 2026 โ€“ User Experience & Scalability
  • Cross-platform GUI application (Electron/Tauri)
  • Book series management and character tracking
  • Template marketplace for different genres
  • Batch processing for multiple book generation
Q3 2026 โ€“ Publishing Ecosystem Integration
  • 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)
Q4 2026 โ€“ Advanced AI Features
  • Multi-modal book creation (images, charts, diagrams)
  • Voice-to-book generation with speech recognition
  • AI-powered market trend prediction
  • Automated competitor analysis and positioning
2027+ โ€“ Publishing Intelligence Platform
  • 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
For Developers:
  • 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
For Researchers:
  • 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.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท wesleyscholl/book-generator ยท Updated daily from GitHub