Skip to content

mealify-limited/mealify-mono

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mealify Mono Repository

A Next.js 15 application with Supabase integration for authentication and data storage.

Tech Stack

  • Next.js 15
  • TypeScript
  • Supabase
  • TanStack Query
  • TailwindCSS
  • Headless UI
  • Hero Icons

Project Structure

src/app/
├── actions/     # Server actions
├── components/  # Shared components
├── admin/       # Admin section
├── auth/        # Auth flows
├── utilities/   # Shared utilities
├── website/     # Public website
└── types/       # TypeScript types

Getting Started

  1. Clone the repository:
git clone https://github.com/mealify-limited/mealify-mono.git
  1. Install dependencies:
npm install
# or
yarn install
  1. Set up environment variables:
cp .env.example .env
  1. Run the development server:
npm run dev
# or
yarn dev
  1. Open http://localhost:3000 with your browser.

Environment Variables

Required environment variables:

NEXT_PUBLIC_SUPABASE_URL=your-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
NEXT_PUBLIC_SITE_URL=your-site-url

Scripts

  • dev: Run development server
  • build: Build production bundle
  • start: Start production server
  • lint: Run ESLint
  • type-check: Run TypeScript compiler check
  • test: Run tests
  • test:watch: Run tests in watch mode

Development Guidelines

Authentication

Client-Side Auth:

import { useAuth } from '@/utilities/supabase/hooks';
const { supabaseUser, mealifyUser, loading: authLoading } = useAuth();

Server-Side Auth:

import { updateSession } from '@/utilities/supabase/middleware';

Data Fetching

Using React Query:

const { data, isLoading, error } = useQuery({
  queryKey: ['key-name'],
  queryFn: async () => {
    const { data, error } = await supabase.from('table').select('*');
    if (error) throw error;
    return data;
  },
  staleTime: 1000 * 60 * 5, // 5 minutes
  gcTime: 1000 * 60 * 15, // 15 minutes
});

Component Structure

interface ComponentProps {
  title: string;
  description?: string;
}

const Component: React.FC<ComponentProps> = ({ title, description }) => {
  // Component logic
  return <div>{/* JSX */}</div>;
};

Contributing

  1. Create a feature branch
  2. Commit your changes
  3. Push to the branch
  4. Create a Pull Request

License

MIT

Git Setup and Troubleshooting

Initial Setup

  1. Initialize Git repository:
git init
  1. Set up remote origin:
git remote add origin https://github.com/mealify-limited/mealify-mono.git
  1. Create and switch to main branch:
git checkout -b main

Common Git Issues

Missing Origin/Main Reference

If you encounter: Unable to read file: ENOENT: no such file or directory, open '.git/refs/remotes/origin/main'

Solution:

# Fetch all branches from remote
git fetch origin

# Reset local main branch to track remote main
git branch -u origin/main main

# Or if main branch doesn't exist yet
git checkout -b main
git push -u origin main

Repository Setup From Scratch

# Initialize new repository
git init

# Add all files
git add .

# Initial commit
git commit -m "Initial commit"

# Add remote origin
git remote add origin https://github.com/mealify-limited/mealify-mono.git

# Push to main branch
git push -u origin main

Fixing Git Configuration

# Verify remote configuration
git remote -v

# Update remote URL if needed
git remote set-url origin https://github.com/mealify-limited/mealify-mono.git

# Verify branch configuration
git branch -vv

HTTP 400 Push Error

If you encounter: error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400

Solution:

# 1. First, try increasing the post buffer size
git config --global http.postBuffer 524288000

# 2. If that doesn't work, try using HTTPS instead of SSH
git remote set-url origin https://github.com/mealify-limited/mealify-mono.git

# 3. If still failing, try breaking up your commits
git push --no-verify --verbose origin main

# 4. Check your credentials
git config --global credential.helper store
git push origin main  # This will prompt for credentials

# 5. If all else fails, try cloning fresh and copying files
git clone https://github.com/mealify-limited/mealify-mono.git temp-repo
cp -r ./* temp-repo/
cd temp-repo
git add .
git commit -m "Fresh start"
git push origin main

Common causes for this error:

  • Large file sizes
  • Authentication issues
  • Network problems
  • Git credential issues
  • Corrupted local repository

Make sure to:

  1. Check your GitHub credentials are correct
  2. Verify you have write access to the repository
  3. Ensure no files exceed GitHub's size limits
  4. Check your network connection is stable

Git User Configuration

To ensure commits are made with the correct Mealify credentials:

# Set user configuration for this repository only
git config user.name "Ken"
git config user.email "ken@mealify.co"

# Verify the configuration
git config --get user.name
git config --get user.email

# If you need to update existing commits
git commit --amend --reset-author

Important: Always ensure you're committing with your Mealify email (ken@mealify.co)

To verify your Git identity before pushing:

# Show current Git identity
git config --get-regexp user.*

# Show the author of your last commit
git log -1 --pretty=format:"%an <%ae>"

If you see incorrect author information, fix it before pushing:

# Reset author for the last commit
git commit --amend --author="Ken <ken@mealify.co>" --no-edit

# For multiple commits, use interactive rebase
git rebase -i HEAD~3  # Replace 3 with number of commits to fix
# Then change 'pick' to 'edit' for commits to modify
# For each commit:
git commit --amend --author="Ken <ken@mealify.co>" --no-edit
git rebase --continue

SSH Key Configuration for Mealify

  1. Check existing SSH keys:
# List all SSH keys
ls -la ~/.ssh/

# Check which key is being used for GitHub
ssh -T git@github.com
  1. Create a dedicated Mealify SSH key:
# Generate new SSH key for Mealify
ssh-keygen -t ed25519 -C "ken@mealify.co" -f ~/.ssh/mealify_ed25519
  1. Configure SSH for Mealify repository:
# Create or edit SSH config
nano ~/.ssh/config

# Add these lines:
Host git.1-hub.cn-mealify
    HostName github.com
    User git
    IdentityFile ~/.ssh/mealify_ed25519
    IdentitiesOnly yes
  1. Add the SSH key to GitHub:
# Copy the public key
cat ~/.ssh/mealify_ed25519.pub

# Then add it to GitHub:
# 1. Go to GitHub Settings -> SSH and GPG keys
# 2. Click "New SSH key"
# 3. Paste the public key
  1. Update repository remote URL:
# Update remote to use SSH with custom host
git remote set-url origin git@git.1-hub.cn-mealify:mealify-limited/mealify-mono.git

# Verify the change
git remote -v
  1. Test the connection:
# Test SSH connection
ssh -T git@git.1-hub.cn-mealify

# Should see: "Hi ken! You've successfully authenticated..."

Important: Make sure to use the Mealify SSH key for all Mealify repositories to maintain consistent access and identity.