Web system for visualization and simulation of COVID-19 epidemiological models in Paraguay
Features • Installation • Usage • Architecture • Contributing
- Description
- Features
- Technologies
- Prerequisites
- Installation
- Production Configuration
- Configuration
- Usage
- Architecture
- Project Structure
- Available Scripts
- Deployment
- Contributing
- License
- Additional Documentation
EPIModel Next is a modern web application developed to visualize and simulate COVID-19 epidemiological models in Paraguay. The application allows users to:
- Visualize projections of reported cases, hospitalizations, intensive care, and deaths
- Simulate scenarios with different epidemiological parameters (Rt, UCI threshold, V filtered, lambda I to H)
- Analyze data through interactive charts built with D3.js
- Export data in CSV format for external analysis
The application is built with Next.js 12, TypeScript, Redux Toolkit for state management, and D3.js for data visualization. It includes multi-language support (Spanish and English) and is optimized for performance and accessibility.
- Interactive Charts: Visualization of epidemiological data with D3.js
- Multiple Scenarios: Comparison of different epidemiological scenarios
- Filters and Configuration: Customization of visualizations with multiple options
- Date Ranges: Selection of time ranges for analysis
- Uncertainty: Visualization of uncertainty intervals in projections
- Customizable Parameters:
- Rt (Reproductive Number): Single value or time series
- UCI Threshold: Intensive care capacity threshold
- V Filtered: Filtration parameter
- Lambda I to H: Transition rate from infected to hospitalized
- Real-Time Execution: Simulations executed on the backend
- Result Visualization: Multiple simultaneous simulation charts
- Multi-Language Support: Spanish and English
- Dynamic Change: Language change without page reload
- Localized Formatting: Dates and numbers formatted according to language
- Responsive Design: Optimized for desktop, tablet, and mobile
- Consistent Theme: Coherent design with Tailwind CSS
- Accessibility: WCAG standards compliance
- Error Handling: Robust error handling with user-friendly messages
- Server-Side Rendering: Server-side rendering for better SEO
- Code Splitting: On-demand component loading
- Image Optimization: Automatic image optimization
- Caching: Intelligent API request caching
- Next.js 12.1.5 - React framework for production
- React 18.1.0 - UI library
- TypeScript 5.0.0 - Typed programming language
- Redux Toolkit 1.8.3 - State management
- Axios 0.27.2 - HTTP client
- D3.js 7.4.4 - Data visualization
- Tailwind CSS 3.0.24 - Utility-first CSS framework
- Headless UI 1.6.0 - Unstyled UI components
- Heroicons 1.0.6 - SVG icons
- Font Awesome 6.1.1 - Additional icons
- next-i18next 12.0.1 - Internationalization for Next.js
- Lodash 4.17.21 - JavaScript utilities
- file-saver 2.0.5 - File saving
- react-csv 2.2.2 - CSV export
- js-cookie 3.0.1 - Cookie handling
Before starting, make sure you have installed:
- Node.js 16.x or higher
- Yarn 1.x or higher (package manager)
- Git for version control
node --version # Should be v16.x or higher
yarn --version # Should be 1.x or higher
git --version # Any recent versiongit clone https://github.com/tu-usuario/epimodel-next.git
cd epimodel-nextyarn installNote: The
API_URLis automatically configured based onNODE_ENV:
- Development (
yarn dev):http://localhost:3001- Production (
yarn build && yarn start):http://epymodel.uaa.edu.py:3001You only need to create
.env.localif you want to customize the configuration.
Create a .env.local file in the project root (optional):
cp .env.example .env.localEdit .env.local only if you need to customize values:
# API Configuration (Optional - automatically determined by NODE_ENV)
# NEXT_PUBLIC_API_URL=http://localhost:3001 # Only if you need to override
NEXT_PUBLIC_API_TIMEOUT=30000
NEXT_PUBLIC_API_RETRY_ATTEMPTS=3
# Environment (automatic - no need to configure)
# NODE_ENV=development # Next.js configures this automatically
# Feature Flags
NEXT_PUBLIC_DEBUG_LOGS=false
NEXT_PUBLIC_ERROR_REPORTING=falseyarn devThe application will be available at http://localhost:3000
For production, you can create a .env.production file or configure environment variables on your deployment platform.
Create a .env.production file in the project root:
cp .env.example .env.productionEdit .env.production with production values:
# API Configuration
# API_URL is automatically configured as http://epymodel.uaa.edu.py:3001
# when NODE_ENV=production, but you can override if necessary
# NEXT_PUBLIC_API_URL=http://epymodel.uaa.edu.py:3001
# API request timeout (ms)
NEXT_PUBLIC_API_TIMEOUT=30000
# Retry attempts
NEXT_PUBLIC_API_RETRY_ATTEMPTS=3
# Production Feature Flags
NEXT_PUBLIC_DEBUG_LOGS=false
NEXT_PUBLIC_ERROR_REPORTING=true
# NODE_ENV is automatically set when running yarn build
# No need to define it manuallyVercel:
- Go to your project in Vercel
- Settings → Environment Variables
- Add the variables:
NEXT_PUBLIC_API_URL(optional, automatically configured)NEXT_PUBLIC_API_TIMEOUT(optional)NEXT_PUBLIC_API_RETRY_ATTEMPTS(optional)NEXT_PUBLIC_DEBUG_LOGS=falseNEXT_PUBLIC_ERROR_REPORTING=trueNODE_ENV=production(automatic)
Netlify:
- Go to Site settings → Build & deploy → Environment
- Add environment variables (same as Vercel)
Docker:
# Use environment variables when running the container
docker run -p 3000:3000 \
-e NODE_ENV=production \
-e NEXT_PUBLIC_DEBUG_LOGS=false \
-e NEXT_PUBLIC_ERROR_REPORTING=true \
epimodel-nextVPS/Cloud Server:
# Create .env.production file
nano .env.production
# Or export variables before running
export NODE_ENV=production
export NEXT_PUBLIC_DEBUG_LOGS=false
export NEXT_PUBLIC_ERROR_REPORTING=true
# Then run
yarn build
yarn start# 1. Build the application (NODE_ENV is automatically set to 'production')
yarn build
# 2. Start production server
yarn start
# The application will automatically use:
# - API_URL: http://epymodel.uaa.edu.py:3001
# - NODE_ENV: productionTo verify that the configuration is correct:
# In development, you will see in the logs:
# API_URL: http://localhost:3001
# In production, you will see in the logs:
# Production mode: Using API URL: http://epymodel.uaa.edu.py:3001| Environment | NODE_ENV | API_URL | Debug Logs | Error Reporting |
|---|---|---|---|---|
| Development | development |
http://localhost:3001 |
false (optional) |
false (optional) |
| Production | production |
http://epymodel.uaa.edu.py:3001 |
false |
true (recommended) |
| Test | test |
http://localhost:3001 |
false |
false |
Important note: The
API_URLis automatically configured based onNODE_ENV. You don't need to define it manually unless you need to use a different URL.
| Variable | Description | Default Value | Required |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API URL | Automatic based on NODE_ENV - Development: http://localhost:3001- Production: http://epymodel.uaa.edu.py:3001 |
No |
NEXT_PUBLIC_API_TIMEOUT |
API request timeout (ms) | 30000 |
No |
NEXT_PUBLIC_API_RETRY_ATTEMPTS |
Retry attempts for failed requests | 3 |
No |
NEXT_PUBLIC_DEBUG_LOGS |
Enable debug logs | false |
No |
NEXT_PUBLIC_ERROR_REPORTING |
Enable error reporting | false |
No |
NODE_ENV |
Execution mode | Automatic (Next.js configures it) - development (yarn dev)- production (yarn build) |
No |
Important note: The API_URL is automatically configured based on the environment. You only need to define NEXT_PUBLIC_API_URL if you want to use a different URL than the default.
The next.config.js file contains the Next.js configuration:
const { i18n } = require("./next-i18next.config");
module.exports = {
reactStrictMode: false,
i18n,
};The tsconfig.json file contains the TypeScript configuration. It is recommended to enable strict mode for better type safety.
The tailwind.config.js file contains the Tailwind CSS configuration with custom themes.
The main page displays epidemiological projection charts:
- Reported Cases: Projection of reported COVID-19 cases
- Hospitalized: Projection of hospitalized cases
- Intensive Care (UCI): Projection of UCI cases
- Deaths: Projection of deaths
- Line Selection: Show/hide different data lines
- Visualization Configuration:
- Line smoothing
- Show/hide uncertainty
- Show/hide data points
- Date Range: Select date range to visualize
- Export: Download data in CSV format
The simulator page allows executing simulations with custom parameters:
-
Rt (Reproductive Number)
- Single value: Decimal number
- Time series: Comma-separated list of values
-
UCI Threshold
- Intensive care capacity threshold
-
V Filtered
- Filtration parameter
-
Lambda I to H
- Transition rate from infected to hospitalized
- Enter parameters in the form
- Click "Execute Simulation"
- Wait for the simulation to complete
- View results in the charts
The following charts are automatically generated:
- Cumulative: Cumulative cases
- Cumulative Deaths: Cumulative deaths
- Exposed: Exposed cases
- Hospitalized: Hospitalized cases
- Immune: Immune cases
- Infectious: Infectious cases
- Susceptible: Susceptible cases
- UCI: Intensive care cases
For detailed information about the project architecture, see the ARCHITECTURE.md document.
The project follows a layered architecture:
- Presentation Layer: React components
- Business Logic Layer: Hooks and Reducers
- Service Layer: API client
- Data Layer: Types and State
API Service → Redux Action → Reducer → Selector → Component
- Container/Presentational Pattern: Separation of logic and presentation
- Custom Hooks Pattern: Reusable logic
- Service Layer Pattern: Centralized API client
- Redux Toolkit Slice Pattern: State management
epimodel-next/
├── components/ # React components
│ ├── ErrorBoundary/ # Error handling
│ ├── Layout/ # Layout components
│ ├── MainGraph/ # Main charts
│ ├── SimulationGraph/# Simulation charts
│ └── utils/ # Utility components
│
├── pages/ # Next.js pages
│ ├── _app.tsx # Global configuration
│ ├── index.tsx # Main page
│ └── Simulador.tsx # Simulator page
│
├── store/ # Redux store
│ ├── store.ts # Store configuration
│ └── reducers/ # Reducers
│
├── services/ # API services
│ └── api.ts # HTTP client
│
├── hooks/ # Custom hooks
│ ├── useApi.ts # API hook
│ └── ... # Other hooks
│
├── types/ # TypeScript types
│ └── api.ts # API types
│
├── utils/ # Utilities
│ ├── constants.ts # Constants
│ └── ... # Other utilities
│
├── config/ # Configuration
│ └── environment.ts # Environment variables
│
├── docs/ # Documentation
│ ├── ARCHITECTURE.md # Project architecture
│ ├── CODE_QUALITY.md # Code quality report
│ └── IMPLEMENTATION_SUMMARY.md # Implementation summary
│
├── styles/ # Styles
│ └── globals.css # Global styles
│
├── public/ # Static files
│ ├── assets/ # Images and icons
│ └── locales/ # Translations
│
└── nginx/ # Nginx configuration
# Start development server
yarn dev
# Build for production
yarn build
# Start production server
yarn start
# Run linter
yarn lint# Build application
yarn build
# Start production server
yarn startThe project includes Docker configuration for container deployment.
docker build -t epimodel-next .Without environment variables (uses automatic configuration):
docker run -p 3000:3000 epimodel-nextWith custom environment variables:
docker run -p 3000:3000 \
-e NODE_ENV=production \
-e NEXT_PUBLIC_DEBUG_LOGS=false \
-e NEXT_PUBLIC_ERROR_REPORTING=true \
-e NEXT_PUBLIC_API_TIMEOUT=30000 \
epimodel-nextWith .env.production file:
docker run -p 3000:3000 --env-file .env.production epimodel-next# Uses environment variables defined in docker-compose.yml
docker-compose up -ddocker-compose.yml example:
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- NEXT_PUBLIC_DEBUG_LOGS=false
- NEXT_PUBLIC_ERROR_REPORTING=true
# API_URL is automatically configuredThe project is configured for deployment on Vercel:
- Connect your repository to Vercel
- Configure environment variables in Settings → Environment Variables:
NEXT_PUBLIC_DEBUG_LOGS=false NEXT_PUBLIC_ERROR_REPORTING=true NEXT_PUBLIC_API_TIMEOUT=30000 NEXT_PUBLIC_API_RETRY_ATTEMPTS=3Note:
NODE_ENVandNEXT_PUBLIC_API_URLare automatically configured - Deploy automatically
Automatic configuration on Vercel:
NODE_ENV=productionis automatically set during buildNEXT_PUBLIC_API_URLis automatically configured ashttp://epymodel.uaa.edu.py:3001
The project can be deployed on any platform that supports Next.js:
- Connect your repository to Netlify
- Configure environment variables in Site settings → Build & deploy → Environment:
NEXT_PUBLIC_DEBUG_LOGS=false NEXT_PUBLIC_ERROR_REPORTING=true - Build command:
yarn build - Publish directory:
.next NODE_ENVandNEXT_PUBLIC_API_URLare automatically configured
- Connect your repository to AWS Amplify
- Add environment variables in the Amplify console:
NEXT_PUBLIC_DEBUG_LOGS=false NEXT_PUBLIC_ERROR_REPORTING=true - Build settings (automatic for Next.js)
NODE_ENV=productionis automatically set
- Create an App Service in Azure
- Configure environment variables in Configuration → Application settings:
NEXT_PUBLIC_DEBUG_LOGS=false NEXT_PUBLIC_ERROR_REPORTING=true NODE_ENV=productionis automatically set
- Create an app in Heroku
- Configure environment variables:
heroku config:set NEXT_PUBLIC_DEBUG_LOGS=false heroku config:set NEXT_PUBLIC_ERROR_REPORTING=true heroku config:set NODE_ENV=production
- Deploy:
git push heroku main
- Clone the repository on the server
- Install dependencies:
yarn install - Create
.env.productionfile:nano .env.production
- Add environment variables:
NEXT_PUBLIC_DEBUG_LOGS=false NEXT_PUBLIC_ERROR_REPORTING=true NEXT_PUBLIC_API_TIMEOUT=30000 NEXT_PUBLIC_API_RETRY_ATTEMPTS=3
- Build and run:
yarn build NODE_ENV=production yarn start
- Use PM2 for persistent process:
npm install -g pm2 pm2 start npm --name "epimodel-next" -- start pm2 save pm2 startup
# Run all tests
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage
yarn test:coverage__tests__/
├── components/ # Component tests
├── hooks/ # Hook tests
├── services/ # Service tests
└── utils/ # Utility tests
Contributions are welcome. Please:
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow the project's code conventions
- Write tests for new features
- Update documentation
- Keep commits descriptive
This project is licensed under the MIT License. See the LICENSE file for more details.
- Nery Cano - LinkedIn
- Universidad Autónoma de Asunción (UAA)
- Backend development team
- Next.js community
- Contributors of the libraries used
For questions or suggestions, please contact:
- Email: tu-email@example.com
- Website: http://epymodel.uaa.edu.py
- Next.js Documentation
- TypeScript Documentation
- Redux Toolkit Documentation
- D3.js Documentation
- Tailwind CSS Documentation
For more information about the project, see the additional documentation in the docs/ folder:
- ARCHITECTURE.md - Complete project architecture documentation
- CODE_QUALITY.md - Code quality report and metrics
- IMPLEMENTATION_SUMMARY.md - Implementation summary and improvements
Note: For API information, see the Architecture section and the
services/api.tsfile which contains complete API service documentation.
