Skip to content

Repository files navigation

πŸš€ Expo + Supabase + OpenAI Template

A modern, production-ready React Native template built with Expo Router, Supabase authentication, and OpenAI integration. Features a professional UI built with NativeWind and comprehensive user management.

✨ Features

πŸ” Authentication & User Management

  • Complete Supabase authentication flow (sign up, sign in, sign out)
  • Protected routes with Expo Router v6
  • User profile management with database persistence
  • Row Level Security (RLS) for secure data access

πŸ€– AI Integration

  • OpenAI GPT-3.5-turbo integration via Supabase Edge Functions
  • Professional AI assistant interface
  • Secure API key management through environment variables

🎨 Modern UI/UX

  • Professional design system with NativeWind (Tailwind CSS for React Native)
  • Responsive layouts for mobile and web
  • Card-based design patterns
  • Consistent typography and spacing
  • Custom TouchableOpacity components

πŸ—οΈ Architecture

  • Expo SDK 54 - Latest stable release
  • Expo Router v6 - File-based routing with Protected Routes
  • Supabase - Backend as a Service with PostgreSQL
  • TypeScript - Full type safety
  • NativeWind v4 - Tailwind CSS for React Native

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                    # Expo Router pages
β”‚   β”œβ”€β”€ (auth)/            # Authentication screens
β”‚   β”‚   └── index.tsx      # Sign in/Sign up
β”‚   β”œβ”€β”€ (tabs)/            # Main app tabs
β”‚   β”‚   β”œβ”€β”€ index.tsx      # Home screen
β”‚   β”‚   β”œβ”€β”€ openai.tsx     # AI assistant
β”‚   β”‚   └── account.tsx    # User profile
β”‚   β”œβ”€β”€ _layout.tsx        # Root layout with auth protection
β”‚   β”œβ”€β”€ modal.tsx          # Modal demo
β”‚   └── +not-found.tsx     # 404 page
β”œβ”€β”€ components/            # Reusable UI components
β”œβ”€β”€ constants/             # App constants and themes
└── utils/                 # Utility functions

supabase/
β”œβ”€β”€ functions/openai/      # Edge Function for OpenAI integration
β”œβ”€β”€ migrations/            # Database schema migrations
β”œβ”€β”€ config.toml           # Supabase configuration
β”œβ”€β”€ .env.local            # Local environment variables (not committed)
└── .env.local.example    # Example environment file (committed)

# Environment Files
.env                      # Main environment file (not committed)
.env.example             # Example main environment file (committed)

πŸ› οΈ Tech Stack

Category Technology
Framework Expo SDK 54 + React Native
Routing Expo Router v6 (file-based)
Styling NativeWind v4 (Tailwind CSS)
Backend Supabase (Auth + Database + Functions)
Database PostgreSQL with Row Level Security
AI OpenAI GPT-3.5-turbo
Language TypeScript
State React Context + Hooks

πŸš€ Quick Start

Prerequisites

1. Clone and Install

# Clone the repository
git clone <your-repo-url>
cd gemini-expo-supabase

# Install dependencies
npm install

2. Set Up Supabase

# Start local Supabase
supabase start

# Apply database migrations
supabase db reset

3. Configure Environment

# Copy example environment files
cp .env.example .env
cp supabase/.env.local.example supabase/.env.local

Add your OpenAI API key to supabase/.env.local:

OPENAI_API_KEY=sk-your-actual-openai-api-key-here

The .env file will be automatically populated with local Supabase URLs when you run supabase start.

4. Start Edge Functions

# Start the OpenAI Edge Function
supabase functions serve openai --env-file supabase/.env.local

5. Run the App

# Start Expo development server
npm start

# Run on specific platforms
npm run ios     # iOS simulator
npm run android # Android emulator
npm run web     # Web browser

πŸ”§ Development

Environment Configuration

This project uses environment files to manage configuration:

File Purpose Committed
.env.example Example main environment variables βœ… Yes
.env Actual environment variables (auto-generated) ❌ No
supabase/.env.local.example Example Supabase Edge Function variables βœ… Yes
supabase/.env.local Actual Edge Function environment variables ❌ No

First-time setup:

# Copy example files
cp .env.example .env
cp supabase/.env.local.example supabase/.env.local

# Edit supabase/.env.local and add your OpenAI API key
OPENAI_API_KEY=sk-your-actual-openai-api-key-here

Local Supabase URLs

After running supabase start, you'll have:

  • API URL: http://127.0.0.1:54321
  • Database: postgresql://postgres:postgres@127.0.0.1:54322/postgres
  • Studio: http://127.0.0.1:54323 (Database management UI)
  • Edge Functions: http://127.0.0.1:54321/functions/v1/openai

Database Management

# View database schema
supabase db diff

# Reset database (applies all migrations)
supabase db reset

# Create new migration
supabase migration new <migration_name>

# View database in browser
open http://127.0.0.1:54323

Testing Edge Functions

# Test the OpenAI function
curl -X POST http://127.0.0.1:54321/functions/v1/openai \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello, AI!"}'

πŸ“± App Features

🏠 Home Screen

  • Welcome message with user info
  • Quick action cards for navigation
  • Feature overview and checklist
  • Professional card-based layout

πŸ€– AI Assistant

  • Chat interface with OpenAI GPT-3.5-turbo
  • Professional messaging UI
  • Loading states and error handling
  • Copy suggestions and examples

πŸ‘€ Account Management

  • User profile editing (username, website, full name)
  • Avatar URL management
  • Account information display
  • Secure sign out functionality

πŸ” Authentication

  • Email/password sign up and sign in
  • Form validation and error handling
  • Automatic profile creation
  • Protected route navigation

πŸš€ Deployment

Supabase Production Setup

  1. Create a new Supabase project at supabase.com
  2. Push your schema: supabase db push
  3. Deploy Edge Functions: supabase functions deploy openai
  4. Set production secrets: supabase secrets set OPENAI_API_KEY=your-key

Expo App Deployment

# Build for production
eas build --platform all

# Submit to app stores
eas submit --platform all

πŸ“š Documentation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Ready to build something amazing? πŸš€ This template gives you everything you need for a modern, scalable mobile app with authentication, database, and AI features!

About

A modern React Native template with Expo Router, Supabase authentication, and OpenAI integration

Resources

Stars

21 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages