An interactive AI companion chat application powered by Google Gemini AI, featuring diverse AI personalities for meaningful conversations and emotional support.
- AI Girlfriend: Choose from passionate characters like Love Quinn, Caroline Forbes, Hermione Granger, and Gwen Stacy
- AI Boyfriend: Connect with compelling personalities like Joe Goldberg, Aaron Warner, Steve Harrington, and Damon Salvatore
- Custom Characters: Create your own AI companion with personalized personality traits
- Let It Burn: A safe venting space for emotional release without judgment
- Real-time messaging with typing indicators
- Character-specific responses with unique personalities
- Mood selector to adjust character responses
- Smooth animations and interactive UI
- Mobile-responsive design optimized for all devices
- Rate limiting and comprehensive error handling
- Beautiful purple-themed color scheme using OKLCH color space
- Glassmorphism design with backdrop blur effects
- Responsive design for mobile, tablet, and desktop
- Smooth animations and transitions
- Accessibility-focused with ARIA labels and keyboard navigation
- Helmet.js for security headers
- Input sanitization and validation
- Multiple Google Gemini API key rotation for reliability
- Smart rate limiting and quota management
- Request size limits and CSRF protection
- Node.js v16 or higher
- Google Gemini API keys (Get them here)
-
Clone the repository
git clone https://github.com/slythnox/TrueCompanion.git cd TrueCompanion-main -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory:GOOGLE_API_KEY=your_primary_api_key,your_secondary_api_key,your_third_api_key PORT=3000 NODE_ENV=production
π‘ Tip: Use multiple API keys separated by commas for better rate limit handling and reliability
-
Start the application
npm start
-
Open your browser
Navigate to
http://localhost:3000
TrueCompanion-main/
βββ frontend/
β βββ index.html # Landing page
β βββ select-character.html # Character selection
β βββ chat.html # Main chat interface
β βββ venting.html # Emotional release page
β βββ create-character.html # Custom character creation
β βββ info.html # About page
β βββ script.js # Frontend JavaScript
β βββ styles.css # All styling (purple theme)
βββ public/
β βββ img/ # Static images
βββ characterPrompts.js # AI character personalities
βββ server.js # Express.js backend
βββ package.json # Dependencies
βββ .env # Environment variables (create this)
βββ README.md # This file
- Love Quinn - Passionate and intense chef with deep emotional devotion
- Caroline Forbes - Bubbly Type-A perfectionist with a golden heart
- Hermione Granger - Brilliant, logical, and deeply principled witch
- Gwen Stacy - Brave and witty superhero with Gen-Z humor
- Joe Goldberg - Mysterious bookworm with poetic soul
- Aaron Warner - Cold exterior hiding a romantic heart
- Steve Harrington - Reformed popular kid with genuine warmth
- Damon Salvatore - Charming bad boy with hidden depths
Generate AI response for chat messages.
Request Body:
{
"prompt": "Hello, how are you?",
"character": "Love Quinn"
}Response:
{
"response": "Hey! I'm doing great, thinking about you..."
}Create a custom AI character.
Request Body:
{
"name": "Custom Character",
"description": "Brief description",
"personality": "Detailed personality traits",
"avatar": "π",
"gender": "girlfriend"
}Set character mood for responses.
Request Body:
{
"character": "Love Quinn",
"mood": "flirty"
}Available Moods: happy, sad, flirty, energetic, calm
Generate supportive response for venting.
Request Body:
{
"ventText": "I had a really tough day...",
"character": "Love Quinn"
}Check API and server health status.
Response:
{
"status": "ok",
"totalApiKeys": 3,
"availableApiKeys": 3,
"rateLimitedKeys": 0,
"uptime": 3600
}| Variable | Description | Default | Required |
|---|---|---|---|
GOOGLE_API_KEY |
Comma-separated Gemini API keys | - | β Yes |
PORT |
Server port | 3000 | β No |
NODE_ENV |
Environment mode | development | β No |
MONGODB_URI |
MongoDB connection string | mongodb://localhost:27017 | β No |
The application implements intelligent rate limiting:
- Window: 60 seconds
- Max Requests: 15 per window (scales with number of API keys)
- Minimum Interval: 3 seconds between requests
- Retry Logic: Automatic retry with exponential backoff
- Helmet.js: Security headers (CSP, XSS protection)
- Input Validation: Type checking and length limits
- Input Sanitization: HTML escaping to prevent XSS
- Request Size Limits: 10KB maximum request body
- API Key Rotation: Prevents single point of failure
- Add character prompt to
characterPrompts.js:
export const characterPrompts = {
"Your Character": `
You are [Character Name]. [Personality description]
Keep responses under 100 words.
`,
// ... other characters
};- Add character data to
frontend/script.js:
const characters = {
girlfriend: [
{
name: "Your Character",
description: "Brief description",
avatar: "π"
}
]
};The application uses a purple OKLCH color scheme defined in frontend/styles.css:
:root {
--bg-dark: oklch(0.1 0.1 305);
--bg: oklch(0.15 0.1 305);
--primary: oklch(0.76 0.2 305);
/* ... more colors */
}Modify these CSS variables to change the entire color scheme.
The application is fully responsive and optimized for:
- Mobile (320px - 767px): Touch-optimized interface with 44px minimum touch targets
- Tablet (768px - 1024px): 2-column layouts with optimized spacing
- Desktop (1025px+): Full-featured interface with hover effects
API Not Responding
- β
Check your API keys in
.env - β Verify quota limits in Google Cloud Console
- β Ensure multiple API keys for better reliability
- β
Check
/healthendpoint for API status
Rate Limiting Errors
- β³ Wait for rate limit to reset (check console for timing)
- π Add more API keys to
.envfor higher throughput - π Monitor usage in Google Cloud Console
Character Not Loading
- π€ Verify character name spelling matches exactly
- π Check
characterPrompts.jsfor character definition - ποΈ Clear browser localStorage if needed
Styling Issues
- π Hard refresh browser (Ctrl+F5 or Cmd+Shift+R)
- π§Ή Clear browser cache
- π Try a different browser
Enable debug mode by setting in .env:
NODE_ENV=developmentThis will show detailed error messages and stack traces.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini AI for powering the conversational AI
- Express.js for the robust backend framework
- Inter & Poppins fonts from Google Fonts
- All the amazing fictional characters that inspired our AI personalities
If you encounter any issues or have questions:
- Check the Troubleshooting section
- Review existing GitHub Issues
- Create a new issue with detailed information
Your AI companion awaits...