Skip to content

leonardopt/similarity-task-allocator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

similarity-task-allocator-api

Backend API for running a naturalistic image-similarity study where each participant must receive a valid, non-conflicting design assignment.

Study Context

This project belongs to a three-stage study pipeline:

  1. Stage 1: synthesis and model-based perceptual scaling of the stimulus set
  2. Stage 2: psychophysical validation via similarity judgements
  3. Stage 3: behavioral validation in a memory task

This repository is for Stage 2 infrastructure. It serves design allocation and participant submission handling used during psychophysical similarity-judgement data collection.

Pettini, L., Bogler, C., Doeller, C., & Haynes, J.-D. (2025). Synthesis and perceptual scaling of high-resolution naturalistic images using Stable Diffusion. Behavior Research Methods, 58(1), 24. https://doi.org/10.3758/s13428-025-02889-8

What The App Does

The API manages the assignment lifecycle for experiment designs stored in Supabase.

  1. Assignment step (GET /)
  • Finds designs marked as available in experiment_design_batches.
  • Prioritizes the earliest batch (lowest batch_number) and randomly picks one design from that batch.
  • Immediately reserves that design (available = false) so concurrent participants are less likely to receive the same assignment.
  1. Submission step (POST /)
  • Accepts participant identifiers (participant_id, study_id, session_id) plus the assigned design_file_name.
  • Updates the matching database row with participant metadata and a timestamped availability/status change.
  1. Access control
  • Uses CORS allowlisting via FRONTEND_ALLOWED_ORIGINS so only approved frontend origins can call the API from browsers.

This repository is organized with a clear app-first structure to separate runtime API code, tests, and operational scripts.

Quick Start

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn apps.api.src.main:app --reload

Create .env from .env.example and set:

SUPABASE_URL=
SUPABASE_KEY=
FRONTEND_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001

About

Backend API for managing the allocation of participants in an online similarity task.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages