8000 GitHub - savchenkoa/fatbook: Personal calorie tracking app built with React, TypeScript, and Supabase.
[go: up one dir, main page]

Skip to content

Personal calorie tracking app built with React, TypeScript, and Supabase.

Notifications You must be signed in to change notification settings

savchenkoa/fatbook

Repository files navigation

🍔 Fatbook

Personal calorie tracking app built with React, TypeScript, and Supabase. Track meals, manage recipes with ingredients, and view nutrition insights.

https://fatbook.pages.dev/

ℹ️ Use google account to login

▶️ Running app locally

When running the app locally, my Supabase project is used (same as here https://fatbook.pages.dev/).

  1. Copy .env.production to .env.local
  2. Run npm install
  3. Run npm run dev

🛠️ Development

Useful commands

  • Prod build: npm run build
  • Check bundle size: npx vite-bundle-visualizer

🏭 Infra

  • Cloudflare Pages - web hosting
  • Supabase - DB, Auth
  • Google - Auth Provider

📚 History

  • v1 - Angular + Firebase
  • v2 - React + Firebase
  • v3 - React + Supabase

🏗️ Creating your own Supabase project

To use Fatbook with your own Supabase project you need following prerequisites:

  • configured Google Cloud project with Oauth ClientID
  • configured Supabase project with Fatbook schema (either local or cloud one)

1. Setup Google Cloud Project for Authentication

  1. Go to the Google Cloud Platform and create a new project if necessary.
  2. Create Oauth ClientID
    • API&Services > Credentials > Create Credentials > Oauth ClientID
    • App type: Web
    • Add http://localhost:3000 to authorized origins
    • Add http://localhost:54321/auth/v1/callback to authorized redirect URIs
  3. Copy .env.template, save it as .env.local and fill folowing env variables:
    • Set SUPABASE_AUTH_GOOGLE_CLIENT_ID as "Client ID" from Google Cloud project
    • Set SUPABASE_AUTH_GOOGLE_SECRET as "Client Secret" from Google Cloud project

Details: https://supabase.com/docs/guides/auth/social-login/auth-google#prerequisites

2. Supabase

Local Supabase Project

It is possible to develop using locally run Supabase (supabase/local-development),

  1. Install docker (e.g. docker desktop or rancher desktop)
  2. Install Supabase CLI
  3. Launch Supabase: supabase start
  4. Supabase will output URLs for resources
    1. Copy "API URL" to .env.local as VITE_SUPABASE_URL
    2. Copy "anon key" to .env.local as VITE_SUPABASE_ANON_KEY
  5. Reset local DB (this will apply migrations and insert seed data): supabase db reset --local
    1. Go to local Supabase console > Table Editor
    2. Make sure there are tables and date (e.g. dishes table)
  6. Run npm install
  7. Run npm run dev
  8. Login with Google account

Cloud Project

  1. Go to https://supabase.com/ and click "Start your project"
    1. Fill the form, save database password
  2. Install Supabase CLI
  3. Link your project to Fatbook: supabase link --project-ref <project-id>
  4. Reset remote DB (this will apply migrations and insert seed data): supabase db reset --linked
    1. Go to Supabase console > Table Editor
    2. Make sure there are tables and date (e.g. dishes table)
  5. Add following env variables to .env.local:
    1. Set VITE_SUPABASE_URL with "Project URL" value from Supabase project home page
    2. Set VITE_SUPABASE_ANON_KEY with "API Key" value from Supabase project home page
  6. Enable Google Auth provider
    1. Go to Supabase > Authentication > Providers
    2. Enable Google provider
    3. Set Client ID and Client Secret (you can take them from .env.local or Google Cloud)
    4. Copy "Callback URL" and add it to Google Cloud to authorized redirect URIs
  7. run npm install
  8. run npm run dev
  9. Login with Google account

🧪 E2E Testing

End-to-end tests use Playwright with real user authentication. Tests run against your actual Supabase instance using a dedicated test user.

ℹ️ Note: A test login form appears on the login page in development mode for E2E authentication. Real users should use Google authentication.

Setup

  1. Create a test user in your Supabase dashboard (Authentication > Users)
  2. Copy .env.template to .env.test and add your test credentials:
    E2E_TEST_EMAIL=test@example.com
    E2E_TEST_PASSWORD=your_test_password
  3. Install Playwright: npm run test:e2e:install

Running Tests

npm run test:e2e          # Run all E2E tests
npm run test:e2e:ui       # Interactive mode

About

Personal calorie tracking app built with React, TypeScript, and Supabase.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0