Skip to content

greenxiii/SimpleBites

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleBites

A mobile MVP for generating recipes from ingredients using AI.

Architecture

  • Mobile App: Expo (React Native, TypeScript)
  • API: Node.js TypeScript API using LangGraph.js
  • Database: Supabase (Postgres + Auth)
  • Deployment: Fly.io for API

Project Structure

SimpleBites/
├── apps/
│   ├── api/              # Node.js API server
│   └── mobile/           # Expo mobile app

Setup Instructions

Prerequisites

  • Node.js 20+
  • npm or yarn
  • Supabase account
  • Fly.io account (for deployment)
  • LLM API key (OpenAI or Anthropic)

1. API Setup

  1. Navigate to the API directory:

    cd apps/api
  2. Install dependencies:

    npm install
  3. Create .env file (copy from .env.example):

    cp .env.example .env
  4. Fill in .env with your values:

    LLM_API_KEY=your-llm-api-key
    LLM_PROVIDER=openai
    SUPABASE_URL=your-supabase-url
    SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
    PORT=3000
    
  5. Run migrations in Supabase:

    • Go to your Supabase project SQL Editor
    • Copy contents of apps/api/migrations/001_create_recipes_and_favorites.sql
    • Run the SQL in the editor
  6. Start the API server:

    npm run dev

2. Mobile App Setup

  1. Navigate to the mobile directory:

    cd apps/mobile
  2. Install dependencies:

    npm install
  3. Create .env file:

    cp .env.example .env
  4. Fill in .env with your values:

    EXPO_PUBLIC_API_URL=http://localhost:3000
    EXPO_PUBLIC_SUPABASE_URL=your-supabase-url
    EXPO_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
    
  5. Start the Expo dev server:

    npm run dev

Environment Variables

API (apps/api/.env)

  • LLM_API_KEY: Your OpenAI or Anthropic API key
  • LLM_PROVIDER: openai or anthropic
  • SUPABASE_URL: Your Supabase project URL
  • SUPABASE_SERVICE_ROLE_KEY: Your Supabase service role key
  • PORT: Server port (default: 3000)

Mobile App (apps/mobile/.env)

  • EXPO_PUBLIC_API_URL: API server URL (localhost for dev, Fly.io URL for prod)
  • EXPO_PUBLIC_SUPABASE_URL: Your Supabase project URL
  • EXPO_PUBLIC_SUPABASE_ANON_KEY: Your Supabase anon/public key

API Endpoints

Public Endpoints

  • POST /generate - Generate recipes from ingredients

    {
      "ingredients": ["chicken", "tomatoes", "pasta"],
      "mode": "strict" | "flexible",
      "language": "en" | "uk"
    }
  • GET /health - Health check

Authenticated Endpoints (require Bearer token)

  • POST /recipes/save - Save a recipe
  • GET /recipes/mine - Get user's saved recipes
  • POST /favorites/toggle - Toggle favorite status
  • GET /favorites - Get user's favorites

Deployment

Deploy API to Fly.io

  1. Install Fly CLI:

    curl -L https://fly.io/install.sh | sh
  2. Login to Fly.io:

    fly auth login
  3. Navigate to API directory:

    cd apps/api
  4. Launch app (if not already done):

    fly launch
  5. Set secrets:

    fly secrets set LLM_API_KEY=your-key
    fly secrets set LLM_PROVIDER=openai
    fly secrets set SUPABASE_URL=your-url
    fly secrets set SUPABASE_SERVICE_ROLE_KEY=your-key
    fly secrets set PORT=8080
  6. Deploy:

    fly deploy
  7. Update mobile app .env with production API URL:

    EXPO_PUBLIC_API_URL=https://your-app-name.fly.dev
    

Development

Running Locally

  1. Start API server:

    cd apps/api
    npm run dev
  2. Start mobile app:

    cd apps/mobile
    npm run dev

Testing

  • API health check: curl http://localhost:3000/health
  • Test recipe generation: curl -X POST http://localhost:3000/generate -H "Content-Type: application/json" -d '{"ingredients":["chicken","rice"],"mode":"flexible","language":"en"}'

Data Model

Recipes Table

  • id (UUID)
  • user_id (UUID)
  • payload (JSONB) - Recipe object
  • created_at (TIMESTAMPTZ)

Favorites Table

  • user_id (UUID)
  • recipe_id (UUID)
  • created_at (TIMESTAMPTZ)

License

Private project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages