This repository contains the source code for building a SaaS AI-COMPANION Platform using Next.js 13, React, Tailwind CSS, TypeScript, Prisma, PostgreSQL, and Stripe.
- Fully styled using Tailwind CSS.
- Integrated with Tailwind animations for a polished user interface.
- Optimized for seamless display across devices, ensuring a great user experience.
- Utilizes Clerk Authentication with support for Email and Google.
- Implements react-hook-form for intuitive client-side form validation and management.
- Includes react-toast for server-side error handling and user notifications.
- Ensures a smooth user experience with optimized page loading indicators.
- Fully integrated with Stripe to handle subscription payments, including:
- Monthly subscriptions
- Token-based top-ups
- Time-based call plans
- Implements
POST
,GET
, andDELETE
API endpoints using Next.js route handlers.
- Fetches data directly in server-side React components, eliminating the need for intermediate APIs.
- Manages relationships between parent and child components efficiently.
- Features reusable layouts for consistent and modular application design.
- Organizes the application using the Next.js 13 App Router and modern folder structure.
- Integrated with Cloudinary for secure and efficient image hosting and management.
- Utilizes OpenAI APIs for advanced AI-driven features, such as personality simulation.
- Node.js: Ensure you have Node.js 18.x.x installed.
- PostgreSQL Database: Set up a cloud-hosted PostgreSQL database for application data.
- Stripe Account: Obtain necessary API keys for subscription management.
- Clerk Account: Configure Clerk for authentication.
git clone https://github.com/VALASALARAKESH/AI-COMPANION-V2.git
cd AI-COMPANION-V2
Install all dependencies using npm
:
npm install
Create a .env
file in the root directory and add the following variables:
Variable Name | Description |
---|---|
TOKENS_TOPUP_PRICE_ID |
Price ID for tokens top-up. |
CALLTIME_TOPUP_5_PRICE_ID |
Price ID for 5 minutes call time top-up. |
CALLTIME_TOPUP_10_PRICE_ID |
Price ID for 10 minutes call time top-up. |
CALLTIME_TOPUP_30_PRICE_ID |
Price ID for 30 minutes call time top-up. |
UNLIMITED_SUB_PRICE_ID |
Price ID for unlimited subscription. |
PRO_SUB_PRICE_ID |
Price ID for pro subscription. |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Publishable key for Clerk authentication. |
CLERK_SECRET_KEY |
Secret key for Clerk authentication. |
DATABASE_URL |
Connection string for PostgreSQL database. |
NEXT_PUBLIC_APP_URL |
Base URL of the application. |
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME |
Cloud name for Cloudinary image uploads. |
NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET |
Upload preset for Cloudinary. |
STRIPE_API_KEY |
API key for Stripe payment processing. |
STRIPE_WEBHOOK_SECRET |
Webhook secret for Stripe. |
NEXT_PUBLIC_OPENAI_API_KEY |
API key for OpenAI integration. |
-
Generate Prisma Client:
npx prisma generate
-
Push the database schema to your PostgreSQL database:
npx prisma db push
-
Seed the database with initial data:
node scripts/seed_phone_voices_bolna.js
Run the development server:
npm run dev
The application will be available at http://localhost:3000.
The backend for this project can be found at: modal-ai-companion
- Character-based AI interactions with configurable personalities
- YAML-based character configuration
- Image generation support for character avatars
- Streaming responses
- Modal-based deployment architecture
- FastAPI backend integration
- Python 3.10 or higher
- Poetry for dependency management
- Modal.com account
- Required API keys:
- DeepInfra API key
- FAL.ai API key
- OpenAI API key (optional)
- Google Cloud Storage credentials
- Clone the backend repository:
git clone https://github.com/VALASALARAKESH/modal-ai-companion.git
cd modal-ai-companion
- Install dependencies using Poetry:
poetry install
Required environment variables:
API_KEY
: Authentication token (used to authenticate with app endpoint)MODAL_TOKEN_ID
: Modal authentication token IDMODAL_TOKEN_SECRET
: Modal authentication secretDeep Infra API key
: Added to Modal secretsFAL.ai API key
: Added to Modal secretsGCP credentials
: Added to Modal secrets for image storage
Start the server:
modal serve src.app
To deploy:
modal deploy src.app
- src/
app.py
: Main FastAPI application- agent/: Modal agent implementation
- handlers/: Image and LLM handling logic
- models/: Data models and schemas
- test/
- characters/: Character YAML files
client.py
: Test client implementationcharacter_loader.py
: YAML character loading utilities
/init_agent
: Initialize or update an agent/prompt
: Send prompts to the agent/generate_avatar
: Generate character avatars
Run these commands with npm run [command]
:
Command | Description |
---|---|
dev |
Starts a development instance of the app. |
We welcome contributions! If you'd like to contribute, please:
- Fork this repository.
- Create a new branch with your feature or fix.
- Submit a pull request for review.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, please contact Rakesh Valasala:
- Email: [email protected]
- LinkedIn: linkedin.com/in/rakeshvalasala