Skip to content

surajiyer/roleplay-chat-app

Repository files navigation

Advanced Roleplay Chat App

A modern Next.js application for engaging in roleplay conversations with AI-powered fictional characters.

Features

  • 🎭 Character Roleplay - Interact with diverse fictional characters
  • 💬 AI-Powered Chat - Advanced conversations using local AI models
  • 🔒 Private & Secure - Your conversations stay private
  • 🎨 Custom Characters - Create your own characters
  • 🔐 Secure Authentication - User registration and login with NextAuth.js
  • 📱 Responsive Design - Works on desktop and mobile devices

Tech Stack

  • Framework: Next.js 15 with App Router
  • Database: PostgreSQL with Prisma ORM
  • Authentication: NextAuth.js v4
  • UI: Radix UI with Tailwind CSS
  • Validation: Zod
  • TypeScript: For type safety

Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • npm/yarn/pnpm

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd roleplay-chat-app
  1. Install dependencies:
npm install
# or
yarn install
# or
pnpm install
  1. Set up environment variables:
cp .env.example .env.local

Edit .env.local with your values:

DATABASE_URL="postgresql://username:password@localhost:5432/database_name"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"
  1. Set up the database:
npx prisma db push
npx prisma db seed
  1. Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

Project Structure

src/
├── app/                    # Next.js App Router pages
│   ├── api/               # API routes
│   ├── login/             # Login page
│   ├── register/          # Registration page
│   └── dashboard/         # Protected dashboard
├── components/            # Reusable components
├── lib/                   # Utility functions
│   ├── auth.ts           # Password hashing utilities
│   ├── prisma.ts         # Database client
│   ├── validations.ts    # Zod schemas
│   └── api-utils.ts      # API response utilities
├── types/                 # TypeScript type definitions
└── auth.ts               # NextAuth.js configuration

Database Schema

The application uses the following main entities:

  • Users: Authentication and user management
  • Characters: AI roleplay characters with personalities and prompts
  • Conversations: Chat sessions between users and characters
  • Messages: Individual messages within conversations

Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint
  • npm run db:seed - Seed database with sample characters

Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string Yes
NEXTAUTH_URL App URL for NextAuth Yes
NEXTAUTH_SECRET Secret for NextAuth sessions Yes

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License.

About

Streamlit AI Chat App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published