An AI-powered content generation platform built with Next.js 16, React 19, and Firebase. Xref.ai helps you create original content for blog posts, essays, marketing copy, product descriptions, and more using advanced AI capabilities.
- π¬ AI Chat β Real-time conversational AI with streaming responses and conversation memory
- π Text Summarization β Summarize any topic or scrape websites for content summarization
- β¨ Freestyle Writing β Generate creative content from custom prompts
- π Text Simplification β Simplify complex text to different reading levels (1st Grade to PhD)
- π¨ Image Generation β Create AI-generated images from text descriptions
- π― Designer Tool β Mix creative elements (colors, artists, styles) to generate unique visual designs
- π History β View and manage all your past generations
- π³ Payments β Stripe integration for premium features and credits
- Tech Stack
- Prerequisites
- Installation
- Environment Variables
- Project Structure
- Features Deep Dive
- Architecture
- API Reference
- Contributing
- License
| Package | Version | Purpose |
|---|---|---|
| Next.js | 16.x | React framework with App Router and Turbopack |
| React | 19.x | UI library with latest features |
| TypeScript | 5.x | Type safety and developer experience |
| Package | Version | Purpose |
|---|---|---|
| Vercel AI SDK | 6.x | Streaming AI responses and model integration |
| @ai-sdk/react | 3.x | UI hooks for streaming chat |
| @ai-sdk/openai | 3.x | OpenAI provider for text generation |
| @ai-sdk/anthropic | 3.x | Anthropic provider |
| @ai-sdk/xai | 3.x | xAI provider |
| @ai-sdk/google | 3.x | Google provider |
| @ai-sdk/rsc | 2.x | Server Actions streaming |
| Package | Version | Purpose |
|---|---|---|
| Firebase | 12.x | Authentication, Firestore database, Cloud Storage |
| Firebase Admin | 13.x | Server-side Firebase operations |
| Stripe | 20.x | Payment processing |
| Package | Version | Purpose |
|---|---|---|
| Tailwind CSS | 4.x | Utility-first CSS framework |
| Lucide React | 0.562.x | Beautiful icon library |
| React Select | 5.x | Advanced select/dropdown components |
| React Markdown | 10.x | Render markdown content |
| React Hot Toast | 2.x | Toast notifications |
| Package | Version | Purpose |
|---|---|---|
| Zustand | 5.x | Lightweight state management |
| Axios | 1.x | HTTP client for API requests |
| Cheerio | 1.x | HTML parsing for web scraping |
| Lodash | 4.x | Utility functions |
| Package | Purpose |
|---|---|
| react-scroll-to-bottom | Auto-scrolling chat container |
| react-textarea-autosize | Auto-expanding textareas |
| react-simple-typewriter | Typewriter effect animations |
| react-cookie-consent | GDPR cookie consent banner |
| react-firebase-hooks | Firebase React hooks |
| remark-gfm | GitHub Flavored Markdown support |
| sharp | Image processing and optimization |
| cookies-next | Cookie management for Next.js |
Before you begin, ensure you have:
- Node.js 18.x or higher
- npm 9.x or higher (or yarn/pnpm)
- A Firebase project with:
- Authentication enabled (Email/Password and/or Google)
- Firestore Database
- Cloud Storage
- An OpenAI API key (optional if you use credits only)
- A Fireworks AI API key (for image generation)
- A Stripe account (for payments)
- Optional: Anthropic, xAI, or Google API keys for alternate models
-
Clone the repository
git clone https://github.com/brown2020/xrefaiapp.git cd xrefaiapp -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local
Fill in your credentials (see Environment Variables)
-
Run the development server
npm run dev
-
Open in browser
Navigate to http://localhost:3000
Create a .env.local file in the root directory with the following variables:
# Firebase Client Configuration
NEXT_PUBLIC_FIREBASE_APIKEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTHDOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECTID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGEBUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID=your_sender_id
NEXT_PUBLIC_FIREBASE_APPID=your_app_id
NEXT_PUBLIC_FIREBASE_MEASUREMENTID=G-XXXXXXXXXX
# Firebase Admin (Server-side)
FIREBASE_TYPE=service_account
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_PRIVATE_KEY_ID=your_private_key_id
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your_project.iam.gserviceaccount.com
FIREBASE_CLIENT_ID=your_client_id
FIREBASE_AUTH_URI=https://accounts.google.com/o/oauth2/auth
FIREBASE_TOKEN_URI=https://oauth2.googleapis.com/token
FIREBASE_AUTH_PROVIDER_X509_CERT_URL=https://www.googleapis.com/oauth2/v1/certs
FIREBASE_CLIENT_CERTS_URL=https://www.googleapis.com/robot/v1/metadata/x509/...
# AI Providers (used when credits are enabled)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=...
XAI_API_KEY=...
GOOGLE_API_KEY=...
# Fireworks AI (Image Generation)
FIREWORKS_API_KEY=your_fireworks_api_key
# Stripe
NEXT_PUBLIC_STRIPE_KEY=pk_...
STRIPE_SECRET_KEY=sk_...
NEXT_PUBLIC_STRIPE_PRODUCT_NAME=Xref.ai Credits
APP_URL=https://your-production-domain.com
# Optional
NEXT_PUBLIC_COOKIE_NAME=xrefAuthToken
# Optional (native IAP WebView)
IAP_WEBVIEW_SECRET=your_shared_hmac_secret| Service | Where to Get |
|---|---|
| Firebase | Firebase Console β Project Settings |
| OpenAI | OpenAI Platform |
| Fireworks AI | Fireworks Console |
| Stripe | Stripe Dashboard |
xrefaiapp/
βββ public/ # Static assets
β βββ .well-known/ # App associations (iOS/Android deep links)
βββ src/
β βββ actions/ # Server Actions
β β βββ generateAIResponse.ts # Unified AI text generation
β β βββ generateImage.ts # AI image generation
β β βββ confirmIapPurchase.ts # Native IAP fulfillment
β β βββ paymentActions.ts # Stripe payment handling
β β βββ suggestTags.ts # AI tag suggestions
β β
β βββ app/ # Next.js App Router pages
β β βββ api/proxy/ # Web scraping proxy endpoint
β β βββ api/chat/ # AI chat streaming endpoint
β β βββ chat/ # AI chat interface
β β βββ tools/ # AI writing tools
β β βββ history/ # Generation history
β β βββ account/ # User account management
β β βββ ... # Other pages
β β
β βββ components/ # React components
β β βββ ui/ # Reusable UI components
β β βββ icons/ # SVG icon components
β β βββ DesignerPrompt/ # Designer tool components
β β βββ ... # Feature components
β β
β βββ hooks/ # Custom React hooks
β β βββ useChatMessages.ts # Chat history management
β β βββ useHistorySaver.ts # Save to Firestore
β β βββ ...
β β
β βββ firebase/ # Firebase configuration
β β βββ firebaseClient.ts # Client-side SDK
β β βββ firebaseAdmin.ts # Admin SDK (server)
β β
β βββ zustand/ # State management stores
β β βββ useAuthStore.ts # Authentication state
β β βββ useProfileStore.ts # User profile state
β β βββ usePaymentsStore.ts # Payment/credits state
β β
β βββ data/ # Static data (painters, colors, etc.)
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
β
βββ .env.example # Environment variables template
βββ next.config.mjs # Next.js configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
A full-featured chat interface with:
- Streaming responses β UI streaming via AI SDK
useChatand/api/chat - Conversation memory β AI remembers context from previous messages
- Persistent history β Conversations saved to Firestore
- Load more β Pagination for older messages
Six AI-powered writing tools:
| Tool | Description |
|---|---|
| Summarize Website | Enter a URL to scrape and summarize web content |
| Summarize Text | Paste text to get a concise summary |
| Freestyle Writing | Generate creative content from any prompt |
| Simplify Writing | Convert complex text to simpler reading levels |
| Generate Image | Create AI images from text descriptions |
| Designer Tool | Combine creative elements for unique visual designs |
- View all past generations (text and images)
- Search through history
- Copy or download previous outputs
- Expandable conversation view
- View profile information
- Manage credits and payments
- Delete account option
Xref.ai uses Server Actions for tools and API routes for chat streaming with AI SDK UI:
// Example: /api/chat route (AI SDK UI)
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: openai("gpt-5.4"),
messages,
});
return result.toUIMessageStreamResponse();
}Lightweight, modular stores:
- useAuthStore β User authentication state
- useProfileStore β User profile and preferences
- usePaymentsStore β Credits and payment status
users/
βββ {uid}/
βββ profile # User profile document
βββ summaries/ # Text generation history
β βββ {docId}
βββ chats/ # Chat conversation history
βββ {docId}
GET /api/proxy?url={encoded_url}Fetches and returns HTML content from the specified URL for summarization.
Parameters:
url(required): URL-encoded website address
Response: Raw HTML content
| Endpoint | Purpose | Input |
|---|---|---|
POST /api/chat |
Streaming chat responses | messages, history, model |
POST /api/billing/checkout |
Start Stripe checkout session | packId, redirectPath |
POST /api/billing/confirm |
Confirm Stripe checkout session | sessionId |
GET /api/proxy |
Web scraping proxy | url |
| Action | Purpose | Input |
|---|---|---|
generateResponse |
Generate text from prompt | systemPrompt, userPrompt |
generateResponseWithMemory |
Generate with conversation context | systemPrompt, chatHistory[] |
generateImage |
Create AI image | prompt |
suggestTags |
Get tag suggestions | freestyle, tags[] |
createPaymentIntent |
Start Stripe payment | amount |
validatePaymentIntent |
Verify payment | paymentIntentId |
We welcome contributions! Here's how to get started:
-
Fork the repository
-
Create a feature branch
git checkout -b feature/amazing-feature
-
Make your changes
- Follow the existing code style
- Add TypeScript types for new code
- Test your changes locally
-
Commit your changes
git commit -m "Add amazing feature" -
Push to your fork
git push origin feature/amazing-feature
-
Open a Pull Request
- Use TypeScript for all new code
- Follow functional components with hooks
- Use Tailwind CSS for styling
- Use Server Actions for tool generation and API routes for chat streaming
- Use Zustand for global state management
- Keep components modular and reusable
npm run dev # Start development server (Turbopack)
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintThis project is licensed under the MIT License β see the LICENSE file for details.
- GitHub Issues: Report a bug
- Email: info@ignitechannel.com
- Website: xref.ai
Built with β€οΈ by brown2020