Development Workflow
Relevant source files
The following files were used as context for generating this wiki page:
- CONTRIBUTING.md
- DEPLOYMENT.md
- PROJECT_SUMMARY.md
- README.md
- package.json
- src/app/layout.tsx
- src/calculators/AntibioticProphylaxisCalculator.tsx
- src/calculators/BloodGasAnalysisCalculator.tsx
- src/calculators/InfusionTherapyCalculator.tsx
- src/calculators/PediatricDoseCalculator.tsx
- src/i18n/translations.ts
This document outlines the development workflow for the Medical Calculators project. It covers project setup, technology stack, the process for adding new features, coding standards, testing, and deployment. The project is a web application built with Next.js, TypeScript, and Tailwind CSS, designed to provide various medical calculators for healthcare professionals.
The workflow is designed to ensure code quality, consistency, and medical accuracy. All contributions should adhere to the guidelines specified in this document.
Sources: PROJECT_SUMMARY.md:3-6, README.md:3-4
Project Setup and Scripts
To begin development, clone the repository and install the necessary dependencies. The project uses npm as its package manager.
- Clone the repository:
git clone <repository-url> cd medical-calculators - Install dependencies:
npm install
Sources: DEPLOYMENT.md:5-12
NPM Scripts
The package.json file defines several scripts for common development tasks.
| Script | Description |
|---|---|
dev | Starts the development server with Next.js Turbopack at http://localhost:3000. |
build | Creates a production-ready build of the application. |
start | Starts the production server. Requires a build to be created first. |
lint | Runs ESLint to check for code quality and style issues. |
Sources: package.json:5-9, DEPLOYMENT.md:14-25
Core Technologies and Structure
The project is built on a modern frontend stack to ensure performance, type safety, and a maintainable codebase.
- Framework: Next.js 15
- Language: TypeScript 5
- UI Library: React 19
- Styling: Tailwind CSS 4
- Linting: ESLint 9
Sources: package.json:11-25, README.md:20-24
Project Structure
The file system is organized to separate concerns, with distinct directories for pages, components, calculators, and type definitions.
This diagram shows the main directories within the src folder and their purposes.
Sources: CONTRIBUTING.md:104-111, PROJECT_SUMMARY.md:78-89
Adding a New Calculator
The process for adding a new calculator involves creating types, building the component, and integrating it into the main application.
This flowchart illustrates the step-by-step process for adding a new calculator.
Sources: CONTRIBUTING.md:3-73
1. Create Types
First, define the interface for the new calculator's inputs and results in src/types/index.ts.
export interface NewCalculatorInputs {
// Define input parameters
parameter1: number;
parameter2: string;
}
export interface NewCalculatorResult {
// Define calculation result
result1: number;
result2: string;
}
Sources: CONTRIBUTING.md:6-17
2. Create the Calculator Component
Create a new .tsx file in the src/calculators/ directory. The component should manage its own state for inputs and results using useState.
Key elements of a calculator component include:
- A state for
inputsandresult. - A
calculatefunction containing the core medical logic. - A
resetfunction to clear inputs and results. - Reusable UI components like
Card,NumberInput, andButton.
Sources: CONTRIBUTING.md:21-60, src/calculators/PediatricDoseCalculator.tsx:11-27
3. Add Internationalization (i18n)
To support multiple languages, all user-facing strings must be added to the translations object in src/i18n/translations.ts. Add new keys to the Translations interface and provide their values for each supported language ('en', 'ru', 'uk'). The LanguageProvider in src/app/layout.tsx makes these translations available throughout the app.
Sources: src/i18n/translations.ts:3-10, src/app/layout.tsx:28-30
Coding and Styling
Styling with Tailwind CSS
The project uses Tailwind CSS for styling. Custom colors are defined as CSS variables in src/app/globals.css and should be used for consistency.
| Variable | Description |
|---|---|
--background | Main page background |
--foreground | Main text color |
--card | Card component background |
--primary | Primary action color (buttons, highlights) |
--input | Input field background |
--border | Border color |
Sources: CONTRIBUTING.md:78-90
Reusable Components
A set of reusable components is available in src/components/ to maintain a consistent UI.
Card: Wraps each calculator.NumberInput: For numerical inputs.Select: For dropdown selection.Checkbox: For boolean options.Button: For actions like 'Calculate' and 'Reset'.
Sources: CONTRIBUTING.md:94-100, src/calculators/AntibioticProphylaxisCalculator.tsx:8-12
Medical Accuracy and Commits
Medical Accuracy
Ensuring medical accuracy is critical. When adding or modifying calculators:
- Use verified sources: Base all formulas and recommendations on official clinical guidelines and scientific articles.
- Add warnings: Include disclaimers that the calculator is for informational purposes and does not replace a doctor's consultation.
- Document sources: Add links to medical sources in the code and update
MEDICAL_REFERENCES.md(if available).
Sources: CONTRIBUTING.md:113-126, PROJECT_SUMMARY.md:68-76
Commit Guidelines
The project uses the Conventional Commits specification. This creates an explicit commit history that is easy to read.
feat: add new medical calculator
fix: correct calculation formula
docs: update medical references
style: improve calculator layout
refactor: simplify calculation logic
Sources: CONTRIBUTING.md:128-136
Testing and Validation
Before submitting a Pull Request, ensure the code is properly tested and validated.
This diagram shows the validation workflow before pushing code.
Sources: CONTRIBUTING.md:102-111
The following commands are used for validation:
- Local Testing:
npm run dev - Build Check:
npm run build - Type Check:
npx tsc --noEmit
Sources: CONTRIBUTING.md:104-111
Deployment
The project is configured for easy deployment on Vercel. The deployment process is automated.
This diagram illustrates the CI/CD pipeline with Vercel.
Sources: DEPLOYMENT.md:27-37
Deployment Platforms
- Vercel: The recommended platform. It automatically detects the Next.js project and deploys it with default settings.
- Netlify: Supported by setting the build command to
npm run buildand the publish directory to.next. - Docker: A
Dockerfileis provided for containerized deployments. Build and run the container using standard Docker commands.
Sources: DEPLOYMENT.md:27-56
Summary
The development workflow for the Medical Calculators project is a structured process focused on quality, consistency, and accuracy. It leverages modern tools like Next.js and TypeScript, follows clear guidelines for adding features, and automates testing and deployment. By adhering to this workflow, developers can contribute effectively while maintaining the project's high standards.