A modern web application designed to help users find natural alternatives to pharmaceutical drugs and supplements. The app integrates with the OpenFDA API and uses an intelligent database-first search strategy to provide accurate, science-backed natural remedy recommendations.
- Fast Search: Find natural alternatives to common pharmaceuticals quickly
- OpenFDA Integration: Search thousands of FDA-approved drugs and supplements
- Database-First Strategy: Intelligent caching for faster subsequent searches
- Dark/Light Mode: Toggle between light and dark themes for comfortable viewing
- Search History: Keep track of your recent searches for easy reference
- Fuzzy Search: Find results even when your spelling isn't perfect
- Filtering: Filter results by category or matching nutrients
- Detailed Remedy Information: Usage, dosage, precautions, and scientific references
- Favorites System: Save your favorite remedies for quick access
- Mobile-Friendly Design: Works on all devices
- React 19: For building the user interface
- Next.js 16: For server-side rendering and API routes
- Bun: Package manager and runtime
- TypeScript 5: For type safety
- Prisma: ORM for database operations
- PostgreSQL: Primary database (local via Docker)
- TailwindCSS 4: For styling
- Framer Motion: For animations
- next-themes: For dark/light mode
- OpenFDA API: For pharmaceutical data
- Levenshtein Algorithm: For fuzzy search functionality
- Node.js 18+
- Bun 1.3+
- Docker (for local PostgreSQL)
- Clone the repository
git clone https://github.com/gr8monk3ys/remedi.git
cd remedi- Install dependencies
bun install- Set up environment variables
cp .env.example .env
# Edit .env with your configuration (optional for basic usage)- Start the database
docker-compose up -d postgres- Set up the database
# Generate Prisma client
bunx prisma generate
# Run database migrations
bunx prisma migrate dev
# Seed the database with initial data
bunx prisma db seed- Run the development server
bun run dev- Open http://localhost:3000 in your browser
Optional: visit http://localhost:3000/landing for the GTM landing page.
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── remedy/[id]/ # Remedy detail API
│ │ └── search/ # Search API
│ ├── remedy/[id]/ # Remedy detail pages
│ ├── layout.tsx # Root layout with ThemeProvider
│ ├── page.tsx # Home page
│ └── globals.css # Global styles
├── components/ # React components
│ ├── theme-provider.tsx # Manages theme state
│ └── ui/ # UI components
│ ├── aurora-background.tsx # Background effect
│ ├── demo.tsx # Demo component
│ ├── filter.tsx # Filter component
│ ├── header.tsx # Header component
│ ├── pagination.tsx # Pagination component
│ ├── search.tsx # Search component
│ └── theme-toggle.tsx # Theme toggle button
├── hooks/ # Custom React hooks
│ └── use-local-storage.ts # localStorage hook
├── lib/ # Utility functions
│ ├── db.ts # Prisma database utilities
│ ├── fuzzy-search.ts # Fuzzy search implementation
│ ├── openFDA.ts # OpenFDA API integration
│ ├── remedyMapping.ts # Remedy matching algorithm
│ ├── types.ts # Shared TypeScript types
│ └── utils.ts # General utilities
├── prisma/ # Database files
│ ├── migrations/ # Database migrations
│ ├── schema.prisma # Database schema
│ ├── seed.ts # Database seed script
│ └── dev.db # SQLite database (development)
├── public/ # Static assets
├── .env.example # Environment variables template
├── next.config.ts # Next.js configuration
├── package.json # Project dependencies
├── tailwind.config.ts # Tailwind CSS configuration
├── tsconfig.json # TypeScript configuration
├── CLAUDE.md # Architecture guide
└── TODO.md # Task tracking
Search for natural alternatives to a pharmaceutical using a three-tier strategy:
- Database search (fastest)
- OpenFDA API (cached to database)
- Mock data fallback
Parameters:
query(string): The name of the pharmaceutical to search for
Example Request:
curl "http://localhost:3000/api/search?query=ibuprofen"Example Response:
[
{
"id": "turmeric",
"name": "Turmeric",
"description": "Contains curcumin which has anti-inflammatory properties.",
"imageUrl": "https://images.unsplash.com/photo-1615485500704-8e990f9900f7",
"category": "Herbal Remedy",
"matchingNutrients": ["Curcumin", "Anti-inflammatory compounds"],
"similarityScore": 0.85
}
]Get detailed information about a specific natural remedy.
Parameters:
id(string): The remedy ID
Example Request:
curl "http://localhost:3000/api/remedy/turmeric"Example Response:
{
"id": "turmeric",
"name": "Turmeric",
"description": "Contains curcumin which has anti-inflammatory properties.",
"imageUrl": "https://images.unsplash.com/photo-1615485500704-8e990f9900f7",
"category": "Herbal Remedy",
"matchingNutrients": ["Curcumin"],
"similarityScore": 0.85,
"usage": "Can be used in cooking, taken as a supplement, or made into a paste...",
"dosage": "500-2,000 mg of turmeric extract per day",
"precautions": "May interact with blood thinners...",
"scientificInfo": "The active compound in turmeric, curcumin, inhibits...",
"references": [
{
"title": "Curcumin: A Review of Its Effects on Human Health",
"url": "https://www.mdpi.com/2072-6643/9/10/1047"
}
],
"relatedRemedies": [{ "id": "ginger", "name": "Ginger" }]
}The application uses Prisma ORM with three main models:
-
Pharmaceutical - Stores drug/supplement information
- FDA ID, name, description, category
- Ingredients and benefits (JSON arrays)
- Usage, warnings, interactions
-
NaturalRemedy - Stores natural alternative information
- Name, description, category, image
- Ingredients, benefits, usage, dosage
- Precautions, scientific info, references
- Evidence level (Strong, Moderate, Limited, Traditional)
-
NaturalRemedyMapping - Links pharmaceuticals to remedies
- Similarity score (0-1)
- Matching nutrients
- Replacement type (Alternative, Complementary, Supportive)
The app implements an intelligent three-tier search:
- Database First: Searches local database for cached pharmaceuticals and their remedy mappings (instant results)
- OpenFDA API: If not in database, queries FDA API and automatically caches results
- Mock Data Fallback: Uses in-memory data for development/testing
- ✅ Prisma ORM with type-safe queries
- ✅ Automatic caching of FDA API results
- ✅ Efficient JSON field parsing for SQLite
- ✅ Database-first search strategy
- ✅ Fuzzy matching with Levenshtein distance
- ✅ Spelling correction and query normalization
- ✅ Relevance scoring for results
- ✅ Search history (localStorage)
- ✅ Dark/Light mode with system preference detection
- ✅ Favorites system (localStorage)
- ✅ Detailed remedy pages with scientific references
- ✅ Responsive design for all screen sizes
- ✅ Loading states and error handling
- ✅ Full TypeScript support with shared types
- ✅ ESLint configuration
- ✅ Environment variable templates
- ✅ Comprehensive documentation (CLAUDE.md, TODO.md)
# Development
bun run dev # Start development server
bun run build # Build for production
bun run start # Start production server
bun run lint # Run ESLint
bun run init # Generate Prisma client, migrate, seed
bun run health:check # Verify database connectivity
bun run health:check:http # Verify /api/health endpoint
bun run predeploy # Run pre-deploy verification suite
# Database
bunx prisma generate # Generate Prisma client
bunx prisma migrate dev # Run migrations
bunx prisma studio # Open Prisma Studio GUI
bunx prisma db seed # Seed database with dataCopy .env.example to .env and configure:
DATABASE_URL="postgresql://remedi:remedi_dev@localhost:5433/remedi?schema=public"
OPENAI_API_KEY="your-key" # Optional: AI features
OPENFDA_API_KEY="your-key" # Optional: higher rate limits- Pages that depend on Prisma queries are configured as dynamic to avoid build-time DB failures.
sitemap.xmlis generated dynamically and revalidated daily.
See docs/production-readiness.md for the verification checklist and CI steps.
P1001: Can't reach database server: Verify Postgres is running and thatDATABASE_URLpoints to port5433(local Docker mapping).listen EPERMin Playwright: Runbun run test:e2elocally/CI where the runtime can bind ports.- Build warnings from
@prisma/instrumentation: These come from Sentry’s Prisma integration and are expected with webpack builds.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See TODO.md for a list of planned features and improvements.
See TODO.md for the complete roadmap. Key priorities:
- Expand database seed with more remedies
- Add testing infrastructure (Vitest)
- Implement user authentication
- Add AI-powered remedy matching
- Mobile app (PWA or React Native)
- CLAUDE.md - Architecture and implementation guide
- TODO.md - Task tracking and roadmap
- COMPLETED_TASKS.md - Completed work summary
This project is licensed under the MIT License - see the LICENSE file for details.
Important: This application is for informational and educational purposes only. It is not intended to be a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition or medication changes. Never disregard professional medical advice or delay seeking it because of information you have read in this application.