#!/bin/bash # VitalLink Automatic Installer for Arch Linux # This script sets up the entire project structure # You'll still need to copy the Python/React code from Claude artifacts set -e RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' PROJECT_ROOT="$PWD/vitallink" clear echo -e "${CYAN}" cat <<"EOF" ╔══════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ ██╗ ██╗██╗████████╗ █████╗ ██╗ ██╗ ██╗███╗ ██╗██╗ ██╗ ║ ║ ██║ ██║██║╚══██╔══╝██╔══██╗██║ ██║ ██║████╗ ██║██║ ██╔╝ ║ ║ ██║ ██║██║ ██║ ███████║██║ ██║ ██║██╔██╗ ██║█████╔╝ ║ ║ ╚██╗ ██╔╝██║ ██║ ██╔══██║██║ ██║ ██║██║╚██╗██║██╔═██╗ ║ ║ ╚████╔╝ ██║ ██║ ██║ ██║███████╗███████╗██║██║ ╚████║██║ ██╗ ║ ║ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ║ ║ ║ ║ Emergency Room Patient Monitoring System ║ ║ Automatic Installer v1.0 ║ ║ ║ ╚══════════════════════════════════════════════════════════════════════════╝ EOF echo -e "${NC}" echo -e "${YELLOW}This script will:${NC}" echo " 1. Create project structure in $PROJECT_ROOT" echo " 2. Set up Python virtual environment" echo " 3. Install all dependencies" echo " 4. Create startup/stop scripts" echo " 5. Generate placeholder files for you to fill" echo "" echo -e "${CYAN}Note: You'll need to copy Python/React code from Claude artifacts after this.${NC}" echo "" read -p "Continue? (y/n) " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo -e "${RED}Installation cancelled.${NC}" exit 1 fi # Check if directory exists if [ -d "$PROJECT_ROOT" ]; then echo -e "${YELLOW}Warning: $PROJECT_ROOT already exists.${NC}" read -p "Delete and recreate? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf "$PROJECT_ROOT" echo -e "${GREEN}✓ Removed existing directory${NC}" else echo -e "${RED}Installation cancelled.${NC}" exit 1 fi fi echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 1: Creating Directory Structure${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" mkdir -p "$PROJECT_ROOT"/{backend,simulator,frontend/{kiosk,dashboard},tests,docs,logs} echo -e "${GREEN}✓ Created project directories${NC}" cd "$PROJECT_ROOT" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 2: Setting up Python Virtual Environment${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" python -m venv venv source venv/bin/activate echo -e "${GREEN}✓ Virtual environment created${NC}" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 3: Creating requirements.txt${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" cat >requirements.txt <<'EOF' # Backend API fastapi==0.104.1 uvicorn[standard]==0.24.0 websockets==12.0 pydantic==2.5.0 python-multipart==0.0.6 # HTTP client for simulator integration aiohttp==3.9.1 requests==2.31.0 # Testing pytest==7.4.3 pytest-asyncio==0.21.1 # Utilities python-dateutil==2.8.2 EOF echo -e "${GREEN}✓ requirements.txt created${NC}" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 4: Installing Python Dependencies${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" pip install --upgrade pip -q pip install -r requirements.txt -q echo -e "${GREEN}✓ All Python packages installed${NC}" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 5: Creating Project Files${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" # Backend server placeholder cat >backend/server.py <<'EOF' """ VitalLink Backend Server TODO: Copy the complete FastAPI code from Claude artifact: "VitalLink Backend API (FastAPI)" """ print("Backend server placeholder - please copy the actual code from Claude artifacts") EOF echo -e "${GREEN}✓ backend/server.py created (placeholder)${NC}" # Simulator placeholder cat >simulator/wristband_simulator.py <<'EOF' """ VitalLink Wristband Simulator TODO: Copy the complete simulator code from Claude artifact: "VitalLink Wristband Simulator & Base Station" """ print("Simulator placeholder - please copy the actual code from Claude artifacts") EOF echo -e "${GREEN}✓ simulator/wristband_simulator.py created (placeholder)${NC}" # Test suite placeholder cat >tests/test_suite.py <<'EOF' """ VitalLink Test Suite TODO: Copy the complete test suite code from Claude artifact: "VitalLink Complete Test Suite" """ print("Test suite placeholder - please copy the actual code from Claude artifacts") EOF echo -e "${GREEN}✓ tests/test_suite.py created (placeholder)${NC}" # Dashboard HTML cat >frontend/dashboard/index.html <<'EOF' VitalLink Staff Dashboard
EOF echo -e "${GREEN}✓ frontend/dashboard/index.html created (template)${NC}" # Kiosk HTML cat >frontend/kiosk/index.html <<'EOF' VitalLink Check-in Kiosk
EOF echo -e "${GREEN}✓ frontend/kiosk/index.html created (template)${NC}" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 6: Creating Control Scripts${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" # Start script cat >start.sh <<'STARTSCRIPT' #!/bin/bash PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$PROJECT_ROOT" source venv/bin/activate echo "╔═══════════════════════════════════════════════════════════════════════╗" echo "║ Starting VitalLink System ║" echo "╚═══════════════════════════════════════════════════════════════════════╝" echo "" mkdir -p logs echo "Starting backend server..." python backend/server.py > logs/backend.log 2>&1 & echo $! > logs/backend.pid echo "✓ Backend started (PID: $(cat logs/backend.pid))" sleep 3 echo "Starting wristband simulator..." python simulator/wristband_simulator.py > logs/simulator.log 2>&1 & echo $! > logs/simulator.pid echo "✓ Simulator started (PID: $(cat logs/simulator.pid))" echo "" echo "═══════════════════════════════════════════════════════════════════════" echo "✅ VitalLink System Running!" echo "═══════════════════════════════════════════════════════════════════════" echo "" echo "📊 Access Points:" echo " • API Docs: http://localhost:8000/docs" echo " • API Stats: http://localhost:8000/api/stats" echo " • WebSocket: ws://localhost:8000/ws" echo " • Staff Dashboard: file://$PROJECT_ROOT/frontend/dashboard/index.html" echo " • Check-in Kiosk: file://$PROJECT_ROOT/frontend/kiosk/index.html" echo "" echo "📝 View Logs:" echo " • Backend: tail -f logs/backend.log" echo " • Simulator: tail -f logs/simulator.log" echo "" echo "🛑 Stop System:" echo " • Run: ./stop.sh" echo "" echo "═══════════════════════════════════════════════════════════════════════" STARTSCRIPT chmod +x start.sh echo -e "${GREEN}✓ start.sh created${NC}" # Stop script cat >stop.sh <<'STOPSCRIPT' #!/bin/bash PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$PROJECT_ROOT" echo "Stopping VitalLink system..." if [ -f logs/backend.pid ]; then kill $(cat logs/backend.pid) 2>/dev/null && echo "✓ Backend stopped" || echo "Backend not running" rm -f logs/backend.pid fi if [ -f logs/simulator.pid ]; then kill $(cat logs/simulator.pid) 2>/dev/null && echo "✓ Simulator stopped" || echo "Simulator not running" rm -f logs/simulator.pid fi echo "✓ VitalLink system stopped" STOPSCRIPT chmod +x stop.sh echo -e "${GREEN}✓ stop.sh created${NC}" # Test script cat >test.sh <<'TESTSCRIPT' #!/bin/bash PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$PROJECT_ROOT" source venv/bin/activate echo "Running VitalLink Test Suite..." echo "" python tests/test_suite.py TESTSCRIPT chmod +x test.sh echo -e "${GREEN}✓ test.sh created${NC}" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 7: Creating Documentation${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" # README cat >README.md <<'EOF' # VitalLink - ER Patient Monitoring System Emergency department patient monitoring system using smart wristbands. ## Quick Start 1. **Copy Code from Claude Artifacts:** - `backend/server.py` ← Copy "VitalLink Backend API (FastAPI)" - `simulator/wristband_simulator.py` ← Copy "VitalLink Wristband Simulator" - `tests/test_suite.py` ← Copy "VitalLink Complete Test Suite" - `frontend/dashboard/index.html` ← Insert React code from "Staff Dashboard" - `frontend/kiosk/index.html` ← Insert React code from "Check-in Kiosk" 2. **Test the System:** ```bash ./test.sh ``` 3. **Start the System:** ```bash ./start.sh ``` 4. **Access the Interfaces:** - API Documentation: http://localhost:8000/docs - Staff Dashboard: Open `frontend/dashboard/index.html` in browser - Check-in Kiosk: Open `frontend/kiosk/index.html` in browser 5. **Stop the System:** ```bash ./stop.sh ``` ## Project Structure ``` vitallink/ ├── backend/ # FastAPI server ├── simulator/ # Wristband simulator ├── frontend/ # Web interfaces │ ├── dashboard/ # Staff monitoring │ └── kiosk/ # Patient check-in ├── tests/ # Test suite ├── logs/ # System logs └── venv/ # Python virtual env ``` ## Commands - `./start.sh` - Start backend + simulator - `./stop.sh` - Stop all services - `./test.sh` - Run test suite - `tail -f logs/backend.log` - View backend logs - `tail -f logs/simulator.log` - View simulator logs ## Testing ```bash # Run all tests ./test.sh # Test API curl http://localhost:8000/api/stats # Create test patient curl -X POST http://localhost:8000/api/checkin \ -H "Content-Type: application/json" \ -d '{"firstName":"Test","lastName":"Patient","dob":"1990-01-01","symptoms":["Fever"],"severity":"moderate"}' ``` ## Next Steps See `docs/SETUP_GUIDE.md` for detailed instructions. EOF echo -e "${GREEN}✓ README.md created${NC}" # Setup guide cat >docs/SETUP_GUIDE.md <<'EOF' # Detailed Setup Guide ## Copying Code from Claude Artifacts ### 1. Backend Server (backend/server.py) Open the artifact titled **"VitalLink Backend API (FastAPI)"** and copy the ENTIRE Python code. Paste it into `backend/server.py`. ### 2. Wristband Simulator (simulator/wristband_simulator.py) Open the artifact titled **"VitalLink Wristband Simulator & Base Station"** and copy the ENTIRE Python code. Paste it into `simulator/wristband_simulator.py`. ### 3. Test Suite (tests/test_suite.py) Open the artifact titled **"VitalLink Complete Test Suite"** and copy the ENTIRE Python code. Paste it into `tests/test_suite.py`. ### 4. Staff Dashboard (frontend/dashboard/index.html) 1. Open the artifact titled **"VitalLink Staff Monitoring Dashboard"** 2. Copy the ENTIRE React component code 3. Open `frontend/dashboard/index.html` in a text editor 4. Find the TODO comment section 5. Paste the React code there 6. Remove the line `export default StaffDashboard;` 7. Add these lines at the end: ```javascript const root = ReactDOM.createRoot(document.getElementById('root')); root.render(); ``` ### 5. Check-in Kiosk (frontend/kiosk/index.html) Follow the same process as the dashboard, but use the **"VitalLink Check-in Kiosk"** artifact. ## Verification After copying all code: ```bash # Activate virtual environment source venv/bin/activate # Run tests ./test.sh # Start system ./start.sh # In another terminal, test API curl http://localhost:8000/api/stats ``` If everything works, you should see JSON output from the API. EOF echo -e "${GREEN}✓ docs/SETUP_GUIDE.md created${NC}" # .gitignore cat >.gitignore <<'EOF' __pycache__/ *.py[cod] venv/ logs/ *.log *.pid .DS_Store EOF echo -e "${GREEN}✓ .gitignore created${NC}" echo "" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" echo -e "${CYAN}STEP 8: Final Setup${NC}" echo -e "${CYAN}═══════════════════════════════════════════════════════════════════════${NC}" # Create empty log directory touch logs/.gitkeep # Deactivate venv for clean state deactivate 2>/dev/null || true echo -e "${GREEN}✓ Project setup complete!${NC}" echo "" echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}║ ✅ Installation Complete! ║${NC}" echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════════════╝${NC}" echo "" echo -e "${YELLOW}📁 Project Location:${NC} $PROJECT_ROOT" echo "" echo -e "${YELLOW}🔔 IMPORTANT - Next Steps:${NC}" echo "" echo -e "${CYAN}1. Copy Code from Claude Artifacts:${NC}" echo " Open each artifact in Claude and copy the code to these files:" echo " • backend/server.py" echo " • simulator/wristband_simulator.py" echo " • tests/test_suite.py" echo " • frontend/dashboard/index.html (insert React code)" echo " • frontend/kiosk/index.html (insert React code)" echo "" echo -e "${CYAN}2. Navigate to project:${NC}" echo " cd $PROJECT_ROOT" echo "" echo -e "${CYAN}3. Run tests:${NC}" echo " ./test.sh" echo "" echo -e "${CYAN}4. Start the system:${NC}" echo " ./start.sh" echo "" echo -e "${CYAN}5. Open interfaces:${NC}" echo " xdg-open frontend/dashboard/index.html" echo " xdg-open frontend/kiosk/index.html" echo "" echo -e "${GREEN}📖 Full documentation:${NC} cat docs/SETUP_GUIDE.md" echo "" echo -e "${BLUE}═══════════════════════════════════════════════════════════════════════${NC}" echo ""