A full-stack web application for managing and visualizing medical test records with secure authentication and real-time data visualization.
- Frontend: React + TypeScript + Vite + Tailwind CSS
- Backend: FastAPI + Python + SQLAlchemy
- Database: PostgreSQL
- Authentication: JWT with access/refresh tokens
- Email: SMTP for verification and password reset
- Containerization: Docker + Docker Compose
- Docker and Docker Compose
- Node.js 18+ (for local development)
- Python 3.11+ (for local development)
-
Clone the repository
git clone <repository-url> cd labsmonitor
-
Start the development environment
docker-compose up -d
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- Database: localhost:5432
-
Stop the environment
docker-compose down
- Docker and Docker Compose installed on production server
- Domain name with SSL certificate
- SMTP email service configured
- PostgreSQL database (or use the included one)
-
Create production environment file
cp env.prod.template .env.prod
-
Edit
.env.prodwith your production values# Database Configuration DB_NAME=medtest_prod DB_USER=medtest_user DB_PASSWORD=your_secure_password_here # Security (Generate secure keys) SECRET_KEY=your_very_long_random_secret_key_here JWT_SECRET_KEY=your_jwt_secret_key_here # Email Configuration SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your_email@gmail.com SMTP_PASSWORD=your_app_password_here # Application Configuration ENVIRONMENT=production DEBUG=false LOG_LEVEL=INFO # CORS Origins (your domain) ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
-
Generate secure secrets
# Generate SECRET_KEY openssl rand -hex 32 # Generate JWT_SECRET_KEY openssl rand -hex 32
Option A: Let's Encrypt (Recommended)
# Install certbot
sudo apt-get update
sudo apt-get install certbot
# Get certificate
sudo certbot certonly --standalone -d yourdomain.com
# Copy certificates to project directory
sudo cp /etc/letsencrypt/live/yourdomain.com/fullchain.pem ./ssl/cert.pem
sudo cp /etc/letsencrypt/live/yourdomain.com/privkey.pem ./ssl/key.pemOption B: Self-signed (Development only)
mkdir ssl
openssl req -x509 -newkey rsa:4096 -keyout ssl/key.pem -out ssl/cert.pem -days 365 -nodes-
Create production database
# If using external PostgreSQL createdb medtest_prod createuser medtest_user psql -c "ALTER USER medtest_user PASSWORD 'your_secure_password';" psql -c "GRANT ALL PRIVILEGES ON DATABASE medtest_prod TO medtest_user;"
-
Run database migrations
# Apply migrations docker-compose -f docker-compose.prod.yml exec backend python -m alembic upgrade head
-
Build and start production containers
docker-compose -f docker-compose.prod.yml up -d --build
-
Verify deployment
# Check container status docker-compose -f docker-compose.prod.yml ps # Check logs docker-compose -f docker-compose.prod.yml logs -f
-
Access your application
- Frontend: https://yourdomain.com
- API: https://yourdomain.com/api
-
Create admin user
# Access the application and register your first admin user # Or use the API directly curl -X POST https://yourdomain.com/api/auth/register \ -H "Content-Type: application/json" \ -d '{"email":"admin@yourdomain.com","password":"secure_password","firstName":"Admin","lastName":"User"}'
-
Set up monitoring
# Check application health curl https://yourdomain.com/api/health # Monitor logs docker-compose -f docker-compose.prod.yml logs -f backend
-
Configure backups
# Database backup script #!/bin/bash docker-compose -f docker-compose.prod.yml exec -T db pg_dump -U $DB_USER $DB_NAME > backup_$(date +%Y%m%d_%H%M%S).sql
- Environment Variables: Set in
frontend/.env.production - API URL: Configure
VITE_API_URLfor backend endpoint - Build Optimization: Production builds are optimized and minified
- Database: Configure
DATABASE_URLin environment - Email: Set SMTP credentials for email functionality
- Security: Configure CORS origins and JWT settings
- Logging: Set log level and output format
- SSL: Configure SSL certificates in
frontend/nginx.conf - Caching: Static assets are cached for 1 year
- Compression: Gzip compression enabled
- Security Headers: XSS protection, frame options, etc.
- Use strong, unique passwords for all services
- Generate secure random keys for JWT and application secrets
- Configure proper CORS origins
- Set up SSL/TLS certificates
- Enable security headers
- Use non-root containers
- Implement rate limiting
- Set up monitoring and alerting
- Configure automated backups
- Keep dependencies updated
# Never commit .env.prod to version control
echo ".env.prod" >> .gitignore
# Use secrets management in production
# Consider using Docker Secrets or HashiCorp Vault# Application health
curl https://yourdomain.com/api/health
# Database health
docker-compose -f docker-compose.prod.yml exec db pg_isready
# Container status
docker-compose -f docker-compose.prod.yml ps# View all logs
docker-compose -f docker-compose.prod.yml logs
# Follow specific service logs
docker-compose -f docker-compose.prod.yml logs -f backend
docker-compose -f docker-compose.prod.yml logs -f frontend# Update application
git pull origin main
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml up -d --build
# Update database schema
docker-compose -f docker-compose.prod.yml exec backend python -m alembic upgrade head-
Database Connection Failed
# Check database container docker-compose -f docker-compose.prod.yml logs db # Verify environment variables docker-compose -f docker-compose.prod.yml exec backend env | grep DATABASE
-
SSL Certificate Issues
# Check certificate validity openssl x509 -in ssl/cert.pem -text -noout # Renew Let's Encrypt certificate sudo certbot renew
-
Email Not Working
# Check SMTP configuration docker-compose -f docker-compose.prod.yml exec backend python -c "from email_service import test_smtp; test_smtp()"
-
High Memory Usage
# Monitor resource usage docker stats # Optimize container resources in docker-compose.prod.yml
Once deployed, access the interactive API documentation at:
- Swagger UI: https://yourdomain.com/docs
- ReDoc: https://yourdomain.com/redoc
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Check the troubleshooting section above
- Review the API documentation
Note: This is a medical application started with Bolt.new. Ensure compliance with relevant healthcare regulations (HIPAA, GDPR, etc.) before deploying in production environments.