A React-based frontend application for visualisation of Milgram experiment conversations which are generated using this repo: https://github.com/frodulec/milgram-experiments
This application provides a platform for running psychological experiments that study learning dynamics, obedience patterns, and decision-making processes. The frontend features real-time audio-visual synchronization, dynamic image generation, and an intuitive interface for both researchers and participants.
- Node.js >= 20.0.0
- npm >= 10.0.0
-
Clone the repository
git clone <repository-url> cd milgram-frontend
-
Install dependencies
npm install
-
Start development server
npm start
-
Open your browser Navigate to
http://localhost:3000
-
Build the application
npm run build
-
Serve the build
npm run serve
# Build the Docker image
make docker-build
# Run the container
make docker-run
# Or build and run in one command
make docker-dev# Build image
docker build -t learning-experiment-app .
# Run container
docker run -p 3000:80 learning-experiment-appCreate a .env file in the root directory:
REACT_APP_BACKEND_URL=https://your-backend-url.comThe application connects to a backend API for:
- Text-to-speech audio generation
- Experiment data streaming
- Conversation management
- Real-time experiment execution
Default backend URL: https://milgram-experiments-production.up.railway.app
src/
├── components/ # React components
│ ├── ui/ # UI components (sliders, color mode)
│ ├── AudioControls.js # Audio playback controls
│ ├── ImageDisplay.js # Dynamic image rendering
│ ├── MessageHistory.js # Conversation display
│ └── Sidebar.js # Navigation sidebar
├── hooks/ # Custom React hooks
│ ├── useAudioPlayer.js # Audio management
│ ├── useExperienceManager.js # Experiment flow
│ └── useSyncQueue.js # Synchronization logic
├── pages/ # Page components
│ ├── ApiKeySetup.js # API configuration
│ └── Settings.js # Application settings
├── services/ # API and external services
│ ├── apiService.js # Backend communication
│ └── imageGenerator.js # Dynamic image generation
├── utils/ # Utility functions
│ └── imageCache.js # Image caching system
└── assets/ # Static assets
└── optimized/ # Optimized images
- Uses Fabric.js for dynamic canvas rendering
- Generates real-time scenes with characters and speech bubbles
- Implements intelligent caching for performance
- Supports multiple character positions and animations
- Manages synchronized audio playback
- Controls playback rate and volume
- Handles audio queue management
- Integrates with text-to-speech API
- Coordinates audio and visual synchronization
- Processes real-time experiment data
- Manages message flow and timing
- Ensures smooth user experience
npm start- Start development servernpm run build- Build for productionnpm run optimize-images- Optimize image assetsnpm test- Run test suitenpm run eject- Eject from Create React App
The application supports custom theming through Chakra UI:
- Light and dark mode support
- Custom color schemes
- Responsive design breakpoints
Configure experiment settings in the Settings page:
- Voltage ranges and increments
- Character profiles and personas
- Message templates
- Audio and visual preferences
- API keys are stored securely in browser storage
- HTTPS enforcement for production deployments
- CORS configuration for backend communication
- Input validation and sanitization
- Image Optimization: Automatic image compression and caching
- Code Splitting: Lazy loading of components
- Bundle Optimization: Tree shaking and minification
- CDN Ready: Static asset optimization for CDN deployment
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the documentation
- Review existing issues
- Create a new issue with detailed information
This application is designed for psychological research and educational purposes. It provides a controlled environment for studying:
- Learning behaviors and patterns
- Decision-making processes
- Social influence and obedience
- Educational technology effectiveness
Note: This application is designed for research and educational purposes. Please ensure compliance with relevant ethical guidelines and institutional review board requirements when conducting experiments.