Skip to content
ohcnetworkPublic

About

Care is a Digital Public Good enabling accelerated healthcare delivery.

Topics

Resources

Code of conduct

Security policy

Stars

695 stars

Watchers

19 watching

Forks

Latest commit

 

History

11,709 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CARE

The web frontend of CARE, an open source EMR and hospital management system.
Our goal is to continuously improve the quality and accessibility of public healthcare services using digital tools.

Verified Digital Public Good MIT License Playwright Tests Code scanning Open in GitHub Codespaces

Staging · Docs · API reference · Backend · Report an issue

Built with React 19 · TypeScript · Vite · TanStack Router & Query · Tailwind CSS v4 · shadcn/ui · Playwright

Table of contents

Quick start

You need Node.js 24 (pinned in .node-version) and npm.

git clone https://github.com/ohcnetwork/care_fe.git
cd care_fe
npm install
npm run dev

Open localhost:4000. The page reloads when you save a file.

By default the app talks to the hosted staging API at careapi.ohc.network (set in .env), so you can work on the UI without running a backend. To sign in with the demo accounts, run the backend locally.

Tip

Working on several branches or git worktrees at once? Start the dev server with portless instead of npm run dev. It picks a free port and serves each checkout at its own stable https://<name>.localhost URL, so the dev servers don't fight over ports or share cookies and storage.

Note

Prefer a ready-made environment? Open the repository in GitHub Codespaces or any Dev Container tool. It installs the dependencies and starts the dev server for you.

Run against a local backend

  1. Set up the CARE backend by following the backend docs. Run it on port 9000 and load the fixtures (python manage.py load_fixtures) to get the demo data.

  2. Create a .env.local file in this repository (it is git-ignored):

    REACT_CARE_API_URL=http://127.0.0.1:9000
  3. Restart the dev server and sign in with one of the accounts below.

    In a dev container or Codespace, REACT_CARE_API_URL is already set in the environment, and it takes priority over .env.local. Stop the dev server that started with the container, and start it with REACT_CARE_API_URL=http://127.0.0.1:9000 npm run dev instead.

Demo accounts. These come from the backend fixtures. Use them only on your local setup.

Role Username Password
Superuser admin admin
Doctor care-doctor Ohcn@123
Staff care-staff Ohcn@123
Nurse care-nurse Ohcn@123
Administrator care-admin Ohcn@123
Volunteer care-volunteer Ohcn@123
Facility Admin care-fac-admin Ohcn@123
Admin care-role-admin Ohcn@123
Manager care-role-manager Ohcn@123
Member care-role-member Ohcn@123

Patient sign-in uses a one-time password sent by SMS. Non-production backends (your local backend and staging) don't send the SMS. Use the OTP 45612.

Everyday commands

Command What it does
npm run dev Start the dev server at localhost:4000
portless Start the dev server at a stable https://<name>.localhost URL
npm run typecheck Type-check the project with tsc
npm run lint Run ESLint (npm run lint-fix to fix what it can)
npm run format Format src/ and tests/ with Prettier
npm run test:unit Run the unit tests
npm run playwright:test Run the end-to-end tests (see Testing)
npm run knip Find unused files, exports and dependencies
npm run build Build for production into build/
npm run preview Serve the production build at localhost:4000

A pre-commit hook runs Prettier and ESLint on the files you stage, and sorts the locale files.

Configuration

The app reads its configuration from REACT_* environment variables, which care.config.ts collects into one typed object. Vite loads them from these files:

File Purpose
.env Committed defaults (points to the staging API)
.env.local Your local overrides. Git-ignored
.example.env Every supported variable, with a description and its default

Variables you are most likely to change:

Variable What it sets
REACT_CARE_API_URL Backend URL, without the /api prefix. Leave empty for same-origin requests
REACT_CARE_URL_MAP A JSON map from frontend origin to backend URL, to use several backends at once
REACT_ENABLED_APPS The Care Apps to load
REACT_ALLOWED_LOCALES The languages users can switch between
REACT_CUSTOM_REMOTE_I18N_URL A URL to load translation overrides from (see Translations)
REACT_MAIN_LOGO and others White-labelling: logos, title, description and more
Use several backends from one dev server

REACT_CARE_URL_MAP picks the backend from the origin you open the app on. Put it in .env.local:

REACT_CARE_URL_MAP='{"http://care.localhost": "https://careapi.ohc.network", "http://develop.localhost": "https://develop-api.ohc.network", "http://dev.localhost": "http://localhost:9000"}'

# Used when no origin matches
REACT_CARE_API_URL=https://careapi.ohc.network

Then put a reverse proxy in front of the dev server so that those hostnames reach it. With nginx (brew install nginx on macOS, sudo apt-get install nginx on Ubuntu), save this as /opt/homebrew/etc/nginx/servers/care (macOS) or /etc/nginx/sites-enabled/care (Linux):

server {
  listen 80;
  server_name care.localhost develop.localhost dev.localhost;

  location / {
    proxy_pass http://localhost:4000/;
    proxy_set_header Host $host;
  }
}

Restart nginx (brew services restart nginx or sudo service nginx restart) and open http://care.localhost. On Debian and Ubuntu, you may need to remove sites-enabled/default first.

Project structure

src/
├── routes/            File-based routes (TanStack Router)
├── pages/             Page components, by feature
├── components/        Feature components
│   └── ui/            shadcn/ui primitives
├── types/             Domain types and typed API routes (*Api.ts)
├── Utils/request/     query() and mutate() helpers for TanStack Query
├── hooks/             Shared React hooks
├── atoms/             Client state (Jotai)
├── context/           React contexts (permissions, shortcuts)
├── Providers/         Auth and session providers
├── lib/router/        Router helpers (navigate, HrefLink, query params)
└── CAREUI/            CARE's healthcare icon set and custom UI
public/locale/         Translations (en.json is the source)
tests/                 Playwright end-to-end tests
docs/                  Architecture and contributor guides
care.config.ts         Runtime configuration

How the app is built

  • Routing. Every page is a file in src/routes/. Staff pages are in src/routes/_app/. The file name gives the URL: facility.$facilityId.overview.tsx is /facility/:facilityId/overview. The dev server generates src/routeTree.gen.ts from these files. Commit it with your route changes, and don't edit it by hand.

  • Links and navigation. Use <Link to="/facility/$facilityId/overview" params={{ facilityId }}> from @tanstack/react-router, and navigate() from @/lib/router/navigate in event handlers. TypeScript checks both against the route tree, so a link to a page that doesn't exist fails the type check.

  • Server data. API routes are typed objects in src/types/{domain}/{domain}Api.ts. Fetch them with TanStack Query and the query() and mutate() helpers:

    const { data } = useQuery({
      queryKey: ["users"],
      queryFn: query(userApi.list),
    });
  • UI. Use the shadcn/ui components in src/components/ui/, Tailwind CSS v4, and lucide-react icons. Forms use react-hook-form with zod.

For the full picture, read docs/architecture.md. To add a page, follow Routing in AGENTS.md.

Translations

Every user-facing string must go through i18next. Add new English strings to public/locale/en.json. Don't edit the other languages in pull requests: translators contribute them on Crowdin.

Load translations from a remote URL

Set REACT_CUSTOM_REMOTE_I18N_URL to load translations from ${REACT_CUSTOM_REMOTE_I18N_URL}/{lang}.json. Keys in the remote file override the local ones, and keys missing from it fall back to public/locale/{lang}.json.

REACT_CUSTOM_REMOTE_I18N_URL=https://cdn.example.com/i18n

Testing

Unit tests run with the Node test runner: npm run test:unit.

End-to-end tests use Playwright. They run against a production build and a local backend on port 9000 with the fixtures loaded (see Run against a local backend). Stop the dev server first: Playwright serves the build on port 4000, and if a dev server is already running there, it tests the dev server instead.

npm run playwright:install   # Install the browsers (first time only)
npm run build                # The tests run against the production build
npm run playwright:test      # Run all tests
Command What it does
npm run playwright:test -- tests/auth/ Run one directory or file
npm run playwright:test -- -g "<test name>" Run the tests whose name matches
npm run playwright:test:ui Open the interactive UI mode
npm run playwright:test:headed Run with a visible browser
npm run playwright:show-report Open the HTML report
npm run playwright:db-reset Create a clean database snapshot

Tests create data, so re-runs can collide. Set CARE_BACKEND_DIR to your backend checkout and run npm run playwright:db-reset once. After that, each local run restores the clean snapshot first.

Warning

npm run playwright:db-reset deletes and recreates the backend database (care, or the one named in POSTGRES_DB), and each local test run restores the snapshot over it. Back up any local data you want to keep first.

Read docs/testing.md for the full setup, and tests/PLAYWRIGHT_GUIDE.md before you write a test.

Care Apps (plugins)

Care Apps are micro-frontends that add pages, tabs and components to CARE at runtime, through Module Federation. List the apps to load in REACT_ENABLED_APPS, as org/repo (served from GitHub Pages) or org/repo@host/path/to/remoteEntry.js:

REACT_ENABLED_APPS="ohcnetwork/care_scribe_fe@localhost:4173/assets/remoteEntry.js"

To build or debug one, see docs/care-apps-local-dev.md and docs/care-apps-plugin-overrides.md.

Contributing

We welcome contributions of every size. Here is how a change gets in:

  1. Pick an issue and comment on it to say that you are working on it.
  2. Branch from develop with a name like issues/7001/edit-prescriptions.
  3. Open a pull request against develop and fill in the template:
    • Link the issue with a closing keyword (Fixes #7001).
    • Attach screenshots or a short video of any UI change.
    • Tag @ohcnetwork/care-fe-code-reviewers for a faster review.
  4. Try the preview. Every pull request gets its own preview deployment. Its link is posted on the pull request.
  5. Review and QA. After code review, the pull request gets the needs testing label and goes to QA. When QA passes, it gets the Tested label and is queued for merge.

When a change is merged, develop deploys automatically to care.ohc.network.

Note

Core team members who push branches to this repository must start pull request titles with a JIRA key, for example [ENG-123] Add support for editing prescriptions.

Please read our Code of Conduct. To report a vulnerability, follow SECURITY.md.

Using an AI coding agent? Its guidance is in AGENTS.md. Claude Code, Codex, Cursor, Copilot and Gemini all read it.

Production builds and self-hosting

npm run build     # Build into build/
npm run preview   # Serve that build at localhost:4000

The output in build/ is a static site that you can host on any static file server or CDN. The Dockerfile builds the same output and serves it with nginx on port 80:

docker build -t care_fe .
docker run -p 8080:80 care_fe

To deploy without building, download the build/ folder that CI publishes for develop, the 3.* branches and each release. See Prebuilt bundles.

Important

Vite reads the REACT_* variables at build time, so set them before you build. For the Docker image, put them in .env.local before you run docker build: the build reads the files in the repository, not the variables in your shell. To change most settings without a rebuild, serve your own /runtime-env.js or pass them to the container with docker run -e: see Runtime configuration. When you upgrade an existing installation, check UPGRADING.md for breaking changes.

Documentation


Digital Public Goods Badge

CARE is a Digital Public Good, released under the MIT License.

About

Care is a Digital Public Good enabling accelerated healthcare delivery.

Topics

Resources

Code of conduct

Security policy

Stars

695 stars

Watchers

19 watching

Forks

Releases

Packages

Used by

Contributors

Languages