Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Celestial-0/Lunara

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ™ Lunara - AI Companion Chat Application

MIT License Next.js TypeScript PostgreSQL Prisma

A modern, real-time AI chat application built with Next.js, featuring advanced voice chat capabilities, real-time messaging, and a beautiful user interface. Lunara provides an intelligent AI companion experience with natural conversation flows and cutting-edge voice interaction technology.

โœจ Features

๐Ÿค– AI-Powered Conversations

  • Intelligent Responses: Powered by Google's Gemini AI with contextual understanding
  • Personality Customization: Choose from 5 AI personalities (friendly, professional, creative, analytical, empathetic)
  • Context-Aware: Maintains conversation history for meaningful, ongoing interactions
  • Custom AI Personalities: Fine-tuned prompts for different conversation styles

๐ŸŽ™๏ธ Voice Chat Integration

  • Speech Recognition: Natural voice input using Web Speech API
  • Text-to-Speech: AI responses spoken aloud with customizable voice settings
  • Real-time Audio: Live voice conversations with visual feedback
  • Audio Level Monitoring: Real-time audio visualization and voice activity detection
  • Voice Customization: Adjustable speech rate, pitch, and voice preferences

๐Ÿ’ฌ Real-Time Messaging

  • Live Updates: Messages appear instantly without page refresh using smart polling
  • Optimistic UI: Immediate feedback for better user experience
  • Typing Indicators: Visual feedback when Lunara is processing responses
  • Message Management: Edit, delete, and organize conversations

๐ŸŽจ Modern UI/UX

  • Responsive Design: Fully optimized for mobile, tablet, and desktop devices
  • Dark/Light Themes: System-aware theme switching with smooth transitions
  • Smooth Animations: Framer Motion powered interactions and micro-animations
  • Glass Morphism: Modern design with backdrop blur effects and OKLCH colors
  • Accessibility: Built with Radix UI primitives for full accessibility support

๐Ÿ‘ค User Management

  • Secure Authentication: NextAuth.js with email/password and Google OAuth
  • Profile Management: Customizable user profiles with avatar uploads
  • Conversation History: Persistent chat history with search and organization
  • Data Export: Download your conversations in JSON or CSV format
  • Privacy Controls: Granular privacy settings and data management

๐Ÿ”ง Advanced Features

  • Conversation Management: Search, organize, and manage chat sessions
  • Notification System: Real-time activity notifications with priority levels
  • Settings Panel: Comprehensive customization for voice, theme, and AI behavior
  • Mobile Optimized: Touch-friendly interface with safe area support
  • API Key Management: Personal Gemini API key support for unlimited usage
  • Maintenance Mode: Built-in maintenance mode for updates and deployments

๐Ÿ—๏ธ Tech Stack

Frontend

  • Next.js 15 - React framework with App Router and Server Components
  • TypeScript 5 - Type-safe development with strict mode
  • Tailwind CSS 4 - Utility-first styling with OKLCH colors and modern features
  • Framer Motion - Smooth animations and transitions
  • Radix UI - Accessible component primitives and design system
  • Zustand - Lightweight state management with TypeScript support
  • React Hook Form - Performant forms with easy validation

Backend & Database

  • Next.js API Routes - Serverless API endpoints with middleware
  • Prisma - Type-safe database ORM with migrations and client generation
  • PostgreSQL - Robust relational database with advanced features
  • NextAuth.js - Authentication with multiple providers and session management
  • Zod - TypeScript-first schema validation with static type inference
  • bcryptjs - Password hashing library for Node.js

AI & Voice Technology

UI/UX Libraries

  • shadcn/ui - Re-usable components built using Radix UI and Tailwind CSS
  • next-themes - Perfect dark mode in Next.js with system theme detection
  • Sonner - An opinionated toast component for React
  • class-variance-authority - Type-safe component variants with TypeScript
  • tailwind-merge - Merge Tailwind CSS classes without style conflicts
  • clsx - Tiny utility for constructing className strings conditionally

Development & Deployment

  • ESLint 9 - Code linting with Next.js and TypeScript rules
  • PostCSS - CSS transformation tool with plugin ecosystem
  • Turbopack - Incremental bundler optimized for JavaScript and TypeScript
  • Vercel - Optimized deployment platform for Next.js
  • cross-env - Cross-platform environment variable setting

๐Ÿš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Quick Start

  1. Clone the repository

    git clone https://github.com/Celestial-0/Lunara.git
    cd Lunara
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env.local

    Fill in your environment variables in .env.local:

    # Database
    DATABASE_URL="postgresql://username:password@localhost:5432/lunara"
    
    # NextAuth
    NEXTAUTH_URL="http://localhost:3000"
    NEXTAUTH_SECRET="your-nextauth-secret-key"
    
    # Google OAuth (optional)
    GOOGLE_CLIENT_ID="your-google-client-id"
    GOOGLE_CLIENT_SECRET="your-google-client-secret"
    
    # AI
    GEMINI_API_KEY="your-gemini-api-key"
  4. Set up the database

    # Generate Prisma client
    npm run db:generate
    
    # Push database schema
    npm run db:push
  5. Start the development server

    npm run dev
  6. Open your browser Navigate to http://localhost:3000 and start chatting with Lunara!

๐ŸŽ™๏ธ Voice Chat Setup

Getting Your Gemini API Key

  1. Visit Google AI Studio

  2. Create API Key

    • Click "Create API Key"
    • Choose your project or create a new one
    • Copy the generated API key
  3. Add to Environment

    • Add to your .env.local file: GEMINI_API_KEY="your-api-key-here"
    • Or add directly in the app settings for personal use

Browser Compatibility & Permissions

Supported Browsers

  • โœ… Chrome/Chromium: Full support for all voice features
  • โœ… Microsoft Edge: Full support for all voice features
  • โš ๏ธ Firefox: Limited voice recognition support
  • โš ๏ธ Safari: Limited voice features, no speech recognition

Required Permissions

  • ๐ŸŽค Microphone Access: Required for voice input and audio level monitoring
  • ๐Ÿ”Š Audio Playback: Automatic for text-to-speech responses
  • ๐Ÿ”’ HTTPS: Voice features work best over HTTPS in production

Optimizing Voice Quality

  • Use a quality microphone or headset for best recognition
  • Speak clearly and at a normal pace
  • Minimize background noise
  • Ensure stable internet connection for AI processing

๐ŸŽฏ Usage Guide

Getting Started with Conversations

  1. Sign up/Login

    • Use email and password or sign in with Google OAuth
    • Complete your profile setup for a personalized experience
  2. Start Your First Chat

    • Click "New Conversation" or begin typing in the chat interface
    • Choose an AI personality that matches your conversation style
    • Ask questions, seek advice, or just have a friendly chat
  3. Voice Chat Features

    • Click the phone icon in the chat header to start voice mode
    • Allow microphone permissions when prompted
    • Click "Start Talking" and speak naturally to Lunara
    • Lunara will respond with both text and voice

Managing Your Experience

  • Search Conversations: Use the conversation manager to find past chats
  • Edit Titles: Click the edit icon to rename conversations
  • Export Data: Download your conversation history from settings
  • Customize Settings: Adjust voice, theme, and AI behavior preferences
  • Manage API Keys: Add your personal Gemini API key for unlimited usage

โš™๏ธ Configuration

AI Personality Settings

Customize Lunara's conversation style in the Settings panel:

  • ๐Ÿค— Friendly: Warm, conversational, and supportive responses
  • ๐Ÿ’ผ Professional: Business-focused, efficient, and direct communication
  • ๐ŸŽจ Creative: Imaginative, colorful language, and innovative thinking
  • ๐Ÿ“Š Analytical: Logical, data-driven, and detailed explanations
  • ๐Ÿ’ Empathetic: Understanding, emotionally aware, and compassionate

Voice Configuration

Fine-tune voice interaction settings:

  • Voice Speed: Adjust speech rate from 0.5x to 2.0x
  • Voice Pitch: Modify voice pitch from 0.5x to 2.0x
  • Enable/Disable: Toggle voice features on/off
  • Audio Feedback: Visual audio level monitoring
  • Browser Compatibility: Works best in Chrome and Edge

API Key Management

For unlimited usage, add your personal Gemini API key:

  1. Visit Google AI Studio
  2. Create a new API key
  3. Add it in Settings โ†’ API Key Management
  4. Enjoy unlimited conversations without rate limits

Theme & Appearance

  • System: Automatically matches your device's theme
  • Light: Clean, bright interface for daytime use
  • Dark: Easy on the eyes for evening conversations

๐Ÿ› ๏ธ Development

Project Architecture

Lunara/
โ”œโ”€โ”€ app/                          # Next.js App Router
โ”‚   โ”œโ”€โ”€ api/                     # API routes and endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ auth/               # Authentication endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ chat/               # AI chat processing
โ”‚   โ”‚   โ”œโ”€โ”€ conversations/      # Conversation management
โ”‚   โ”‚   โ”œโ”€โ”€ messages/           # Message handling
โ”‚   โ”‚   โ”œโ”€โ”€ notifications/      # Notification system
โ”‚   โ”‚   โ”œโ”€โ”€ preferences/        # User settings
โ”‚   โ”‚   โ”œโ”€โ”€ profile/            # Profile management
โ”‚   โ”‚   โ”œโ”€โ”€ search/             # Search functionality
โ”‚   โ”‚   โ””โ”€โ”€ export/             # Data export
โ”‚   โ”œโ”€โ”€ auth/                   # Authentication pages
โ”‚   โ”œโ”€โ”€ chat/                   # Main chat interface
โ”‚   โ”œโ”€โ”€ maintenance/            # Maintenance mode pages
โ”‚   โ”œโ”€โ”€ globals.css             # Global styles and Tailwind
โ”‚   โ”œโ”€โ”€ layout.tsx              # Root layout component
โ”‚   โ””โ”€โ”€ page.tsx                # Home page
โ”œโ”€โ”€ components/                  # React components
โ”‚   โ”œโ”€โ”€ auth/                   # Authentication components
โ”‚   โ”‚   โ”œโ”€โ”€ AuthProvider.tsx    # Auth context provider
โ”‚   โ”‚   โ””โ”€โ”€ SignInForm.tsx      # Login/signup form
โ”‚   โ”œโ”€โ”€ chat/                   # Chat-specific components
โ”‚   โ”‚   โ”œโ”€โ”€ ChatInterface.tsx   # Main chat UI
โ”‚   โ”‚   โ”œโ”€โ”€ VoiceChat.tsx       # Voice chat interface
โ”‚   โ”‚   โ”œโ”€โ”€ MessageBubble.tsx   # Individual messages
โ”‚   โ”‚   โ”œโ”€โ”€ Sidebar.tsx         # Navigation sidebar
โ”‚   โ”‚   โ”œโ”€โ”€ SettingsDialog.tsx  # Settings panel
โ”‚   โ”‚   โ”œโ”€โ”€ ProfileDialog.tsx   # Profile management
โ”‚   โ”‚   โ”œโ”€โ”€ ConversationManager.tsx  # Chat organization
โ”‚   โ”‚   โ”œโ”€โ”€ NotificationCenter.tsx   # Notifications
โ”‚   โ”‚   โ”œโ”€โ”€ AudioControls.tsx   # Audio controls
โ”‚   โ”‚   โ”œโ”€โ”€ TypingIndicator.tsx # Loading states
โ”‚   โ”‚   โ””โ”€โ”€ ApiKeyDialog.tsx    # API key management
โ”‚   โ”œโ”€โ”€ core/                   # Core UI components
โ”‚   โ”‚   โ”œโ”€โ”€ ThemeProvider.tsx   # Theme management
โ”‚   โ”‚   โ”œโ”€โ”€ ThemeToggle.tsx     # Theme switcher
โ”‚   โ”‚   โ””โ”€โ”€ HomeUI.tsx          # Landing page
โ”‚   โ””โ”€โ”€ ui/                     # Reusable UI components (Radix)
โ”œโ”€โ”€ lib/                        # Utilities and configurations
โ”‚   โ”œโ”€โ”€ auth.ts                 # NextAuth configuration
โ”‚   โ”œโ”€โ”€ prisma.ts               # Database client
โ”‚   โ”œโ”€โ”€ store.ts                # Zustand state management
โ”‚   โ”œโ”€โ”€ utils.ts                # Utility functions
โ”‚   โ”œโ”€โ”€ api-client.ts           # API client wrapper
โ”‚   โ”œโ”€โ”€ hooks/                  # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useApi.ts           # API integration hook
โ”‚   โ”‚   โ”œโ”€โ”€ useRealTimeMessages.ts  # Real-time updates
โ”‚   โ”‚   โ””โ”€โ”€ useVoiceChat.ts     # Voice chat functionality
โ”‚   โ””โ”€โ”€ generated/              # Prisma generated files
โ”œโ”€โ”€ prisma/                     # Database schema and migrations
โ”‚   โ”œโ”€โ”€ schema.prisma           # Database schema
โ”‚   โ””โ”€โ”€ migrations/             # Database migrations
โ”œโ”€โ”€ public/                     # Static assets
โ”œโ”€โ”€ types/                      # TypeScript type definitions
โ”‚   โ””โ”€โ”€ types.ts                # Shared type definitions
โ”œโ”€โ”€ .env.example                # Environment variables template
โ”œโ”€โ”€ next.config.ts              # Next.js configuration
โ”œโ”€โ”€ tailwind.config.ts          # Tailwind CSS configuration
โ”œโ”€โ”€ tsconfig.json               # TypeScript configuration
โ””โ”€โ”€ package.json                # Dependencies and scripts

Key Components Deep Dive

Core Chat Components

  • ChatInterface: Main chat UI with real-time messaging, voice controls, and mobile optimization
  • VoiceChat: Voice interaction with speech recognition and synthesis
  • MessageBubble: Individual message display with timestamps and status
  • Sidebar: Navigation, conversation list, and user management
  • NotificationCenter: Real-time notifications with priority levels

State Management

  • Zustand Store: Lightweight state management for conversations, messages, and UI state
  • Real-time Updates: Custom hooks for polling and optimistic updates
  • Persistence: Session storage for UI state and local caching

Database Schema

  • Users: Authentication and profile data with NextAuth integration
  • Conversations: Chat sessions with metadata and timestamps
  • Messages: Individual chat messages with role-based content
  • UserPreferences: Settings, theme, and AI personality configuration
  • UserProfile: Extended profile information and avatar management
  • Notifications: Real-time activity notifications with read status

Development Scripts

# Development
npm run dev              # Start development server with Turbopack
npm run build           # Build for production
npm run start           # Start production server
npm run lint            # Run ESLint

# Database
npm run db:generate     # Generate Prisma client
npm run db:push         # Push schema to database
npm run db:migrate      # Run database migrations
npm run db:studio       # Open Prisma Studio

Environment Variables

# Database
DATABASE_URL="postgresql://user:password@localhost:5432/lunara"

# Authentication
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key"

# Google OAuth (optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# AI Integration
GEMINI_API_KEY="your-gemini-api-key"

# Optional Features
MAINTENANCE_MODE="false"

๐Ÿš€ Deployment

Vercel (Recommended)

Lunara is optimized for Vercel deployment:

  1. Connect Repository

    • Fork this repository to your GitHub account
    • Connect your Vercel account to GitHub
    • Import the Lunara project
  2. Configure Environment Variables

    DATABASE_URL="your-production-database-url"
    NEXTAUTH_URL="https://your-domain.vercel.app"
    NEXTAUTH_SECRET="your-production-secret"
    GEMINI_API_KEY="your-gemini-api-key"
    GOOGLE_CLIENT_ID="your-google-client-id"      # Optional
    GOOGLE_CLIENT_SECRET="your-google-client-secret"  # Optional
  3. Database Setup

    • Use a PostgreSQL provider (Railway, Supabase, PlanetScale, etc.)
    • Run migrations: npx prisma migrate deploy
    • Generate client: npx prisma generate
  4. Deploy

    • Push to main branch for automatic deployment
    • Vercel handles build optimization and CDN distribution

Alternative Deployment Options

Docker Deployment

# Use official Node.js runtime
FROM node:18-alpine

# Set working directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy app source
COPY . .

# Generate Prisma client
RUN npx prisma generate

# Build application
RUN npm run build

# Expose port
EXPOSE 3000

# Start application
CMD ["npm", "start"]

Self-Hosted Setup

  1. Clone repository on your server
  2. Install Node.js 18+ and PostgreSQL
  3. Set up environment variables
  4. Run database migrations
  5. Build and start the application
  6. Configure reverse proxy (nginx/Apache)

๐Ÿค Contributing

We welcome contributions to Lunara! Whether you're fixing bugs, adding features, or improving documentation, your help is appreciated.

Getting Started

  1. Fork the repository

    git fork https://github.com/Celestial-0/Lunara.git
  2. Clone your fork

    git clone https://github.com/your-username/Lunara.git
    cd Lunara
  3. Create a feature branch

    git checkout -b feature/amazing-feature
  4. Make your changes

    • Follow the existing code style
    • Add tests for new features
    • Update documentation as needed
  5. Commit your changes

    git commit -m 'feat: add amazing feature'
  6. Push to your branch

    git push origin feature/amazing-feature
  7. Open a Pull Request

    • Describe your changes clearly
    • Link to any relevant issues
    • Wait for review and feedback

Development Guidelines

  • Code Style: Follow TypeScript and ESLint configurations
  • Commits: Use conventional commit messages (feat:, fix:, docs:, etc.)
  • Testing: Ensure all tests pass before submitting
  • Documentation: Update README and code comments for new features

Areas for Contribution

  • ๐Ÿ› Bug Fixes: Check the issues tab for known bugs
  • โœจ Features: Voice enhancements, UI improvements, new AI personalities
  • ๐Ÿ“š Documentation: API docs, tutorials, code comments
  • ๐Ÿงช Testing: Unit tests, integration tests, E2E tests
  • ๐ŸŽจ Design: UI/UX improvements, animations, themes
  • ๐ŸŒ Internationalization: Multi-language support

๐Ÿ“„ License

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

What this means:

  • โœ… Commercial use allowed
  • โœ… Modification allowed
  • โœ… Distribution allowed
  • โœ… Private use allowed
  • โŒ No warranty provided
  • โŒ No liability assumed

๐Ÿ“ž Support & Community

Getting Help

  • ๐Ÿ“– Documentation: Check this README and inline code comments
  • ๐Ÿ› Bug Reports: Create an issue with detailed information
  • ๐Ÿ’ก Feature Requests: Open a discussion to propose new features
  • โ“ Questions: Use GitHub Discussions for general questions

Stay Updated

  • โญ Star the repository to stay notified of updates
  • ๐Ÿ‘€ Watch releases for new version announcements
  • ๐Ÿด Fork to contribute and customize for your needs

๐Ÿ—บ๏ธ Roadmap

Upcoming Features

  • ๐ŸŒ WebRTC Integration: Direct peer-to-peer voice calls with better quality
  • ๐Ÿ“Ž File Sharing: Upload and discuss documents, images, and media
  • ๐ŸŒ Multi-language Support: International voice recognition and UI translations
  • ๐ŸŽญ Custom Voice Models: Personalized TTS voices and voice cloning
  • ๐Ÿ“ฑ Mobile Apps: Native iOS and Android applications
  • ๐Ÿ‘ฅ Team Workspaces: Collaborative AI assistance for teams and organizations
  • ๐Ÿ”Œ Plugin System: Third-party integrations and custom AI models
  • ๐Ÿ“Š Analytics Dashboard: Conversation insights and usage statistics
  • ๐ŸŽฎ Interactive Elements: Games, quizzes, and interactive learning
  • ๐Ÿ” Advanced Search: Semantic search across conversation history

Long-term Vision

  • AI-powered conversation coaching and improvement suggestions
  • Integration with productivity tools and calendars
  • Voice-based automation and smart home control
  • Advanced emotional intelligence and context understanding
  • Blockchain integration for privacy and data ownership

Built with โค๏ธ using modern web technologies

Experience the future of AI conversation today!

Deploy with Vercel

About

Lunara: AI companion chat app with voice interaction, real-time messaging, and customizable personalities powered by Google Gemini AI

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors