A full-stack Next.js application featuring AI-powered chat, secure authentication, device flow authorization, and a powerful CLI tool - all in one monolithic architecture.
- Gemini AI Integration: Intelligent conversations powered by Google's Gemini AI
- Multi-Model Support: Choose from different AI models for your use case
- Conversation History: Persistent chat history with database storage
- Tool Calling & Agent Mode: Advanced AI capabilities with autonomous agents
- Secure Auth: Built with Better Auth for robust authentication
- Multiple Auth Methods: Email/password, OAuth providers support
- Device Flow: OAuth2 device flow for CLI authentication
- Session Management: Secure session handling with token-based auth
- BYOK (Bring Your Own Key): Users can use their own Gemini API keys
- Secure Storage: Encrypted API key storage in PostgreSQL
- Easy Management: Web UI and CLI for key management
- Interactive CLI: Beautiful terminal UI with
@clack/prompts - Device Authentication: Seamless login flow from the terminal
- AI Chat in Terminal: Chat with AI directly from your command line
- Tool Management: Manage API keys, auth, and more via CLI
- shadcn/ui Components: Beautiful, accessible UI components
- Responsive Design: Works seamlessly on desktop and mobile
- Dark Mode: Eye-friendly dark theme
- Real-time Updates: Instant feedback with React Query
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first styling
- shadcn/ui - High-quality UI components
- React Query - Server state management
- Next.js API Routes - Serverless API endpoints
- Prisma ORM - Type-safe database access
- PostgreSQL - Robust relational database
- Better Auth - Authentication & session management
- Vercel AI SDK - AI/LLM integration framework
- Google Gemini - Advanced AI models
- Tool Calling - Function calling capabilities
- Commander.js - CLI framework
- @clack/prompts - Beautiful CLI prompts
- Chalk & Boxen - Terminal styling
- Node.js 18+
- pnpm (recommended) or npm
- PostgreSQL database
git clone https://github.com/AJAmit17/Phantom-cli.git
cd Phantom-clipnpm installCreate a .env file in the root directory:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/Phantom"
# Authentication
BETTER_AUTH_SECRET="your-secret-key-here"
BETTER_AUTH_URL="http://localhost:3000"
# AI (Optional - users can provide their own)
GEMINI_API_KEY="your-gemini-api-key"
# App
NEXT_PUBLIC_APP_URL="http://localhost:3000"# Generate Prisma Client
pnpm prisma generate
# Run migrations
pnpm prisma migrate dev
# (Optional) Open Prisma Studio to view data
pnpm prisma studiopnpm devOpen http://localhost:3000 to see the application.
The CLI is included in the monorepo. Use it directly:
# Show all commands
pnpm cli --help
# Or install globally (from cli directory)
cd cli
npm link
phantom --help# Login with device flow
pnpm cli login
# Check current user
pnpm cli whoami
# Logout
pnpm cli logout# Set your Gemini API key
pnpm cli api-key set
# View your API key
pnpm cli api-key get
# Remove your API key
pnpm cli api-key remove# Start an AI chat session
pnpm cli ai chat
# Chat with tool calling enabled
pnpm cli ai chat --tools
# Use autonomous agent mode
pnpm cli ai agentFor detailed CLI documentation, see CLI_USAGE.md.
βββ app/ # Next.js App Router
β βββ (auth)/ # Authentication routes
β β βββ sign-in/
β β βββ sign-up/
β βββ api/ # API routes
β β βββ auth/ # Auth endpoints
β β βββ chat/ # AI chat endpoints
β β βββ conversations/ # Conversation management
β β βββ api-keys/ # API key management
β βββ chat/ # Chat interface
β βββ dashboard/ # User dashboard
β βββ device/ # Device authorization flow
βββ cli/ # CLI application
β βββ commands/ # CLI commands
β βββ chat/ # CLI chat implementations
β βββ utils/ # CLI utilities
βββ components/ # React components
β βββ ui/ # shadcn/ui components
βββ lib/ # Shared libraries
β βββ auth.ts # Auth configuration
β βββ prisma.ts # Prisma client
β βββ ai-service.ts # AI service integration
β βββ chat-service.ts # Chat management
βββ prisma/ # Database schema & migrations
βββ hooks/ # Custom React hooks
# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm start # Start production server
pnpm lint # Run ESLint
# Database
pnpm prisma generate # Generate Prisma Client
pnpm prisma migrate dev # Run migrations
pnpm prisma studio # Open Prisma Studio
# CLI
pnpm cli # Run CLI commands- Encrypted API Keys: User API keys are securely stored with encryption
- Session Management: Secure token-based sessions with expiration
- CORS Protection: Proper CORS configuration for API routes
- Input Validation: Request validation and sanitization
- Rate Limiting: Built-in rate limiting for API endpoints
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your 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.
- Next.js - The React Framework
- Vercel AI SDK - AI/LLM integration
- shadcn/ui - UI components
- Better Auth - Authentication
- Prisma - Database ORM
- Google Gemini - AI models
For support, email your-email@example.com or open an issue on GitHub.
- Documentation: CLI_USAGE.md
- Report Bug: GitHub Issues
- Request Feature: GitHub Issues
Made with β€οΈ by Amit