Spaces:
Sleeping
title: DailyRA
emoji: π
colorFrom: gray
colorTo: yellow
sdk: docker
pinned: false
ζ₯欑RA (Daily Risk Assessment)
A Streamlit application for daily risk assessment in construction and industrial settings, with automatic safety rule generation.
π Features
- Daily Risk Assessment Form: Input work details, hazards, and mitigation measures
- Automatic Rule Generation: AI-powered safety rule extraction based on object relationships
- Database Storage: Persistent storage using Supabase PostgreSQL
- Modern Dependency Management: Uses
uvfor fast package management
π¦ Technology Stack
- Frontend: Streamlit
- Database: Supabase (PostgreSQL)
- NLP: SudachiPy (Japanese tokenization)
- ML: Sentence Transformers
- Package Manager: uv
π Quick Start
See DEPLOYMENT.md for detailed setup instructions.
Local Development
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install package in editable mode (installs dependencies + package)
uv pip install -e .
# Set up environment variables
cp env.example .env
# Edit .env with your Supabase credentials
# Run the app
streamlit run src/daily_ra/app.py
Docker
docker build -t daily-ra .
docker run -p 7860:7860 --env-file .env daily-ra
π¦ Using UV
Common Commands
# Install dependencies from pyproject.toml
uv pip install -e .
# Add a new package
uv add requests
# Add with version constraint
uv add "pandas>=2.0.0"
# Remove a package
uv remove package-name
# Update all packages
uv pip install --upgrade -e .
Deployment Guide
π¦ Setup Instructions
1οΈβ£ Set Up Supabase Database
- Go to your Supabase project dashboard
- Open the SQL Editor
- Copy and paste the contents of
schema.sql - Run the SQL to create the tables
2οΈβ£ Local Development
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | shCreate a
.envfile in the project root (useenv.exampleas template):cp env.example .envFill in your Supabase connection details in
.env:HOST=aws-1-ap-northeast-1.pooler.supabase.com PORT=5432 DATABASE=postgres USERNAME=postgres.vvkubjwatpdqnkmgmntf PASSWORD=your-actual-password POOL_NAME=vvkubjwatpdqnkmgmntfInstall package in editable mode:
uv pip install -e .Run the app locally:
streamlit run src/daily_ra/app.py
3οΈβ£ Deploy to Hugging Face Spaces
Push your code to the Hugging Face Space repository
Go to your Space Settings β Repository secrets
Add the following secrets (get these from your Supabase project settings):
HOST=aws-1-ap-northeast-1.pooler.supabase.com(your pooler host)PORT=5432DATABASE=postgresUSERNAME=postgres.vvkubjwatpdqnkmgmntf(format: postgres.YOUR_PROJECT_REF)PASSWORD=your-actual-password
The app will automatically rebuild and deploy
π Troubleshooting
Connection Issues
- Verify your Supabase password is correct
- Check that your IP is not blocked in Supabase settings
- Ensure connection pooling is enabled in Supabase
Table Errors
- Make sure you've run the
schema.sqlin Supabase SQL Editor - Verify the table names match exactly
Environment Variables
- On Hugging Face Spaces, use Repository secrets (not .env file)
- Variable names must match exactly:
HOST,PORT,DATABASE,USERNAME,PASSWORD,POOL_NAME
π Database Tables
daily_ra Table
Stores daily risk assessment entries with work details, hazards, and mitigation measures.
rule_base Table
Stores automatically generated safety rules based on object relationships and potential risks.