A comprehensive Python tutorial project that demonstrates how to build a text analysis tool (BookBot) while learning to code collaboratively with Gemini CLI. This project showcases the power of AI-assisted development through hands-on learning.
GemiBook is an educational project that teaches you to:
- Build a complete Python application from scratch (BookBot - a text analysis tool)
- Learn AI-assisted development using Gemini CLI as your coding companion
- Master essential Python concepts including file I/O, data structures, and command-line interfaces
- Practice test-driven development with comprehensive test suites
- Experience modern development workflows with proper project structure and version control
BookBot is a Python program that analyzes novels and generates statistical reports on word and character usage. It demonstrates practical programming concepts while building something genuinely useful.
BookBot Features:
- π Read and analyze text files (books, documents, etc.)
- π’ Count total words in any document
- π Analyze character frequency with detailed statistics
- π Generate beautifully formatted reports
- π― Handle command-line arguments for different input files
- β Comprehensive test coverage for all functionality
- Python 3.x installed on your system
- Node.js 20+ or Homebrew for Gemini CLI installation
- A text editor or IDE (VS Code recommended)
git clone <your-repo-url>
cd gemibookFollow the detailed installation guide in GEMINI_CLI_SETUP.md:
Option A: With Node.js
npm install -g @google/gemini-cliOption B: With Homebrew
brew install gemini-cliSet up your API key (choose one):
# Gemini API (recommended for learning)
export GEMINI_API_KEY="your-api-key-here"
# OR Vertex AI (for enterprise)
export GOOGLE_API_KEY="your-api-key-here"
export GOOGLE_GENAI_USE_VERTEXAI=truecd gemibook
geminiThe Gemini CLI provides an interactive environment where you can ask questions, get code help, and learn step-by-step while building your BookBot.
Start your Gemini CLI session and begin with these prompts:
> I'm starting the BookBot tutorial. Can you help me understand the project structure and what we'll be building?
> Explain the learning objectives of this BookBot project and how each step builds on the previous one.
> What are the key Python concepts I'll learn while building BookBot?
Work through BOOKBOT_TUTORIAL.md with Gemini CLI assistance:
Step 1 - Environment Setup:
> Help me set up the basic Python environment and create the initial main.py file for BookBot
> I need to create a simple "Hello BookBot" program to test my Python setup. Show me the code and explain what it does.
Step 2 - File Reading:
> I need to implement the get_book_text() function that reads a file and returns its contents. Help me write this using Python's 'with' statement.
> My file reading isn't working. Here's my code: [paste your code]. Can you debug this and explain the fix?
Step 3 - Word Counting:
> Help me implement the count_words() function that takes text and returns the number of words using the .split() method.
> I want to test my word counting function. Can you help me write some test cases to verify it works correctly?
Step 4 - Code Organization:
> I need to refactor my code by moving the word counting function to a new stats.py file. Help me organize this properly and set up the imports.
> Explain the benefits of splitting code across multiple files and how Python imports work.
Step 5 - Character Analysis:
> Help me implement the count_characters() function that counts the frequency of each character in the text using a dictionary.
> I'm getting confused with dictionary operations in Python. Can you explain how to count characters step by step?
Step 6 - Data Processing:
> I need to create a get_character_report() function that converts my character dictionary to a sorted list. Help me implement this with proper sorting.
> My character sorting isn't working correctly. Here's my code: [paste code]. Can you fix this and explain the sorting logic?
Step 7 - Report Generation:
> Help me format the output into a beautiful report that matches the expected format in the tutorial.
> I want to add some polish to my report formatting. Can you suggest improvements and show me how to implement them?
Step 8 - Command Line Arguments:
> I need to add command-line argument support using sys.argv. Help me implement proper argument handling with error messages.
> My argument parsing has bugs. Here's the error I'm getting: [paste error]. Can you help me fix this?
> I want to run the test suite to validate my implementation. Help me understand the test files and run them properly.
> Some of my tests are failing. Here's the output: [paste test output]. Can you help me debug and fix the issues?
> Can you help me add additional test cases to make my BookBot more robust?
> My basic BookBot is working! Can you suggest some interesting extensions or improvements I could add?
> I want to add [specific feature like JSON export/GUI/multiple file support]. Help me design and implement this enhancement.
> Can you help me optimize my BookBot for better performance with large files?
gemibook/
βββ README.md # This file - project overview and guide
βββ BOOKBOT_TUTORIAL.md # Detailed step-by-step tutorial
βββ GEMINI_CLI_SETUP.md # Gemini CLI installation guide
βββ .gitignore # Git ignore rules
βββ skeleton/ # Starter code templates
β βββ main.py # Main program skeleton with TODOs
β βββ stats.py # Statistics functions skeleton
βββ tests/ # Comprehensive test suites
β βββ test_stats.py # Unit tests for statistics functions
β βββ test_main.py # Integration tests for main program
βββ books/ # Sample book data for testing
βββ sample.txt # Sample text from Frankenstein
By completing this tutorial with Gemini CLI, you will:
- β Master Python fundamentals: File I/O, dictionaries, functions, imports
- β Understand data analysis: Text processing, character frequency, sorting
- β Learn project organization: Multi-file projects, proper code structure
- β Practice testing: Unit tests, integration tests, test-driven development
- β Experience AI collaboration: How to effectively use AI assistants for coding
- β Build something real: A functional text analysis tool you can use
The project includes comprehensive test suites to validate your work:
# Test individual functions
python3 tests/test_stats.py
# Test main program functionality
python3 tests/test_main.py
# Test with sample data
python3 skeleton/main.py books/sample.txtWhen your BookBot is complete, it should produce output like this:
============ BOOKBOT ============
Analyzing book found at books/sample.txt...
----------- Word Count ----------
Found 547 total words
--------- Character Count -------
e: 95
t: 73
a: 69
r: 56
n: 55
o: 54
i: 52
...
============= END ===============
Effective Prompting Strategies:
- Be specific about what you're trying to implement
- Share error messages and code snippets when debugging
- Ask for explanations, not just solutions
- Request test cases and validation approaches
- Seek code review and improvement suggestions
Learning Best Practices:
- Work through each step methodically
- Test frequently as you build
- Ask "why" questions to deepen understanding
- Experiment with variations and improvements
- Use Gemini CLI to explain unfamiliar concepts
After completing BookBot:
- Explore Extensions: Add features like word frequency analysis, reading level calculation, or a GUI interface
- Try Other Projects: Use Gemini CLI to tackle more complex programming challenges
- Share Your Experience: Document your learning journey and share insights
- Contribute: Improve this tutorial based on your experience
- Python Official Documentation
- Gemini CLI Documentation
- Project Gutenberg - Free books for testing
- Real Python Tutorials - Advanced Python learning
Ready to start your AI-assisted coding journey? Follow the setup guide and dive into the tutorial! π
Happy coding with Gemini CLI! π€β¨
This tutorial was created as part of exploring AI-assisted development workflows. I'm also building Cipher - an agentic memory system that helps AI assistants remember and learn from past conversations.
π If you found this tutorial helpful, please consider:
- β Starring this repository to help others discover it
- β Checking out Cipher and giving it a star if you're interested in agentic memory systems
- π€ Sharing your feedback and suggestions for improving this tutorial
Your support helps me continue creating educational content and building tools that make AI-assisted development more accessible and effective!
Built with β€οΈ using Gemini CLI
