Overview
This guide walks you through setting up OmniEHR on your local machine using Docker for MongoDB and npm workspaces for the application.Prerequisites
Before you begin, ensure you have the following installed:- Node.js v18 or higher
- npm v9 or higher
- Docker and Docker Compose
- OpenSSL (for generating encryption keys)
Quick Start
For experienced developers, here’s the quick setup:Detailed Setup Instructions
Step 1: Install Dependencies
OmniEHR uses npm workspaces to manage the monorepo structure with separateserver and client packages.
The project uses Node.js ES modules (
"type": "module") throughout. Make sure your Node.js version supports ESM.Step 2: Start MongoDB with Docker
OmniEHR requires MongoDB 7 for data persistence. The includeddocker-compose.yml provides a pre-configured MongoDB instance.
docker-compose.yml
- Uses MongoDB 7 official image
- Exposes port 27017 on localhost
- Creates
ehrdatabase automatically - Persists data in Docker volume
mongo_data - Restarts automatically unless manually stopped
MongoDB data persists across container restarts in the
mongo_data Docker volume.mongo:7 container running.
Alternative: Use Existing MongoDB
If you have an existing MongoDB instance, skip the Docker step and update MONGODB_URI in your .env file to point to your instance.
Step 3: Configure Environment Variables
Create environment files from the provided examples:Generate PHI Encryption Key
Generate a 256-bit encryption key (64 hexadecimal characters):server/.env as the PHI_ENCRYPTION_KEY value.
Server Environment Variables
Editserver/.env:
server/.env
For local development, uncomment and use
CORS_ORIGIN=http://localhost:5173 to allow the Vite dev server to communicate with the API.- Generate a strong random string for
JWT_SECRET(useopenssl rand -base64 32) - Use the 64-character hex key from earlier for
PHI_ENCRYPTION_KEY - Set
CORS_ORIGINto match your client URL (default Vite port is 5173)
Client Environment Variables
Editclient/.env:
client/.env
Step 4: Run the Application
npm run dev command starts both the server and client concurrently:
- API Server: http://localhost:4000
- Client UI: http://localhost:5173
- Server uses
nodemonfor hot-reloading on code changes - Client uses Vite dev server with HMR (Hot Module Replacement)
Step 5: Verify Installation
Check API Health
Access the UI
Open http://localhost:5173 in your browser. You should see the OmniEHR login page.Test Login
On first run, you’ll need to create an initial admin user. The application includes seed data or you can use the patient registration portal to test public endpoints.
Development Workflow
Available Scripts
From the project root:| Command | Description |
|---|---|
npm run dev | Run both server and client in development mode |
npm run dev:server | Run only the server with nodemon |
npm run dev:client | Run only the client with Vite |
npm run start | Start the server in production mode |
npm run lint | Run ESLint on both server and client |
Server Scripts
From theserver/ directory:
| Command | Description |
|---|---|
npm run dev | Start server with nodemon (auto-reload) |
npm run start | Start server without auto-reload |
npm run lint | Run ESLint on server code |
Client Scripts
From theclient/ directory:
| Command | Description |
|---|---|
npm run dev | Start Vite dev server with HMR |
npm run build | Build client for production |
npm run preview | Preview production build locally |
npm run lint | Run ESLint on client code |
Project Structure
Database Management
Access MongoDB Shell
docker ps.
View Database Contents
Reset Database
-v flag removes volumes, deleting all database data.
Troubleshooting
Port Already in Use
If port 4000 or 5173 is already in use: Server: ChangePORT in server/.env
Client: Vite will automatically try the next available port (5174, 5175, etc.)
MongoDB Connection Failed
Verify MongoDB is running:MONGODB_URI in server/.env matches your MongoDB connection string.
Environment Variables Not Loading
Make sure:.envfiles exist inserver/andclient/directories (not in root)- For client variables, prefix with
VITE_ - Restart the dev servers after changing environment variables
Module Not Found Errors
Runnpm install again from the root directory:
Encryption Key Error
If you see “PHI_ENCRYPTION_KEY must be a 64-char hex string”:- Generate a new key:
openssl rand -hex 32 - Ensure it’s exactly 64 hexadecimal characters
- No spaces or line breaks in the value
Next Steps
Environment Variables
Learn about all available configuration options
FHIR API Reference
Explore the FHIR R4 API endpoints
Security Features
Understand HIPAA-aligned security controls
Production Deployment
Deploy to production environments