Napkin-AI-API icon indicating copy to clipboard operation
Napkin-AI-API copied to clipboard

Streamlit Web App/Python CLI client for the Napkin AI API that transforms text into professional diagrams, illustrations, and visual content with 15+ built-in styles.

๐ŸŽจ Napkin AI API Playground

Napkin AI Version Status

๐Ÿ› ๏ธ Tech Stack

Python Poetry Streamlit Typer Pydantic

๐Ÿ“Š Project Stats

GitHub Actions Tests Coverage License

๐Ÿ”ง Code Quality

Ruff MyPy Security Pre-commit

๐ŸŒŸ Features

Languages Styles API Docker

Transform text into stunning visuals with the power of AI โœจ

๐Ÿš€ Quick Start โ€ข โœจ Features โ€ข ๐Ÿ“š Documentation โ€ข ๐ŸŽฎ Demo โ€ข ๐Ÿค Contributing


๐ŸŽฏ What is Napkin AI API Playground?

A production-ready Python toolkit featuring both a ๐ŸŒ Streamlit web interface and ๐Ÿ’ป powerful CLI that seamlessly transforms your text into professional-grade visuals using the Napkin AI API. Built with modern Python practices, robust error handling, intelligent retries, and comprehensive monitoring.


Interactive Web UI

Command Line Tool

Async Operations

Automated Testing

๐ŸŽฏ Perfect for:

  • ๐Ÿ“Š Data Scientists - Visualize complex concepts instantly
  • ๐Ÿ‘ฉโ€๐Ÿ’ป Developers - Generate architecture diagrams from descriptions
  • ๐Ÿ“š Educators - Create engaging visual content for teaching
  • ๐Ÿ’ผ Product Managers - Quickly sketch out ideas and workflows
  • ๐ŸŽจ Content Creators - Transform text into beautiful graphics

โœจ Features

๐ŸŒ Streamlit Web Interface

  • Interactive UI with real-time generation
  • Live preview of all visual styles
  • Multi-language support (38 languages)
  • Advanced options panel
  • Download manager for all formats
  • Mobile-responsive design

๐Ÿ’ป Powerful CLI

  • Full-featured command line tool
  • Single visual generation
  • JSON export options
  • Rich terminal output
  • Progress tracking with spinners
  • Configuration management

๐ŸŽจ 16 Visual Styles

  • Vibrant - Bold, energetic visuals
  • Sketch - Hand-drawn aesthetics
  • Corporate - Professional graphics
  • Minimalist - Clean, simple designs
  • Comic - Fun, playful style
  • And many more!

โšก Advanced Features

  • Async API with retry logic
  • Rate limiting (60 req/min)
  • Error monitoring dashboard
  • GitHub Actions integration
  • Docker support
  • Type-safe with Pydantic v2

๐Ÿš€ Quick Start

๐Ÿ“ฆ Installation

# Clone the repository
git clone https://github.com/moshehbenavraham/Napkin-AI-API.git
cd Napkin-AI-API

# Install with Poetry (recommended)
poetry install

# Or use pip
pip install -r requirements.txt

๐Ÿ”‘ Configuration

# Copy example config
cp .env.example .env

# Add your API token (get one at https://napkin.ai)
echo "NAPKIN_API_TOKEN=your_token_here" >> .env

# Optional: Add GitHub token for error monitoring
echo "GITHUB_TOKEN=ghp_your_github_token" >> .env

๐ŸŽฎ Demo

๐ŸŒ Web Interface (Streamlit)

# Launch the web app
poetry run streamlit run streamlit_app.py

# Or with custom port
poetry run streamlit run streamlit_app.py --server.port 8080

# Access at http://localhost:8501
๐Ÿ“ธ Web Interface Screenshots
  • Main generation interface
  • Style browser with categories
  • Multi-language support
  • Advanced options panel
  • Real-time generation
  • Download manager

๐Ÿ’ป Command Line Interface

# Generate your first visual
poetry run napkin generate "Machine Learning Pipeline"

# With specific style and format
poetry run napkin generate "Data Flow" --style sketch-notes --format png

# Multiple variations
poetry run napkin generate "System Architecture" --variations 4

# Export to JSON
poetry run napkin generate "Workflow" --json output.json

๐Ÿ› ๏ธ Advanced Usage

๐ŸŒ Multi-Language Support

Generate visuals in 38 languages using BCP 47 language tags:

# Spanish
napkin generate "Flujo de datos" --language es-ES

# Japanese
napkin generate "ใƒ‡ใƒผใ‚ฟใƒ•ใƒญใƒผ" --language ja-JP

# Arabic
napkin generate "ุชุฏูู‚ ุงู„ุจูŠุงู†ุงุช" --language ar

๐ŸŽฏ Context Options

Add context for more meaningful visuals:

napkin generate "Neural Network" \
  --context-before "Introduction to" \
  --context-after "for beginners"

๐Ÿ”„ Visual Regeneration

Update existing visuals or search for specific types:

# Regenerate existing visual
napkin generate "Updated Content" --visual-id "5UCQJLAV5S6NXEWS2PBJF54UYPW5NZ4G"

# Search for specific visual type
napkin generate "Project Timeline" --visual-query "timeline"

๐Ÿ“ Custom Dimensions

For PNG format with specific dimensions:

napkin generate "Architecture" \
  --format png \
  --width 1920 \
  --height 1080 \
  --transparent \
  --inverted-color

๐Ÿ” CI/CD & Monitoring

๐Ÿ“Š GitHub Actions Integration

Our project uses GitHub Actions for continuous integration with automated testing, linting, and deployment:

  • Python 3.10, 3.11, 3.12 matrix testing
  • Automated linting with Ruff
  • Type checking with MyPy
  • Security scanning with Bandit
  • Coverage reporting with Codecov
  • Automated notifications on failure

๐Ÿ› ๏ธ Built-in Monitoring Tool

Monitor your CI/CD pipeline with the unified gh-monitor tool:

# Monitor recent failures
bin/gh-monitor          # Show last 5 failures
bin/gh-monitor 10       # Show last 10 failures

# Analyze failures in detail
bin/gh-monitor analyze  # Detailed analysis with error messages

# Generate CI error reports
bin/gh-monitor report   # JSON report with context

# Export and format options
bin/gh-monitor 20 --json failures.json  # Export to JSON
bin/gh-monitor 10 --simple              # Simple one-line format

๐Ÿ”” Automated Notifications

Configure automatic notifications for CI/CD failures:

Slack Integration

SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

Discord Integration

DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}

Email Alerts

EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}

GitHub Issues

CREATE_GITHUB_ISSUE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

๐Ÿ“š Documentation

Document Description Badge
๐Ÿ“˜ API Guide Complete API reference & usage API
๐Ÿ“— Project Guide Development, testing & contributing Project
๐Ÿ“™ Official API Docs Napkin's official API documentation Official

๐Ÿ—๏ธ Architecture

graph TD
    A[๐ŸŒ Web UI / ๐Ÿ’ป CLI] -->|Streamlit / Typer| B[โš™๏ธ Core Generator]
    B --> C[๐Ÿ”Œ API Client]
    C -->|httpx + tenacity| D[โ˜๏ธ Napkin API]
    B --> E[๐Ÿ“‹ Pydantic Models]
    E --> F[โœ… Type Validation]
    B --> G[๐Ÿ” Error Monitor]
    G --> H[๐Ÿ“Š GitHub Actions]
    
    style A fill:#FF4B4B,stroke:#333,stroke-width:2px
    style D fill:#4285F4,stroke:#333,stroke-width:2px
    style H fill:#2088FF,stroke:#333,stroke-width:2px
๐Ÿ“ Project Structure
napkin-api-playground/
โ”œโ”€โ”€ ๐Ÿ“ฑ streamlit_app.py     # Web interface (650 lines)
โ”œโ”€โ”€ ๐Ÿš€ main.py              # CLI entry point
โ”œโ”€โ”€ ๐Ÿ”ง bin/
โ”‚   โ””โ”€โ”€ gh-monitor          # GitHub Actions monitoring tool
โ”œโ”€โ”€ ๐Ÿ“ src/
โ”‚   โ”œโ”€โ”€ ๐Ÿ”Œ api/            # Async API client & models
โ”‚   โ”œโ”€โ”€ ๐Ÿ’ป cli/            # CLI commands & display
โ”‚   โ”œโ”€โ”€ โš™๏ธ core/           # Generation orchestration
โ”‚   โ””โ”€โ”€ ๐Ÿ”ง utils/          # Config & helpers
โ”œโ”€โ”€ ๐Ÿงช tests/              # Test suite
โ”œโ”€โ”€ ๐Ÿ“š docs/               # Complete documentation
โ”œโ”€โ”€ ๐Ÿ” scripts/            # Monitoring & utilities
โ””โ”€โ”€ ๐ŸŽจ data/               # Generated visuals

๐Ÿงช Development

๐Ÿ”ฌ Testing & Quality

# Run all tests
poetry run pytest

# With coverage report
poetry run pytest --cov=src --cov-report=html

# Type checking
poetry run mypy src/

# Linting
poetry run ruff check src/

# Security scan
poetry run bandit -r src/

๐Ÿ” GitHub Actions Monitoring

Monitor and analyze CI/CD failures with the unified monitoring tool:

# Show recent failures
bin/gh-monitor        # Last 5 failures
bin/gh-monitor 10     # Last 10 failures

# Analyze failures in detail
bin/gh-monitor analyze

# Generate CI error report
bin/gh-monitor report

# Export to JSON
bin/gh-monitor 5 --json failures.json

# Simple one-line format
bin/gh-monitor 10 --simple

# See all options
bin/gh-monitor --help

๐Ÿ“š Full documentation

๐Ÿ“Š Code Quality Metrics

Tests
Coverage
Type Safety
Linting
Security

๐ŸŒŸ What's New in v0.3.2

โœจ Latest Features

  • โœ… Production-ready status with all tests passing
  • โœ… Unified error monitoring system
  • โœ… Enhanced CI/CD with automatic notifications
  • โœ… Improved documentation with badges
  • โœ… Fixed all deprecation warnings
  • โœ… Python 3.10+ compatibility

๐ŸŽจ Web Interface (v0.3.0)

  • ๐ŸŒ 38 languages with BCP 47 tags
  • ๐Ÿ“‹ Context options for better visuals
  • ๐ŸŽฏ Advanced settings panel
  • ๐Ÿ”„ Visual regeneration feature
  • ๐Ÿ” Visual type search
  • ๐Ÿ“ฑ Mobile-responsive design

๐Ÿค Contributing

We love contributions! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“Š Project Roadmap

โœ… Completed Phases

โœ… Phase 1: Core MVP
  • [x] Core API integration
  • [x] CLI with all parameters
  • [x] 16 styles support
  • [x] Async operations
  • [x] Comprehensive testing
โœ… Phase 2: Web Interface
  • [x] Streamlit web application
  • [x] Interactive style browser
  • [x] Real-time generation
  • [x] Download functionality
  • [x] Multi-language support
  • [x] Advanced options panel

๐Ÿšง Upcoming Features

  • [ ] Phase 3: Batch Processing - Process multiple visuals from CSV/JSON
  • [ ] Phase 4: Gallery Mode - Local SQLite gallery with search
  • [ ] Phase 5: Custom Styles - Create and save custom visual styles
  • [ ] Team Collaboration - Share visuals with team members
  • [ ] Cloud Integration - S3/GCS storage support
  • [ ] API Webhooks - Real-time generation notifications

๐Ÿ”’ Security

๐Ÿ” Tokens Never Logged ๐Ÿ›ก๏ธ .env Gitignored โœ… Input Validation
๐Ÿ”„ HTTPS Only ๐Ÿ”‘ Bearer Auth ๐ŸŒ Secure Headers

See SECURITY.md for full security practices.

๐Ÿ› Troubleshooting

๐Ÿ’ป CLI Issues
Issue Solution
Rate limit errors Client auto-retries with backoff (60 req/min limit)
File not found Ensure output directory exists or use default ./data/visuals
Token errors Check NAPKIN_API_TOKEN in .env file
๐ŸŒ Web Interface Issues
Issue Solution
403 Forbidden Update to latest version (fixed in v0.2.1)
Pydantic errors Update to latest version (fixed in v0.2.2)
Auth header required Ensure API token is set correctly
๐Ÿ”ง Development Issues
Issue Solution
Poetry lock errors Run poetry lock to update
Type check failures Run poetry run mypy src/
Test failures Ensure .env has valid token

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE.md file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

๐Ÿ“ง Email
[email protected]
๐Ÿ› Issues
GitHub Issues
๐Ÿ’ฌ Discussions
GitHub Discussions

๐ŸŒŸ Star us on GitHub!

If you find this project useful, please consider giving it a star โญ

Stars Forks Watchers

Made with ๐ŸŽจ and Python by the Napkin AI Community

โฌ† Back to top