A Single Page Application (SPA) for conducting research studies via Prolific. Built with React, Material-UI, and a minimal Node.js Express server.
- ✨ Modern, responsive UI using Material-UI
- ⏱️ Automatic time tracking to monitor participant engagement
- 🔗 Prolific integration with URL parameter capture
- 📊 Study form with validation
- 🎨 Clean, professional design
- 🚀 SPA architecture for optimal user experience
mvk-study/
├── client/ # React SPA frontend
│ ├── public/
│ └── src/
│ ├── components/
│ │ └── StudyForm.js
│ ├── App.js
│ ├── App.css
│ └── index.js
├── server/ # Node.js Express backend
│ └── index.js
└── README.md
- Node.js (v14 or higher)
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd mvk-study- Install dependencies:
# Install root dependencies (ESLint)
npm install
# Install client dependencies
cd client
npm install
# Install server dependencies
cd ../server
npm install- Configure Environment:
- Create a
.envfile in theserverdirectory (seeserver/.env.exampleif available, or use the provided.env). - Ensure
MASTER_IMAGE_DIRpoints to your image dataset.
- Create a
This builds the client and serves it via the Node.js server, simulating the production environment.
- Build the client:
npm run build- Start the server:
npm startThe application will be available at http://localhost:5000.
For active development with Hot Module Replacement (HMR).
- Start the server (Terminal 1):
cd server
npm start- Start the client (Terminal 2):
cd client
npm startThe client will run on http://localhost:3000 (or another available port) and proxy API requests to the server.
To check for code quality issues:
npm run lintPORT: Server port (default: 5000)
Create a .env file in the server directory for custom configuration:
PORT=5000
Submit study responses and time tracking data.
Request Body:
{
"prolificId": "string",
"timeSpent": "number (seconds)",
"responses": {
"age": "string",
"experience": "string",
"feedback": "string"
},
"startTime": "ISO date string",
"endTime": "ISO date string"
}Response:
{
"success": true,
"message": "Data received"
}Health check endpoint.
Response:
{
"status": "ok",
"timestamp": "ISO date string"
}The app automatically tracks how long participants spend on the page:
- Timer starts when the page loads
- Updates every second
- Displayed in MM:SS format
- Submitted with form data
The app captures Prolific participant IDs from URL parameters:
- Supports
PROLIFIC_PIDparameter (Prolific standard) - Also supports
prolific_idas fallback - Displays participant ID in the UI
- Includes in submitted data
- Required fields are validated before submission
- Clear error messages for incomplete forms
- Loading state during submission
- Success confirmation after submission
Edit client/src/components/StudyForm.js to add more form fields:
const [formData, setFormData] = useState({
age: '',
experience: '',
feedback: '',
// Add your new fields here
});The app uses Material-UI's theming system. Modify the theme in client/src/App.js:
const theme = createTheme({
palette: {
primary: {
main: '#1976d2',
},
// Customize colors here
},
});The current server logs data to the console. To persist data:
- Add a database (e.g., MongoDB, PostgreSQL)
- Update the
/api/study-dataendpoint inserver/index.js - Implement proper data storage logic
ISC
For issues or questions, please open an issue in the repository.