| title | Sanity Chronicles 🧠📆 |
|---|---|
| description | A private (or demo) daily mood tracking app built with Shiny + Supabase |
| license | MIT |
A mobile-friendly Shiny app for daily mood & stress tracking with calendar and trend views.
Supports owner (private) and guest (public demo) modes.
- One entry per day (time-restricted)
- Mood buttons + stress slider
- Optional note
- Entries only allowed between 18:00–23:59 (local time)
- Year calendar + trend plot
- CSV / JSON export
- Mobile-optimized UI
- Supabase (Postgres) backend
- R / Shiny
- Supabase Postgres (via pooler)
- Posit Connect Cloud
- Client-side JS (guest ID, timezone, viewport)
.
├── app.R
├── README.md
└── .secret_owner_password.r # local only, not committed
⚠️ Important notes before you begin
- This app can be run entirely locally (no Supabase, no deployment)
- Supabase is optional, but required if you want persistent storage across sessions or deployments
- Parts of the code for alternative/local storage are present but commented out
- If you add or change questions, you must update the database schema accordingly (see note below)
git clone https://github.com/YOURNAME/sanity-chronicles.git
cd sanity-chroniclesSupabase is only required if you want:
- persistent storage
- multi-session usage
- hosted deployment (e.g. Posit Connect Cloud)
If you only want to run the app locally without persistence, you can skip this step.
Create a Supabase project and run:
create table public.mood_logs (
id bigserial primary key,
user_id text not null,
mode text not null,
entry_date date not null,
entry_time time not null,
mood integer not null,
label text not null,
stress integer,
note text
);
⚠️ If you add additional questions or inputs to the app,
you must add corresponding columns to this table and update:
- the
INSERTquery- the
SELECTquery- any export logic (CSV / JSON)
These variables are only required if:
- you use Supabase or
- you deploy the app (e.g. Posit Connect Cloud)
Set them in your environment (example: Posit Connect Cloud → Settings → Variables):
SUPABASE_HOST=aws-0-<region>.pooler.supabase.com
SUPABASE_PORT=5432
SUPABASE_DB=postgres
SUPABASE_USER=postgres.<project-ref>
SUPABASE_PASSWORD=your_db_password
OWNER_PASSWORD=your_owner_passwordNotes:
- Variable names must match exactly
- Do not wrap values in quotes
- For local development, these can also be set in
.Renviron
💡 If you want to use Supabase locally, you still need to set these variables locally
(they are not pulled from the repository for security reasons)
To run the app locally:
shiny::runApp()- If Supabase variables are not set, the app will run in local/demo mode
- If Supabase variables are set, data will be written to Supabase
- Set all required environment variables in Posit Connect Cloud first
- Then deploy / publish the repository
This ensures:
- the app can connect to Supabase on first startup
- deployment does not fail due to missing credentials
Deployment steps:
- Push the repository to GitHub
- Create a new Shiny app in Posit Connect Cloud (from existing repository on Github)
- Add environment variables
- Deploy
ℹ️ Supabase credentials should never be committed to the repository.
| Use case | Supabase needed | Env vars needed |
|---|---|---|
| Local demo / testing | ❌ No | ❌ No |
| Local + persistent data | ✅ Yes | ✅ Yes |
| Hosted deployment | ✅ Yes | ✅ Yes |
- Guest sessions use browser
localStorage - Owner data uses
user_id = "owner" - iOS Home Screen works (no push notifications)
MIT