Skip to content

FixIt API - Self-healing code search API with rate limiting and 18.5M+ records

Notifications You must be signed in to change notification settings

Built-Simple/fixit-api

Repository files navigation

FixIt API - Stack Overflow Solution Search

A production-ready API serving Stack Overflow code search with 18.5M+ records and full-text search capabilities.

🚀 Features

  • 82.9GB Database with 18.5M+ Stack Overflow solutions
  • Full-Text Search using SQLite FTS5 optimization
  • Rate Limiting with tiered access (Free: 100/day, Pro: 10k/day)
  • Health Monitoring endpoints for production deployment
  • Modern Frontend interface for interactive search
  • Fast Search - Average query time under 100ms

📊 Tech Stack

  • Backend: Python Flask
  • Database: SQLite with FTS5 full-text search
  • Web Server: Nginx
  • Data Source: Stack Overflow dataset (PostgreSQL backend)

🔧 Installation

Prerequisites

  • Python 3.8+
  • Nginx
  • 100GB+ storage for database

Setup

  1. Clone the repository:
git clone https://github.com/Built-Simple/fixit-api.git
cd fixit-api
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Configure Nginx:
sudo cp nginx-config/fixit /etc/nginx/sites-available/fixit
sudo ln -s /etc/nginx/sites-available/fixit /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx
  1. Run the API:
python3 working_api_with_rate_limiting.py

The API will start on http://localhost:5001 and the frontend will be available at http://localhost/

📖 API Endpoints

Health Check

GET /health

Returns database status and statistics:

{
  "status": "healthy",
  "database": "connected",
  "live_stats": {
    "database_size": "82.9GB",
    "total_records": "18,563,455"
  },
  "rate_limiting": {
    "enabled": true,
    "tiers": {
      "free": {
        "daily_limit": 100,
        "name": "Free Tier",
        "price": 0
      }
    }
  }
}

Search Solutions

POST /search
Content-Type: application/json

{
  "query": "python error handling",
  "limit": 10
}

Returns matching Stack Overflow solutions:

{
  "count": 10,
  "query": "python error handling",
  "search_time_ms": 87.3,
  "total_records": "18.5M+",
  "results": [
    {
      "id": 12345,
      "title": "How to handle exceptions in Python",
      "solution": "<p>Use try/except blocks...</p>",
      "answer_score": 245,
      "is_accepted": true,
      "tags": "|python|error-handling|",
      "similarity": 0.95
    }
  ]
}

🎨 Frontend

The frontend provides a modern, dark-themed interface with:

  • Live database statistics
  • Real-time search
  • Example queries
  • Formatted code snippets
  • Responsive design

Access at: http://localhost/

📁 Project Structure

fixit-api/
├── working_api_with_rate_limiting.py  # Main Flask API
├── fixit_frontend.html                # Frontend interface
├── requirements.txt                   # Python dependencies
├── nginx-config/                      # Nginx configuration
│   └── fixit                         # Nginx site config
├── archive/                          # Historical versions
│   ├── old-apis-NOT-PRODUCTION/     # Previous API versions
│   └── backups-NOT-PRODUCTION/      # Backup files
└── README.md                         # This file

🔐 Rate Limiting

The API implements tiered rate limiting:

  • Free Tier: 100 requests/day
  • Pro Tier: 10,000 requests/day ($29/month)

Rate limits are tracked per API key and reset daily.

🏥 Health Monitoring

Production deployment includes:

  • Container health monitoring
  • Application health checks (every 5 minutes)
  • Email alerts for failures
  • Automatic restart on crashes

See README_PRODUCTION.md for production deployment details.

📊 Database

The database contains:

  • 18,563,455 records from Stack Overflow
  • Full-text search index using FTS5
  • Optimized for sub-100ms query times
  • 82.9GB total size

Database schema includes:

  • Question titles
  • Answer solutions
  • Vote scores
  • Tags
  • Acceptance status

🚀 Performance

  • Average search time: < 100ms
  • Database size: 82.9GB
  • Total records: 18.5M+
  • Concurrent requests: Supports multiple simultaneous searches
  • Cache: Rate limiting cache for fast API key validation

🔧 Development

Running Tests

# Test API health
curl http://localhost:5001/health

# Test search
curl -X POST http://localhost:5001/search \
  -H "Content-Type: application/json" \
  -d '{"query":"python error","limit":5}'

Contributing

This is a production system. For changes:

  1. Test in a development environment
  2. Update documentation
  3. Submit pull requests with detailed descriptions

📝 License

Copyright © 2025 Built Simple

🙏 Credits

  • Data source: Stack Overflow
  • Built with: Flask, SQLite FTS5, Nginx
  • Frontend: Vanilla JavaScript with modern CSS

Production Status: ✅ Active Last Updated: December 5, 2025 Maintained by: Built Simple Team

About

FixIt API - Self-healing code search API with rate limiting and 18.5M+ records

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •