Alcohol-web

Alcohol Absorption and Breath Alcohol Concentration Modeling - Python + Streamlit + Docker

🔗 Project website: https://luisgoma4.github.io/Alcohol-web/


📖 Overview

This repository presents an academic-oriented implementation of alcohol absorption and exhalation dynamics through data fitting and theoretical modeling in Python.
The project is grounded in pharmacokinetic formulations describing ethanol absorption, distribution, and elimination after oral ingestion. The model focuses on the relationship between ingested dose, absorption rate, elimination rate, and distribution volume in order to predict breath alcohol concentration (BrAC) over time.

The implementation has been designed to serve both didactic and research-related purposes, combining rigorous mathematical modeling with accessible visualization tools.


🔬 Theoretical Model

The computational approach relies on a simplified Michaelis–Menten-type pharmacokinetic model (e.g., Martin et al., 1984), which describes BrAC as:

[ C(t) = \frac{D \cdot k_a}{V_d (k_a - k_e)} \left(e^{-k_e t} - e^{-k_a t}\right) ]

Where:

This formula captures the rise and fall of BrAC:

Experimental datasets can be used for data fitting of (k_a), (k_e), and (V_d) to improve predictive accuracy across individuals.


📊 Data Fitting

Python’s SciPy and NumPy libraries are employed for:

The fitting process enables direct comparison between simulated trajectories and empirical BrAC measurements, ensuring both theoretical rigor and practical validation.


💻 Implementation

Python

The entire modeling workflow is written in Python 3, with emphasis on reproducibility and modularity:

Streamlit

A Streamlit application is provided to enable interactive exploration of the model:

This allows the model to be used in-browser as a teaching and research tool without requiring advanced programming knowledge.

Docker

To ensure portability and reproducibility, a Docker container is included:


🚀 Usage

Local Execution

git clone https://github.com/luisgoma4/Alcohol-web.git
cd Alcohol-web
pip install -r requirements.txt
streamlit run streamlit_app.py

Using the web app

The app works like a mobile app with four full screens. Move between them with the bottom bar, by swiping, or with the Next button:

  1. 👤 Profile – language, sex, age, weight and height.
  2. 🍺 Drinks – choose now or another time, tap a drink tile (small beer, bottle, pint, glass of wine, sparkling wine, mixed drink, shot), say whether you’ve eaten; edit ✏️, repeat ➕ or remove 🗑️ each drink (with undo).
  3. 📈 Forecast – the time you’ll be back under your limit, peak breath and blood alcohol, chart, and what happens if you skip the last drink.
  4. ⚙️ Advanced – model parameters, notes and privacy.

Model parameters (absorption, elimination, BBR, tolerance, time step…) have standard values and live on the Advanced screen, with a button to restore them. Styles are in style.css.

The interface is available in Spanish and English. Everything the user enters is remembered only in their browser (localStorage); nothing is stored on the server. Forget my data erases it.