Skip to content

Project Initialization

Asterios Raptis edited this page Jul 24, 2025 · 3 revisions

πŸ—οΈ Initialize Book Project Structure

⚠️ Deprecated: The shell script create_project_structure.sh is now deprecated. βœ… Please use the new Python-based initializer instead: init_book_project.py


βœ… Why Switch to the Python Script?

The new init_book_project.py script offers:

  • Cross-platform compatibility (Windows, macOS, Linux)
  • More readable and maintainable code
  • Poetry integration for smooth CLI usage
  • Auto-creation of metadata files and a JSON template for image generation

πŸš€ How to Use the New Initializer

First, make sure dependencies are installed:

poetry install

or if pyproject.toml changed significantly since poetry.lock was last generated. Run the following command to fix the lock file.

poetry lock

and then run again:

poetry install

Then you can run the initializer:

poetry run init-book-project

This will:

  • Prompt you for project name, book title, author name, and description
  • Create the full book folder structure (manuscript, config, assets, output, etc.)
  • Generate default content files (README, LICENSE, chapter stubs, metadata files)
  • Initialize a ready-to-use JSON image prompt configuration in scripts/data/

πŸ› οΈ Auto-Configuration After Initialization

After running:

poetry run init-book-project

or the shortcut:

poetry run init-bp

you will be prompted to enter:

  • πŸ“˜ Project name (used for folder and export base name)
  • πŸ“ Project description (used in pyproject.toml)
  • πŸ“– Book title (used in export metadata)
  • πŸ‘€ Author name (used in export metadata)

These values will be automatically applied to key files:


πŸ”„ What Gets Updated Automatically

File Field(s) Modified Notes
pyproject.toml tool.poetry.name, tool.poetry.description Updates project name and description
scripts/full_export_book.py OUTPUT_FILE, metadata template string Changes the export base name and Pandoc metadata defaults
config/metadata.yaml title, author, description, date, language Pre-fills metadata for Pandoc export

🧩 Example Prompt Flow

πŸ“˜ Enter your project name (e.g., 'ai-for-everyone'): my-book
πŸ“ Enter a short description of your project: A journey into friendly AI.
πŸ“– Enter your book title: AI for Everyone
πŸ‘€ Enter the author's name: Asterios Raptis

This will result in:

  • pyproject.toml:

    name = "my-book"
    description = "A journey into friendly AI."
  • full_export_book.py:

    OUTPUT_FILE = "my-book"
    ...
    f.write("title: 'AI for Everyone'\nauthor: 'Asterios Raptis'\ndate: '2025'\nlang: 'en'\n")
  • config/metadata.yaml:

    title: "AI for Everyone"
    author: "Asterios Raptis"
    description: "A journey into friendly AI."
    date: "2025"
    language: "en"
    ...

πŸ’‘ Pro Tip

You no longer need to manually edit pyproject.toml or full_export_book.py after project setup. If you want to reapply or change these values later, just re-run the initializer.


βš™οΈ What’s Created?

Directories:

  • manuscript/chapters
  • manuscript/front-matter
  • manuscript/back-matter
  • assets/covers
  • assets/author
  • assets/figures/diagrams
  • assets/figures/infographics
  • config
  • output
  • scripts/data

Files:

  • Chapter placeholders (01-chapter.md, 02-chapter.md)
  • Front and back matter files (toc.md, preface.md, glossary.md, etc.)
  • Config files: metadata.yaml, metadata_values.json, styles.css, keywords.md, etc.
  • Image generation config: scripts/data/image_project_config.json
  • README and LICENSE templates

πŸ—‚οΈ Example Directory Structure

book-project/
β”œβ”€β”€ manuscript/
β”‚   β”œβ”€β”€ chapters/01-chapter.md
β”‚   β”œβ”€β”€ front-matter/preface.md
β”‚   └── back-matter/epilogue.md
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ covers/
β”‚   β”œβ”€β”€ figures/diagrams/
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ metadata.yaml
β”‚   └── metadata_values.json
β”œβ”€β”€ output/
β”œβ”€β”€ scripts/
β”‚   └── data/image_project_config.json
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE

🧹 Remove Old Scripts

If you previously used this deprecated script:

scripts/create_project_structure.sh

you should now remove it from your workflow and use:

poetry run init-book-project

🧱 Easily Extendable

The Python version can easily be extended to:

  • Generate additional chapters
  • Accept command-line arguments (e.g. for CI/CD or automation)
  • Apply different templates (e.g., children's books, whitepapers, technical manuals)

Clone this wiki locally