A comprehensive Flask web application for creating, customizing, and ordering high-quality educational books for children ages 3-10.
Vahini Education Book Builder empowers parents, teachers, and schools to:
- Create custom educational books with AI-generated illustrations
- Choose from multiple book types (pre-writing, coloring, subject learning, practice)
- Customize content for different age groups and learning objectives
- Get transparent pricing with instant cost calculation
- Order print-ready books delivered to your door
- Track orders and manage fulfillment
-
5-Step Book Builder: Intuitive wizard for creating custom books
- Step 1: Choose book type, age group, difficulty
- Step 2: Set title, topic, number of pages
- Step 3: Customize language, size, purpose
- Step 4: Review details and adjust quantity
- Step 5: Save draft or proceed to checkout
-
Dynamic Pricing: Real-time cost calculation including:
- Per-page printing costs
- Shipping to 50+ countries
- Tax calculations
- Bulk discounts
-
Book Preview: See page-by-page layout before ordering
-
Order Management: Track order status from processing to delivery
- Print Job Dashboard: Manage fulfillment pipeline
- Order Management: View, update, and fulfill orders
- Analytics: Order statistics and revenue reports
- Courier Integration: Track shipments and delivery status
vahini-book-builder/
├── app/
│ ├── __init__.py # Application factory
│ ├── models/
│ │ └── __init__.py # SQLAlchemy models
│ │ ├── User # User accounts
│ │ ├── BookOrder # Orders
│ │ ├── Page # Book pages
│ │ └── PrintJob # Print jobs
│ ├── routes/
│ │ ├── book_builder.py # 5-step form & APIs
│ │ ├── preview.py # Book preview
│ │ ├── order.py # Checkout & tracking
│ │ └── admin.py # Admin dashboard
│ ├── services/
│ │ ├── prompt_builder.py # Prompt generation
│ │ ├── image_service.py # DALL-E 3 integration
│ │ ├── pdf_service.py # PDF compilation
│ │ └── pricing_service.py # Cost calculation
│ ├── templates/
│ │ ├── base.html # Base layout
│ │ ├── index.html # Landing page
│ │ ├── book_builder/ # Builder forms
│ │ ├── order/ # Order forms
│ │ ├── preview/ # Preview pages
│ │ ├── admin/ # Admin pages
│ │ └── errors/ # Error pages
│ └── static/
│ ├── css/
│ │ └── style.css # Main styles
│ └── js/
│ └── main.js # Frontend JS
├── config.py # Configuration
├── wsgi.py # Gunicorn entry point
├── requirements.txt # Dependencies
└── README.md # This file
Backend:
- Flask 2.3.3 - Web framework
- Flask-SQLAlchemy 3.0.5 - ORM
- SQLAlchemy 2.0.21 - Database abstraction
- Gunicorn 21.2.0 - Production server
- Python-dotenv 1.0.0 - Environment configuration
Database:
- SQLite (development)
- PostgreSQL (production-ready)
Frontend:
- Bootstrap 5.3 - UI framework
- Vanilla JavaScript - No dependencies
Services:
- OpenAI DALL-E 3 - Image generation
- ReportLab 4.0.7 - PDF generation
- Pillow 10.0.0 - Image processing
- Requests 2.31.0 - HTTP client
- Python 3.9+
- pip or conda
- OpenAI API key (for DALL-E 3, optional)
-
Clone Repository
git clone https://github.com/vahinitech/vahini-book-builder.git cd vahini-book-builder -
Create Virtual Environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Configure Environment
cp .env.example .env # Edit .env with your settings: # - FLASK_ENV=development # - SECRET_KEY=your-secret-key # - DATABASE_URL=sqlite:///vahini_books.db # - OPENAI_API_KEY=your-openai-key (optional)
-
Initialize Database
flask db upgrade # Or manually with: # python -c "from app import create_app, db; app = create_app(); app.app_context().push(); db.create_all()"
-
Run Development Server
python wsgi.py # Or: flask runServer runs at: http://localhost:5000
- Go to Book Builder at
/builder/ - Follow the 5-step wizard:
- Select book type and target age
- Set title, topic, page count
- Customize language, size, purpose
- Review details and pricing
- Save draft or checkout
- Proceed to checkout for order placement
- Track order status from dashboard
- Navigate to
/admin/dashboard - View order statistics and recent orders
- Manage print jobs at
/admin/print-jobs - Edit orders and update fulfillment status
GET /builder/- Landing pagePOST /builder/step1-5- Form submissionsGET /builder/api/book-types- Book typesGET /builder/api/topics- Available topicsPOST /builder/api/pricing- Calculate pricing
GET /order/checkout/<id>- Checkout pagePOST /order/checkout/<id>- Submit orderGET /order/confirmation/<id>- Order confirmationGET /order/tracking/<id>- Order tracking
GET /preview/book/<id>- View bookGET /preview/gallery- Sample galleryGET /preview/api/pages/<id>- Get page list
GET /admin/dashboard- DashboardGET /admin/orders- Order listGET /admin/print-jobs- Print jobsPOST /admin/api/print-job/<id>- Update print job
id, email, name, user_type, phone, organization, created_at, updated_at
id, user_id, title, book_type, topic, num_pages, age_group, difficulty_level,
language, book_size, purpose, config_json, status, prompt_file, pdf_file,
page_cost, shipping_cost, total_cost, quantity, delivery_address, phone_number,
created_at, updated_at
id, book_order_id, page_number, title, content_prompt, image_prompt,
image_url, image_file, status, created_at, updated_at
id, book_order_id, job_number, status, courier_name, tracking_number,
created_at, shipped_at, delivered_at, updated_at
# Flask
FLASK_ENV=development # development, production, testing
SECRET_KEY=your-super-secret-key # For session security
DEBUG=False # Debug mode
# Database
DATABASE_URL=sqlite:///vahini_books.db # SQLite or PostgreSQL
# OpenAI
OPENAI_API_KEY=sk-... # For DALL-E 3
# Pricing (optional, uses defaults from config)
PRICE_PER_PAGE=0.50
SHIPPING_BASE=5.00Edit config.py to customize:
- Database settings
- Upload folders
- Image generation options (model, size, quality)
- PDF specifications (DPI, margins)
- Pricing (per-page, shipping by region)
# Create migration
flask db migrate -m "description"
# Apply migration
flask db upgrade
# Revert migration
flask db downgrade# Run tests
pytest
# With coverage
pytest --cov=app# Format code
black app/
# Lint
flake8 app/
# Type checking
mypy app/# Install production dependencies
pip install gunicorn
# Run with Gunicorn
gunicorn -w 4 -b 0.0.0.0:8000 wsgi:app
# Or with systemd service:
# [Unit]
# Description=Vahini Book Builder
# After=network.target
#
# [Service]
# User=www-data
# WorkingDirectory=/var/www/vahini-book-builder
# Environment="PATH=/var/www/vahini-book-builder/venv/bin"
# ExecStart=/var/www/vahini-book-builder/venv/bin/gunicorn --workers 4 wsgi:app
#
# [Install]
# WantedBy=multi-user.target# Use PostgreSQL
DATABASE_URL=postgresql://user:password@localhost/vahini_books
# Enable SSL/TLS
FLASK_ENV=production
DEBUG=False
PREFERRED_URL_SCHEME=httpsFROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
ENV FLASK_ENV=production
EXPOSE 5000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "wsgi:app"]- User authentication (Flask-Login)
- Payment integration (Stripe/Razorpay)
- Email notifications (order confirmations, tracking)
- Courier API integration (Shiprocket/DHL)
- Image generation queue (background tasks with Celery)
- User dashboard (order history, favorites)
- Book customization (upload images, custom text)
- Bulk ordering discounts
- Subscription plans
- Multi-language support (i18n)
- Mobile app (iOS/Android)
- Social sharing (Pinterest, Instagram)
- Affiliate program
- Educational partnerships
- Accessibility (WCAG 2.1)
from flask_caching import Cache
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
@app.route('/api/book-types')
@cache.cached(timeout=3600)
def get_book_types():
...- User.email (unique)
- BookOrder.user_id, status, created_at
- Page.book_order_id, page_number
- PrintJob.status, courier_name
<!-- Use CDN for Bootstrap/jQuery -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect(app)- All user inputs validated server-side
- SQL injection prevention via SQLAlchemy ORM
- XSS prevention via Jinja2 auto-escaping
from flask_limiter import Limiter
limiter = Limiter(app)
@app.route('/api/pricing', methods=['POST'])
@limiter.limit("10/minute")
def get_pricing():
...# Remove SQLite database and reinitialize
rm vahini_books.db
python -c "from app import create_app, db; app = create_app(); db.create_all()"# Ensure app/ has __init__.py files
touch app/routes/__init__.py
touch app/services/__init__.py
touch app/models/__init__.py- Check API key validity
- Verify account has DALL-E access
- Check rate limits: https://platform.openai.com/account/rate-limits
Email: support@vahinitech.com
Website: https://vahinitech.com
LinkedIn: https://linkedin.com/company/vahini-technologies
Vahini Technologies 2026 License - See LICENSE.md
Contributions welcome! Please:
- Fork repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- Initial release
- 5-step book builder
- Order management system
- Admin dashboard
- Dynamic pricing calculator
- Database models for users, orders, pages, print jobs
Vahini Technologies
Startup India: DIPP201621
Patents: #202541020023, #202541020024
"Creating educational excellence through technology"