Hey Mitar,
I would recommend using fastAPI as the API layer and then farm out computationally expensive tasks to Ray tasks (or use Ray actors for stateful services in the web app). This is also what we do to build the Anyscale service on top of Ray! For the database access, I’d recommend asyncpg or SQLAlchemy.
Here is an example to get you started with Ray and fastAPI:
from fastapi import FastAPI
import ray
import sympy
app = FastAPI(title="Web backend", openapi_url="/openapi.json", docs_url="/docs")
@app.on_event("startup")
def startup_event():
ray.init(num_cpus=1)
@ray.remote
def integration(expression: str):
x = sympy.Symbol("x")
return str(sympy.integrate(expression, x))
@app.get('/integrate')
async def integrate(expression: str):
return {"integral": await integration.remote(expression)}
Then start the app with
uvicorn backend:app --port 8080
and go to http://localhost:8080/docs in your browser to query the endpoint.
You can then for example build the frontend in React or any other Javascript library you want.
Best,
Philipp.