Skip to content

Commit d0640d8

Browse files
feat: added facets endpoint #737
1 parent b419e22 commit d0640d8

File tree

12 files changed

+200
-0
lines changed

12 files changed

+200
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
node_modules/
22
lib/
33
.vscode/
4+
.venv/
5+
__pycache__/
6+
*.pyc
47
.DS_Store
58
.idea

.husky/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ npm test ||
2727
false;
2828
)
2929

30+
# Check Black (Python formatter)
31+
python -m black backend --check ||
32+
(
33+
echo '🤔 Black Check Failed. Run: python -m black backend';
34+
false;
35+
)
36+
3037
# Check TypeScript
3138
npm run test-compile ||
3239
(

backend/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Findable Backend (FastAPI)
2+
3+
This folder contains a minimal FastAPI backend that exposes a stubbed **query-to-facets** endpoint for experimentation and PoC work.
4+
5+
## Requirements
6+
7+
- Python 3.9+
8+
- `pip`
9+
10+
## Set up a Python virtual environment
11+
12+
From the repo root:
13+
14+
```bash
15+
python -m venv backend/.venv
16+
source backend/.venv/bin/activate
17+
python -m pip install --upgrade pip
18+
```
19+
20+
## Install dependencies
21+
22+
From the repo root:
23+
24+
```bash
25+
pip install -r backend/requirements.txt
26+
```
27+
28+
## Run the server
29+
30+
From the repo root:
31+
32+
```bash
33+
uvicorn backend.main:app --reload
34+
```
35+
36+
## Format code
37+
38+
From the repo root:
39+
40+
```bash
41+
python -m black backend
42+
```
43+
44+
The app will start on `http://127.0.0.1:8000` by default.
45+
46+
### Endpoint
47+
48+
- **Method:** `POST`
49+
- **Path:** `/api/v0/facets`
50+
- **Request body:**
51+
52+
```json
53+
{ "query": "string" }
54+
```
55+
56+
- **Example request:**
57+
58+
```bash
59+
curl -sS -X POST "http://127.0.0.1:8000/api/v0/facets" \
60+
-H "Content-Type: application/json" \
61+
-d '{ "query": "public bam files for latino patients with diabetes" }'
62+
```
63+
64+
- **Response:** currently returns a **hard-coded** JSON structure representing resolved facets for the query. This is intentionally stubbed for PoC and will be replaced by a real implementation later.

backend/__init__.py

Whitespace-only changes.

backend/controllers/__init__.py

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from fastapi import APIRouter
2+
from pydantic import BaseModel
3+
4+
from backend.services.facets_service import compute_facets_from_query
5+
from backend.services.facets_service import FacetsResponse
6+
7+
from backend.controllers.models import FacetsRequest
8+
9+
router = APIRouter(prefix="/api/v0/facets", tags=["facets"])
10+
11+
12+
@router.post("")
13+
def get_facets(payload: FacetsRequest) -> FacetsResponse:
14+
# NOTE: Stubbed PoC implementation. This will be replaced by
15+
# LLM-backed intent parsing and real facet resolution in a later step.
16+
# For now, delegate to the service layer so the controller stays thin.
17+
return compute_facets_from_query()

backend/controllers/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pydantic import BaseModel
2+
3+
4+
# Model of the request body for the /api/v0/facets endpoint.
5+
class FacetsRequest(BaseModel):
6+
query: str

backend/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from fastapi import FastAPI
2+
3+
from backend.controllers.facets_controller import router as facets_router
4+
5+
6+
app = FastAPI(title="Findable API")
7+
8+
# Register controller(s)
9+
app.include_router(facets_router)

backend/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fastapi==0.115.0
2+
uvicorn[standard]==0.30.0
3+
pydantic==2.9.0
4+
black==24.10.0

backend/services/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)