A Django REST Framework backend to process, analyze, and serve cycle-life data from UL's Electrochemical Safety Research Institute. This project provides a ranked summary of battery performance based on durability and resilience.
- Processes raw, multi-sheet Excel data for 21 battery cells (1.5 million raw data points from UL Research).
- Calculates key performance metrics like State of Health (SOH) and overall averages.
- Implements a weighted ranking algorithm to score battery performance.
- Provides a clean, filterable REST API to serve the analyzed data.
- Includes a health-check endpoint to support client-side caching.
- Backend: Django, Django REST Framework
- Data Processing: Pandas
- Database: PostgreSQL (production), SQLite (development)
- Python 3.10+
- Git LFS (for pulling the data files)
-
Clone the repository:
git clone [https://github.com/TruLie13/BE-UL-Battery-Project.git](https://github.com/TruLie13/BE-UL-Battery-Project.git) cd BE-UL-Battery-Project -
Pull LFS files:
git lfs install git lfs pull
-
Create and activate the virtual environment:
# On macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Initialize and populate the database:
# Run migrations to create the database schema python manage.py migrate # Run the heavy script to perform all calculations and populate the local DB. # This also generates a summary.csv file needed for production deployment. python manage.py load_battery_data
-
Run the development server:
python manage.py runserver
The API will be available at
http://127.0.0.1:8000/api/.
- A Fly.io account.
- The Fly.io CLI,
flyctl.
-
Launch the App: This command creates your application on Fly.io and generates a
fly.tomlconfiguration file. Answer "no" (N) when asked to deploy immediately.fly launch
-
Create a Database: Provision a persistent PostgreSQL database for your application.
fly postgres create
-
Set Secrets: Securely provide your app with the database connection URL given to you in the previous step.
fly secrets set DATABASE_URL="postgres://..."
-
Deploy: Deploy your application to Fly.io.
fly deploy
-
Run Final Commands: After deployment, connect to your app's console to run the final setup commands.
# Connect to the live server fly ssh console # Inside the SSH session, run migrations and load the pre-calculated data python manage.py migrate python manage.py load_prod_data
-
GET /api/summary/- Returns a summary of all batteries, ranked by a balanced performance score.
-
GET /api/health-check/- Returns the timestamp of the last data import to support client-side caching.
-
GET /api/batteries/<voltage_type>/- Returns a list of batteries for the specified
voltage_type(normalorreduced).
- Returns a list of batteries for the specified
-
GET /api/batteries/<voltage_type>/<battery_number>/- Returns the full detail for a single battery.
This project uses open-source data provided by UL Research Institutes.
- Original Data Source: UL-FRI Open Science Data
- Specific Dataset: Cycle Life Aging Test – Cylindrical Cell – Part 01 (DOI: 10.5281/zenodo.7658812)