Skip to content

Commit 13418d1

Browse files
committed
neurosift-search nextjs app
1 parent 463542b commit 13418d1

File tree

12 files changed

+11347
-2
lines changed

12 files changed

+11347
-2
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[codespell]
22
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
3-
skip = .git*,*.svg,package-lock.json,*.css,.codespellrc,static
3+
skip = .git*,*.svg,**/package-lock.json,*.css,.codespellrc,static
44
check-hidden = true
55
ignore-regex = \btempory\.net\b
66
ignore-words-list = numer,breal

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
# Changes
22

3+
## August 19, 2025
4+
5+
- implemented neurosift-search service (nextjs)
6+
37
## August 13, 2025
8+
49
- Added job cancellation functionality to JobStatusHandler component with red "Cancel Job" button for running jobs
510
- Added continuous integration workflow to test neurosift Python package installation, NWB file creation with pynwb, and CLI functionality
611

712
## August 11, 2025
13+
814
- Added redirect from /experimental-neurotile to /experimental-neurosift-tiles for URL compatibility
915
- Modified ExperimentalNeurosiftTilesPage to use zarr_url and path query parameters instead of example parameter, with examples landing page when parameters are not provided
1016
- Modified ExperimentalNeurosiftTilesPage to dynamically fetch examples from neurosift-tiles catalog instead of hard-coding them
1117

1218
## August 1, 2025
19+
1320
- Added channel selection functionality to neurotile visualization with click-to-select interaction
1421
- Implemented semitransparent yellow highlight overlay for selected channels in neurotile view
1522
- Added mouse click handling in TimeScrollView3 to support channel selection based on Y-coordinate

nextjs/neurosift-search/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts

nextjs/neurosift-search/README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Neurosift Search API
2+
3+
A standalone Next.js API service for executing scripts via the Neurosift job runner system using PubNub.
4+
5+
## Overview
6+
7+
This service provides API endpoints for executing scripts and performing DANDI semantic searches through the existing Neurosift job runner infrastructure. The PubNub client persists in memory across serverless requests for optimal performance.
8+
9+
## API Endpoints
10+
11+
### POST `/api/execute-script`
12+
13+
Executes a script via the job runner system and returns the raw output.
14+
15+
**Request Body:**
16+
17+
```json
18+
{
19+
"script": "your_javascript_script_here"
20+
}
21+
```
22+
23+
**Response (Success):**
24+
25+
```json
26+
{
27+
"success": true,
28+
"output": "script_output_here"
29+
}
30+
```
31+
32+
**Response (Error):**
33+
34+
```json
35+
{
36+
"success": false,
37+
"error": "error_message_here"
38+
}
39+
```
40+
41+
**Status Codes:**
42+
43+
- `200` - Success
44+
- `400` - Bad request (missing/invalid script)
45+
- `408` - Request timeout (job runner offline)
46+
- `500` - Internal server error
47+
48+
### POST `/api/dandi-semantic-search`
49+
50+
Performs a DANDI semantic search and returns a list of relevant dandiset IDs.
51+
52+
**Request Body:**
53+
54+
```json
55+
{
56+
"query": "your_search_query_here"
57+
}
58+
```
59+
60+
**Response (Success):**
61+
62+
```json
63+
{
64+
"success": true,
65+
"dandisetIds": ["000001", "000002", "000003"]
66+
}
67+
```
68+
69+
**Response (Error):**
70+
71+
```json
72+
{
73+
"success": false,
74+
"error": "error_message_here"
75+
}
76+
```
77+
78+
**Status Codes:**
79+
80+
- `200` - Success
81+
- `400` - Bad request (missing/invalid query)
82+
- `408` - Request timeout (job runner offline)
83+
- `500` - Internal server error
84+
85+
## Environment Variables
86+
87+
Set these in your Vercel deployment configuration:
88+
89+
- `PUBNUB_SUBSCRIBE_KEY` - PubNub subscribe key
90+
- `PUBNUB_PUBLISH_KEY` - PubNub publish key
91+
92+
## Usage Examples
93+
94+
### Execute Script
95+
96+
```bash
97+
curl -X POST https://neurosift-search.vercel.app/api/execute-script \
98+
-H "Content-Type: application/json" \
99+
-d '{
100+
"script": "interface.print(\"Hello from job runner!\");"
101+
}'
102+
```
103+
104+
### DANDI Semantic Search
105+
106+
```bash
107+
curl -X POST https://neurosift-search.vercel.app/api/dandi-semantic-search \
108+
-H "Content-Type: application/json" \
109+
-d '{
110+
"query": "olfactory bulb rat"
111+
}'
112+
```
113+
114+
## Development
115+
116+
1. Install dependencies:
117+
118+
```bash
119+
npm install
120+
```
121+
122+
2. Set environment variables in Vercel configuration
123+
124+
3. Run development server:
125+
126+
```bash
127+
npm run dev
128+
```
129+
130+
4. Test the API:
131+
```bash
132+
curl -X POST http://localhost:3001/api/execute-script \
133+
-H "Content-Type: application/json" \
134+
-d '{"script": "interface.print(\"test\");"}'
135+
```
136+
137+
## Deployment
138+
139+
Deploy to Vercel:
140+
141+
```bash
142+
vercel --prod
143+
```
144+
145+
## Architecture
146+
147+
- **Persistent PubNub Client**: A singleton client instance persists across serverless requests
148+
- **Job Runner Integration**: Uses the same channels and protocols as the main Neurosift application
149+
- **CORS Enabled**: Allows cross-origin requests for web integration
150+
- **Error Handling**: Comprehensive error handling with appropriate HTTP status codes
151+
152+
## PubNub Configuration
153+
154+
- **User ID**: `neurosift-search`
155+
- **Job Channel**: `dandi-index-query-job-requests`
156+
- **Response Channel**: `dandi-index-query-job-responses`
157+
- **Timeout**: 10 seconds for job acceptance

0 commit comments

Comments
 (0)