Skip to content

AI-powered crossword puzzle generator with React frontend and FastAPI backend. Features multi-provider LLM integration, Docker deployment, and professional UI. Built with comprehensive prompts demonstrating AI-assisted development.

Notifications You must be signed in to change notification settings

Rperry2174/faster_crowssword_generator

Repository files navigation

Crossword Studio - AI-Powered Puzzle Generator

A production-ready, commercial-grade crossword puzzle generator that demonstrates AI/LLM capabilities through an interactive web application. Users can input topics (e.g., "The Office", "Basketball", "Pixar Characters") and receive fully playable crossword puzzles with generated clues.

πŸš€ Features

  • AI-Powered Word Generation: Generates themed words and clues using multiple LLM providers
  • Robust Crossword Algorithm: Creates valid crosswords with proper word intersections
  • Interactive Grid: Professional crossword interface with click/type interaction
  • Multi-Provider LLM Support: OpenAI, Anthropic, Ollama, and mock fallback
  • Production Ready: Docker containerization with health checks
  • Comprehensive Testing: Full test suite with 80%+ coverage

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚   Backend       β”‚    β”‚   LLM APIs      β”‚
β”‚   (React/TS)    │◄──►│   (FastAPI)     │◄──►│   Multi-providerβ”‚
β”‚   Port: 3000    β”‚    β”‚   Port: 8000    β”‚    β”‚   External APIs β”‚
β”‚   Nginx Proxy   β”‚    β”‚   Python        β”‚    β”‚   + Local Ollamaβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Using Docker (Recommended)

  1. Clone and setup:

    git clone <repository>
    cd faster_dynamic_crossword
    cp .env.template .env
  2. Configure environment (edit .env):

    LLM_PROVIDER=anthropic  # or openai, ollama, mock
    ANTHROPIC_API_KEY=your_key_here
    OPENAI_API_KEY=your_key_here
  3. Start the application:

    docker-compose up --build
  4. Access the application:

Local Development

Backend Setup

cd backend
pip install -r requirements.txt
python start_server.py

Frontend Setup

cd frontend
npm install
npm start

πŸ§ͺ Testing

Backend Tests

cd backend
pytest tests/ -v

Test Coverage

  • Crossword generation algorithm validation
  • LLM integration with multiple providers
  • API endpoint functionality
  • Error handling and edge cases

πŸ› οΈ Core Components

Backend (/backend)

  • FastAPI Application: RESTful API with CORS support
  • Crossword Generator: Robust algorithm preventing invalid word formations
  • LLM Service: Multi-provider integration with fallback
  • Comprehensive Tests: pytest suite with mocking

Frontend (/frontend)

  • React TypeScript: Modern component architecture
  • Interactive Grid: Professional crossword interface
  • Tab System: Topic generation vs. custom words
  • Responsive Design: Mobile-friendly with touch support

πŸ“‹ API Endpoints

  • POST /generate-from-topic - Generate words from topic
  • POST /generate-crossword - Create crossword from word list
  • GET /clues/{crossword_id} - Retrieve stored clues
  • GET /health - Health check

πŸ”§ Configuration

Environment Variables

Variable Description Default
LLM_PROVIDER LLM provider (openai/anthropic/ollama/mock) mock
OPENAI_API_KEY OpenAI API key -
ANTHROPIC_API_KEY Anthropic API key -
OLLAMA_BASE_URL Ollama server URL http://localhost:11434

LLM Providers

  1. OpenAI: GPT-3.5-turbo for word generation
  2. Anthropic: Claude Haiku for word generation
  3. Ollama: Local LLM support (llama2)
  4. Mock: Fallback with curated word lists

🎯 Crossword Algorithm

The crossword generation engine implements:

  • Intersection Validation: Ensures proper word connections
  • Boundary Checking: Prevents word merging and overflow
  • Perpendicular Word Validation: Avoids creating invalid words
  • Connectivity Requirements: All words must connect to main structure
  • Quality Filtering: Professional crossword standards

πŸ”’ Security Features

  • API Key Management: Environment-based configuration
  • CORS Protection: Proper cross-origin headers
  • Input Validation: Sanitized user inputs
  • Container Security: Non-root users, minimal images
  • Health Monitoring: Built-in health checks

πŸ“± User Experience

  1. Topic Input: Enter any topic (e.g., "Basketball")
  2. Word Generation: AI generates 30 themed words with clues
  3. Crossword Creation: Algorithm creates valid puzzle structure
  4. Interactive Solving: Click cells, type letters, navigate with arrows
  5. Validation: Check answers or reveal solution
  6. Completion Tracking: Real-time progress indication

πŸ› Troubleshooting

Common Issues

CORS Errors: Ensure backend is running and CORS is configured LLM API Failures: Check API keys and network connectivity Docker Build Failures: Verify Docker and docker-compose versions Frontend Build Issues: Clear npm cache and reinstall dependencies

Debug Mode

# Backend with debug logging
cd backend
uvicorn src.api:app --reload --log-level debug

# Frontend with detailed errors
cd frontend
npm start

🚒 Deployment

Production Deployment

  1. Set production environment variables
  2. Use production Docker configurations
  3. Configure reverse proxy (nginx)
  4. Set up monitoring and logging
  5. Implement backup strategies

Scaling Considerations

  • Stateless backend design for horizontal scaling
  • Session storage can be moved to Redis/database
  • CDN for frontend assets
  • Load balancing for multiple backend instances

πŸ“Š Performance

  • Backend Response: < 2 seconds for crossword generation
  • Frontend Rendering: 60fps animations, smooth interactions
  • LLM Calls: Timeout handling with fallback
  • Docker Images: Optimized with multi-stage builds

🀝 Contributing

  1. Fork the repository
  2. Create feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit pull request

πŸ“„ License

This project is built for demonstration purposes and showcases AI integration patterns for crossword generation.


Built with AI-powered crossword generation 🧩

About

AI-powered crossword puzzle generator with React frontend and FastAPI backend. Features multi-provider LLM integration, Docker deployment, and professional UI. Built with comprehensive prompts demonstrating AI-assisted development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •