Project Summary
Relevant source files
The following files were used as context for generating this wiki page:The Medical Calculators project is a web application designed to provide a suite of essential calculators for healthcare professionals. It is built using a modern technology stack, featuring a responsive, dark-themed user interface. The primary goal is to offer a reliable and intuitive tool for clinical decision support, covering areas like electrolyte correction, antibiotic prophylaxis, and pediatric dosing.
The application is developed with Next.js 14, TypeScript, and Tailwind CSS, ensuring type safety, a robust framework, and a utility-first styling approach. It includes several specialized calculators, each with its own set of medical algorithms, safety warnings, and clinical recommendations based on established guidelines.
Sources: PROJECT_SUMMARY.md:3-7, README.md:3-5
Technical Architecture
The project is a frontend application built with Next.js and React. It follows a component-based architecture with a clear separation of concerns.
Sources: README.md:20-22, PROJECT_SUMMARY.md:29-34
Technology Stack
The core technologies used in this project are:
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 15.4.5 | React framework with App Router for UI and routing. |
| React | 19.1.0 | UI library for building components. |
| TypeScript | ^5 | Provides static typing for the codebase. |
| Tailwind CSS | ^4 | Utility-first CSS framework for styling. |
Sources: package.json:9-19, PROJECT_SUMMARY.md:29-34, README.md:20-25
Project Structure
The project's directory structure is organized to separate different concerns of the application, such as pages, reusable components, calculator logic, and type definitions.
This diagram illustrates the high-level folder structure of the src directory.
src/app/: Contains Next.js App Router files, including the main page (page.tsx) and root layout (layout.tsx).src/components/: Holds reusable UI components likeCard,Button, andNumberInput.src/calculators/: Each file in this directory represents a specific medical calculator component.src/types/: Contains TypeScript interface definitions for data structures.src/i18n/: Manages internationalization, providing translation strings for different languages.src/data/: Stores medical data and references, such as the pediatric medications database.
Sources: README.md:27-42, PROJECT_SUMMARY.md:83-93, CONTRIBUTING.md:100-106
Available Calculators
The application provides several medical calculators, each designed for a specific clinical purpose. New calculators can be added by following the contribution guidelines.
Sources: PROJECT_SUMMARY.md:9-27, README.md:7-18
| Calculator | Description | Source File |
|---|---|---|
| Potassium Correction | Calculates potassium correction doses using aspartame or potassium chloride. | PotassiumCorrectionCalculator.tsx |
| Antibiotic Prophylaxis | Provides antibiotic selection based on wound classification, patient factors, and allergy history. | AntibioticProphylaxisCalculator.tsx |
| Pediatric Dose Calculator | Calculates pediatric medication doses based on age and weight, with safety checks. | PediatricDoseCalculator.tsx |
| Sodium Correction | Calculates correction for hyponatremia and hypernatremia using established formulas. | SodiumCorrectionCalculator.tsx |
| Blood Gas Analysis | Interprets acid-base status from blood gas data, including anion gap and compensation analysis. | BloodGasAnalysisCalculator.tsx |
| Infusion Therapy | Calculates fluid requirements, including maintenance, deficit, and ongoing losses. | InfusionTherapyCalculator.tsx |
Sources: PROJECT_SUMMARY.md:9-27, README.md:7-18, src/calculators/BloodGasAnalysisCalculator.tsx, src/calculators/InfusionTherapyCalculator.tsx, src/calculators/PediatricDoseCalculator.tsx
Calculator Integration Flow
The main page (src/app/page.tsx) manages the display of the active calculator. Users can switch between different calculators using navigation buttons.
The following diagram shows how a new calculator is integrated into the main application page.
Sources: CONTRIBUTING.md:46-77
Core Features
Internationalization (i18n)
The application supports multiple languages (en, ru, uk) through a dedicated internationalization module. The LanguageProvider component wraps the application layout, making translation strings available throughout the component tree.
The translations.ts file defines a Translations interface and a translations object containing the text for all supported languages.
This diagram shows how the LanguageProvider provides context to the application.
Reusable UI Components
The project emphasizes code reuse through a set of standardized UI components located in src/components/. These components ensure a consistent look and feel across all calculators.
Key components include:
Card: A container for wrapping calculators and results sections.NumberInput: A specialized input for numeric values with validation.Select: A dropdown component for selection from a list of options.Checkbox: A standard checkbox for boolean inputs.Button: A versatile button component with different variants (primary,outline).
Sources: CONTRIBUTING.md:88-96, README.md:33-39
Safety and Clinical Guidelines
Medical accuracy and patient safety are central to the project.
- Safety Features: The application incorporates conservative correction rates, clinical warnings for severe cases, input validation, and educational disclaimers.
- Clinical Guidelines: Algorithms are based on established guidelines from organizations like the European Society of Endocrinology and the Infectious Diseases Society of America.
- Medical Disclaimer: A prominent disclaimer warns users that the calculators are for educational and decision support purposes and do not replace professional clinical judgment.
Sources: PROJECT_SUMMARY.md:63-81, README.md:44-47
Development and Deployment
The project is configured for both local development and production deployment.
Development Workflow
- Installation: Dependencies are installed using
npm install. - Local Server: The development server is started with
npm run dev --turbopack. - Production Build: A production-ready build is created with
npm run build.
Sources: package.json:4-8, DEPLOYMENT.md:5-15
Deployment
The application is designed for easy deployment on platforms like Vercel. The DEPLOYMENT.md file also provides instructions for deploying on Netlify or using Docker.
This flowchart outlines the automated deployment process on a platform like Vercel.
Sources: DEPLOYMENT.md:24-31, DEPLOYMENT.md:64-70
Contribution Guidelines
The project has a structured process for contributing, particularly for adding new calculators.
Adding a New Calculator
The process involves three main steps:
- Define Types: Create new TypeScript interfaces for the calculator's inputs and results in
src/types/index.ts. - Create Component: Build the new calculator as a React component in
src/calculators/. The component should manage its own state for inputs and results. - Integrate into Main Page: Import the new component into
src/app/page.tsxand add the necessary state and UI elements to display it.
This diagram visualizes the workflow for adding a new calculator.
Sources: CONTRIBUTING.md:5-77
Commits and Pull Requests
- Commits: The project follows the Conventional Commits specification.
- Pull Requests: PRs should include a description of changes, citation of medical sources, and screenshots where applicable.