Skip to content

🟡 [Enhancement] Add REST API layer using FastAPI for programmatic access #14

Description

@AkshatRaj00

Feature Request

Summary

Currently VisaIQ is only accessible via the Streamlit UI. Adding a FastAPI layer would allow:

  • Mobile app integration (Flutter client)
  • Third-party integrations
  • Programmatic batch predictions

Proposed Implementation

# api.py
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from predict import predict_with_confidence

app = FastAPI(title="VisaIQ API", version="1.0.0")

class PredictionRequest(BaseModel):
    country: str
    visa_type: str
    application_date: str  # YYYY-MM-DD

class PredictionResponse(BaseModel):
    days: float
    lower: float
    upper: float
    confidence: float
    confidence_label: str

@app.post("/predict", response_model=PredictionResponse)
def predict(req: PredictionRequest):
    result, error = predict_with_confidence(req.dict())
    if error:
        raise HTTPException(status_code=422, detail=error)
    return result

@app.get("/health")
def health():
    return {"status": "ok", "model_loaded": MODEL_LOADED}

Deploy alongside Streamlit:

uvicorn api:app --port 8001 &
streamlit run app.py --port 8501

Use Cases

  • Flutter mobile app for VisaIQ
  • Agency dashboard integrations
  • Automated batch processing scripts

enhancement api fastapi integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions