Formulary is a backend-driven healthcare platform that enables users to search medicines, discover equivalent substitutes, and compare prices to identify cost-effective alternatives.
The system is designed as a read-heavy, high-performance API, optimized using caching and efficient database querying.
Patients often pay higher prices for branded medicines due to lack of visibility into cheaper substitutes with identical compositions.
Formulary provides:
- Fast medicine search
- Substitute discovery using composition-based mapping
- Price comparison across equivalent medicines
- Admin-controlled data management with bulk uploads
- Frontend: React, TailwindCSS
- Backend: Node.js, Express
- Database: PostgreSQL
- Caching: Redis
- Containerization : Docker, Docker Compose
- CI/CD : GitHub Actions
To handle a read-heavy load, we implemented a robust Redis caching layer on our search and substitute APIs.
| Endpoint | Before (DB) | After (Cache) | Improvement |
|---|---|---|---|
| Search | ~80–200 ms | ~7–12 ms | ~85% faster |
| Substitutes | ~120 ms | ~10–20 ms | ~80% faster |
git clone https://github.com/CodeByAshuu/formulary.git
cd formularycd server
npm install- Create a
.envfile in theserverdirectory with your Postgres and Redis credentials.
PORT=5000
DB_USER=postgres
DB_PASSWORD=password
DB_NAME=formulary_db
DB_HOST=localhost
DB_PORT=5432
REDIS_URL=redis://localhost:6379
JWT_SECRET= your_secret_key
ADMIN_PASSWORD=admin
ADMIN_EMAIL=admin@example.com- Seed the database (if applicable) and start the server:
npm run devcd ../client
npm install
npm run devThe application utilizes Redis to cache API responses. You can run Redis locally either by installing it directly or by using Docker.
Running Redis via Docker ensures a clean environment without system-level installations.
- Ensure Docker is installed and running on your machine.
- Run the following command to start a Redis container:
docker run -d --name formulary-redis -p 6379:6379 redis
- The server will automatically connect to
redis://localhost:6379. - Open Redis CLI inside container
docker exec -it formulary-redis redis-cli - Clear Cache (everything)
FLUSHALL
- Windows: Install using WSL (Windows Subsystem for Linux) and run:
Alternatively, download the pre-compiled Windows port of Redis from GitHub.
sudo apt-get install redis-server sudo service redis-server start
- Mac: Use Homebrew:
brew install redis brew services start redis
- Linux: Use your package manager (e.g., APT):
sudo apt install redis-server sudo systemctl start redis-server
Once running locally, the application will automatically connect to the default port 6379.
- High-performance search with indexing
- Redis caching with TTL and invalidation
- Bulk CSV upload for medicines
- Automatic substitute linking using composition
- Secure admin APIs with JWT authentication
- Containerized deployment
-
CI pipeline:
- Linting + dependency install
- PostgreSQL + Redis service containers
- Backend smoke test
-
CD pipeline:
- Docker image build
- Push to GitHub Container Registry (GHCR)
- Fuzzy search (typo tolerance)
- Advanced filtering (price range, manufacturer)
- Rate limiting
- Observability (logs, metrics)
Sagar Sahu




