Skip to content

Srijan-Baniyal/osdc_hacknight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pageMind

AI-powered research assistant that helps you explore and analyze web content with source-restricted intelligence

Next.js React TypeScript MongoDB Perplexity

✨ Features

🧠 AI-Powered Research

  • Source-restricted research assistant powered by Perplexity AI's sonar-reasoning model
  • Chat-based interface for natural conversation flow
  • Real-time streaming responses with structured thinking and answers
  • Custom API key support for personalized usage

πŸ’¬ Intelligent Chat System

  • Multi-session conversation management
  • Persistent chat history stored in MongoDB
  • Session resumption and continuation
  • Token usage tracking (input/output/total)
  • Response time and source count metrics

🎨 Modern UI/UX

  • Immersive WebGL-powered landing page with fluid shader effects
  • Custom cursor and grain overlay for premium feel
  • Horizontal scrolling portfolio-style landing
  • Dark/Light theme support with smooth transitions
  • Responsive design across all devices

πŸ” Authentication & Security

  • Clerk authentication integration
  • User-specific chat sessions and history
  • Secure API key management
  • Protected API routes

πŸ“Š Dashboard Features

  • Clean, organized chat interface
  • Collapsible "thinking" sections showing AI reasoning
  • Source citations display
  • Message metadata (tokens, duration, sources)
  • Real-time streaming with smooth animations
  • Stop generation capability

🎭 Visual Components

  • Landing Sections:
    • Hero section with animated WebGL shaders
    • Work showcase
    • Services overview
    • About section
    • Contact form
  • Interactive Elements:
    • Magnetic buttons with hover effects
    • Smooth scroll navigation
    • Custom cursor tracking
    • Touch-optimized mobile experience

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 16.0.1 (App Router)
  • UI Library: React 19.2.0
  • Styling: Tailwind CSS 4.1.16
  • Components: Radix UI, shadcn/ui
  • Animations: Framer Motion principles, Custom CSS
  • WebGL: Shaders library for visual effects
  • Markdown: Streamdown for streaming markdown rendering

Backend

  • API Routes: Next.js API handlers
  • Database: MongoDB with Mongoose ODM
  • Authentication: Clerk
  • AI Integration: Perplexity AI SDK (@ai-sdk/perplexity)
  • Streaming: Vercel AI SDK

Development

  • Language: TypeScript 5.9.3
  • Linting: ESLint 9.39.0
  • Package Manager: Bun
  • Form Handling: React Hook Form + Zod validation
  • State Management: TanStack Query

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ or Bun
  • MongoDB Atlas account
  • Clerk account
  • Perplexity API key (optional for custom usage)

Installation

  1. Clone the repository
git clone <your-repo-url>
cd osdc_hacknight
  1. Install dependencies
bun install
# or
npm install
  1. Set up environment variables

Create a .env file in the root directory:

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key

# MongoDB
MONGODB_URI=your_mongodb_connection_string

# Perplexity AI (Default key for the app)
PERPLEXITY_API_KEY=your_perplexity_api_key

# Optional: GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
  1. Run the development server
bun dev
# or
npm run dev
  1. Open your browser Navigate to http://localhost:3000

πŸ“ Project Structure

osdc_hacknight/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── chat/
β”‚   β”‚       β”œβ”€β”€ stream/           # Streaming chat endpoint
β”‚   β”‚       β”œβ”€β”€ history/          # Chat history retrieval
β”‚   β”‚       └── session/          # Session management
β”‚   β”œβ”€β”€ dashboard/                # Dashboard pages
β”‚   β”œβ”€β”€ layout.tsx                # Root layout
β”‚   └── page.tsx                  # Landing page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Dashboard/
β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx         # Main chat interface
β”‚   β”‚   β”œβ”€β”€ DashboardNavbar.tsx   # Dashboard navigation
β”‚   β”‚   └── DashBoardSidebar.tsx  # Sidebar with sessions
β”‚   β”œβ”€β”€ section/                  # Landing page sections
β”‚   β”œβ”€β”€ ui/                       # Reusable UI components
β”‚   β”œβ”€β”€ CustomCursor.tsx          # Custom cursor component
β”‚   β”œβ”€β”€ GrainOverlay.tsx          # Visual grain effect
β”‚   β”œβ”€β”€ MagneticButton.tsx        # Interactive button
β”‚   └── ThemeSwitcher.tsx         # Theme toggle
β”œβ”€β”€ context/
β”‚   └── ChatContext.tsx           # Chat state management
β”œβ”€β”€ schemas/
β”‚   β”œβ”€β”€ ChatSession.ts            # MongoDB chat schema
β”‚   └── MongoDBClientConnection.ts # Database connection
β”œβ”€β”€ hooks/                        # Custom React hooks
β”œβ”€β”€ lib/                          # Utility functions
└── public/                       # Static assets

πŸ”‘ Key Features Explained

Source-Restricted Research

pageMind is designed to be a source-restricted research assistant. Unlike typical AI chatbots that can search the entire internet, pageMind:

  • Only reads URLs explicitly provided by users
  • Never hallucinates beyond provided sources
  • Cites specific URLs and sections in answers
  • Refuses to answer questions outside provided sources

Streaming Architecture

The chat system uses Server-Sent Events (SSE) for real-time streaming:

event: conversation    # Session ID
event: delta          # Incremental text chunks
event: metadata       # Token usage, duration, sources
event: done           # Completion signal

AI Response Structure

Assistant responses are parsed into three sections:

  • Thinking: AI's reasoning process (collapsible)
  • Answer: Main response content
  • Sources: Citations and references

πŸ“Š Usage Metrics

Each AI response tracks:

  • Input Tokens: Prompt + history token count
  • Output Tokens: Generated response tokens
  • Total Tokens: Combined usage
  • Duration: Response generation time
  • Source Count: Number of sources cited
  • API Key Type: Default or custom key usage

🎨 Customization

Theme Customization

Modify app/globals.css for theme variables:

:root {
  --background: ...;
  --foreground: ...;
  /* Add your custom colors */
}

Shader Effects

Customize WebGL effects in app/page.tsx:

<Swirl
  colorA="#1275d8"
  colorB="#e19136"
  speed={0.8}
  detail={0.8}
  // Adjust parameters
/>

πŸ§ͺ Development

Build for Production

bun run build
# or
npm run build

Lint Code

bun run lint
# or
npm run lint

Start Production Server

bun start
# or
npm start

πŸ”’ Security Notes

  • Never commit .env file
  • Rotate API keys regularly
  • Use environment variables for all secrets
  • Implement rate limiting for production
  • Monitor token usage to control costs

πŸ“ API Endpoints

POST /api/chat/stream

Stream AI responses

Body: {
  prompt: string;
  conversationId?: string;
  apiKey?: string;
}

GET /api/chat/history

Retrieve user's chat sessions

GET /api/chat/session/[sessionId]

Get specific session details

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a 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.

πŸ“€ Video

Screen.Recording.2025-11-02.at.16.18.08.1.mov

πŸ™ Acknowledgments

πŸ“§ Support

For support, please open an issue in the repository or contact the maintainers.


Made with ❀️ for OSDC Hack Night

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors