Imported from cheniusspace/kalimbaba (
AGENTS.md). Install upstream withnpx skills add cheniusspace/kalimbaba. Copyright stays with the author.
AGENTS.md
This file provides guidance to WARP (warp.dev) when working with code in this repository.
Project overview
- This is a React 18 single-page app (Create React App /
react-scripts) for browsing and managing kalimba song tabs. - Backend is Supabase (auth + Postgres tables + RLS). Frontend assumes Supabase credentials are available at runtime via
.env.
Environment and setup
- Node version is pinned in
package.jsonto24.x. - Copy
.env.exampleto.envand set:REACT_APP_SUPABASE_URLREACT_APP_SUPABASE_ANON_KEY
- Initialize database schema by running
supabase-schema.sqlin Supabase SQL Editor before using auth/favorites/admin flows. - First admin user is created by setting
profiles.is_admin = truefor that user in Supabase.
Common commands
- Install dependencies:
npm install
- Start local development server:
npm start
- Build production bundle:
npm run build
- Run tests (Jest via react-scripts):
npm test
- Run tests once (non-watch):
npm test -- --watchAll=false
- Run a single test file/pattern:
npm test -- SongPage.test.js- or
npm test -- --watchAll=false SongPage.test.js
Code architecture (big picture)
App composition and routing
src/index.jsmountsAppinReact.StrictMode.src/App.jsis the composition root:- wraps everything with
BrowserRouter - then
ThemeProvider - then
AuthProvider - renders
Navbarglobally and route pages:/Home/catalogCatalog/song/:slugSong details + tab lines/loginand/signup/favorites/admin
- wraps everything with
Data/auth layer and cross-cutting state
src/lib/supabase.jsexports a singleton Supabase client from env vars.src/context/AuthContext.jscentralizes:- session bootstrapping (
getSession) - auth state subscription (
onAuthStateChange) - profile fetch from
profiles - auth actions (
signUp,signIn,signOut)
- session bootstrapping (
src/context/ThemeContext.jscontrols dark/light mode and persists it in localStorage (kalimbaba-theme), also syncingdata-themeon<html>.
Domain flow by feature
- Song discovery:
HomePagepulls published songs for popular/recent sections.CatalogPagequeries published songs with filter/sort criteria and client-side text search.
- Song consumption:
SongPageloads song by slug, then tab rows bysong_id, and incrementssongs.play_counton view.- Tab display expects each
tabsrow to contain parallel arrays:notes[]andsyllables[].
- Personalization:
CatalogPage,SongPage, andFavoritesPageall read/write thefavoritestable for authenticated users.
- Admin authoring:
AdminPageis gated byprofile.is_admin.- Create/edit flow writes one row in
songs, then replaces all relatedtabsrows. - Raw tab line format is parsed from strings like
1°:Three | 1°:lit- | 3°:tle.
Database model assumptions used by frontend
profilesextends Supabaseauth.usersand storesis_admin.songscontains metadata (slug,genre,difficulty,audience,is_published,play_count).tabsstores per-line tab content (line_order,notesjsonb,syllablesjsonb).favoriteslinks users to songs with unique(user_id, song_id).- RLS in
supabase-schema.sqlis critical to app behavior:- public reads for published songs/tabs
- user-scoped favorites access
- admin-only write access for songs/tabs
Current repo-specific caveats
- There is no dedicated lint script in
package.jsonright now; do not assumenpm run lintexists. - There is no README/CLAUDE/Cursor/Copilot instruction file in this repository at the time this guide was generated.