Skip to content

πŸš€ Phantom CLI - A monolithic Next.js application with AI-powered chat (Gemini), secure authentication, device flow authorization, and a powerful CLI tool. Features include conversation history, API key management, and autonomous agent mode.

Notifications You must be signed in to change notification settings

AJAmit17/Phantom-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Phantom CLI - AI-Powered Monolithic Application

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.

✨ Features

πŸ€– AI-Powered Chat

  • 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

πŸ” Authentication & Authorization

  • 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

πŸ”‘ API Key Management

  • 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

πŸ’» Command Line Interface

  • 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

🎨 Modern UI/UX

  • 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

πŸ› οΈ Tech Stack

Frontend

  • 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

Backend

  • Next.js API Routes - Serverless API endpoints
  • Prisma ORM - Type-safe database access
  • PostgreSQL - Robust relational database
  • Better Auth - Authentication & session management

AI & Tools

  • Vercel AI SDK - AI/LLM integration framework
  • Google Gemini - Advanced AI models
  • Tool Calling - Function calling capabilities

CLI

  • Commander.js - CLI framework
  • @clack/prompts - Beautiful CLI prompts
  • Chalk & Boxen - Terminal styling

πŸ“¦ Installation

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm
  • PostgreSQL database

1. Clone the repository

git clone https://github.com/AJAmit17/Phantom-cli.git
cd Phantom-cli

2. Install dependencies

pnpm install

3. Set up environment variables

Create 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"

4. Set up the database

# Generate Prisma Client
pnpm prisma generate

# Run migrations
pnpm prisma migrate dev

# (Optional) Open Prisma Studio to view data
pnpm prisma studio

5. Run the development server

pnpm dev

Open http://localhost:3000 to see the application.

πŸ–₯️ CLI Usage

Installation

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

Authentication

# Login with device flow
pnpm cli login

# Check current user
pnpm cli whoami

# Logout
pnpm cli logout

API Key Management

# 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

AI Chat

# 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 agent

For detailed CLI documentation, see CLI_USAGE.md.

πŸ“ Project Structure

β”œβ”€β”€ 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

πŸš€ Available Scripts

# 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

πŸ”’ Security Features

  • 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

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

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

πŸ™ Acknowledgments

πŸ“§ Support

For support, email your-email@example.com or open an issue on GitHub.

πŸ”— Links


Made with ❀️ by Amit

About

πŸš€ Phantom CLI - A monolithic Next.js application with AI-powered chat (Gemini), secure authentication, device flow authorization, and a powerful CLI tool. Features include conversation history, API key management, and autonomous agent mode.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published