Skip to content

dipankaratriya-cloud/Study_preferences

Repository files navigation

StudyAbroadAI πŸŽ“

AI-powered guidance platform for Indian students pursuing global education. Built with Next.js 14, Supabase, and Groq AI.

πŸš€ Features

  • AI Chatbot: Conversational assistant powered by Groq API (Moonshot/Kimi K2)
  • Smart Profile Detection: Automatically extracts student information from conversations
  • University Recommendations: Personalized suggestions based on profile
  • Country Comparisons: Side-by-side analysis with interactive charts
  • Streaming Responses: Real-time AI responses via Server-Sent Events
  • Authentication: Email/password and Google OAuth via Supabase
  • Hybrid Caching: Intelligent data caching with staleness management
  • PDF Reports: Generate custom study abroad reports on-demand
  • Multiple Chat Sessions: Manage parallel conversations with history

πŸ“‹ Prerequisites

Before you begin, ensure you have:

πŸ› οΈ Installation

1. Install Dependencies

npm install

2. Set Up Environment Variables

Create a .env.local file in the root directory:

cp .env.example .env.local

Edit .env.local with your credentials:

# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

# Groq API
GROQ_API_KEY=your_groq_api_key

# Site Configuration
NEXT_PUBLIC_SITE_URL=http://localhost:3000

3. Set Up Supabase Database

  1. Go to your Supabase project dashboard
  2. Navigate to the SQL Editor
  3. Run the database schema from database/schema.sql

The schema includes:

  • chat_sessions - Store conversation history
  • universities_cache - Cache university data
  • countries_cache - Cache country information
  • saved_comparisons - Save comparison charts

4. Enable Authentication

In your Supabase dashboard:

  1. Go to Authentication β†’ Providers
  2. Enable Email provider
  3. Enable Google provider:
    • Add your Google OAuth credentials
    • Set redirect URL: http://localhost:3000/auth/callback

5. Get Groq API Key

  1. Visit console.groq.com
  2. Create an account or sign in
  3. Generate an API key
  4. Add it to your .env.local file

6. Run Development Server

npm run dev

Open http://localhost:3000 in your browser.

πŸ“ Project Structure

study-abroad-ai/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ (auth)/                   # Authentication pages
β”‚   β”‚   β”œβ”€β”€ login/
β”‚   β”‚   β”œβ”€β”€ signup/
β”‚   β”‚   └── forgot-password/
β”‚   β”œβ”€β”€ (dashboard)/              # Protected dashboard routes
β”‚   β”‚   β”œβ”€β”€ chats/
β”‚   β”‚   β”œβ”€β”€ comparisons/
β”‚   β”‚   └── profile/
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”œβ”€β”€ chat/
β”‚   β”‚   └── groq/
β”‚   β”œβ”€β”€ about/
β”‚   └── page.tsx                  # Landing page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/                       # Shadcn/ui components
β”‚   β”œβ”€β”€ chat/                     # Chat interface components
β”‚   └── layout/                   # Layout components
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ supabase/                 # Supabase clients
β”‚   β”œβ”€β”€ groq/                     # Groq API integration
β”‚   └── utils.ts                  # Utility functions
β”œβ”€β”€ types/                        # TypeScript type definitions
└── public/                       # Static assets

🎯 Key Implementation Details

Chat System

The chat system uses streaming responses for a real-time experience:

// Stream AI responses via SSE
const stream = await streamChatCompletion(messages, ADVISOR_SYSTEM_PROMPT)

// Messages are saved to Supabase with full history
await supabase
  .from('chat_sessions')
  .update({ messages: [...messages, { role: 'assistant', content: response }] })

Caching Strategy

Data is cached intelligently to balance freshness and performance:

  • Universities: 30 days
  • Countries: 7 days
  • Job Market: 14 days
  • Deadlines: 1 day

Stale data is returned immediately while refreshing in the background.

Profile Extraction

Student profiles are automatically extracted from conversations:

const profileData = await extractProfile(messages)
// Returns: education level, field, budget, preferences, etc.

πŸš€ Deployment

Deploy to Vercel

  1. Push your code to GitHub
  2. Connect your repository to Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!
npm run build

Production Checklist

  • Add your production domain to Supabase authentication settings
  • Update NEXT_PUBLIC_SITE_URL in environment variables
  • Configure Google OAuth redirect URLs for production
  • Set up Supabase Row Level Security (RLS) policies
  • Review and optimize API rate limits

πŸ“Š Database Schema

See database/schema.sql for the complete database schema including:

  • Chat sessions with JSONB message arrays
  • University and country data caches
  • Saved comparisons
  • Indexes for performance

🀝 Contributing

This is a project built for a French client. If you want to extend it:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“ License

This project is proprietary and confidential.

πŸ› Troubleshooting

"Module not found" errors

rm -rf node_modules
rm package-lock.json
npm install

Supabase connection issues

  • Verify your environment variables are correct
  • Check that your Supabase project is active
  • Ensure RLS policies allow your operations

Groq API errors

  • Verify your API key is valid
  • Check API rate limits
  • Ensure you're using a supported model name

πŸ“ž Support

For issues or questions:

  • Check the documentation
  • Review existing issues on GitHub
  • Contact the development team

πŸŽ‰ Next Steps

After setup, you can:

  1. Customize the landing page in app/page.tsx
  2. Seed university data using public/data/universities-seed.json
  3. Configure AI prompts in lib/groq/prompts.ts
  4. Add more Shadcn components as needed
  5. Implement remaining features:
    • Dashboard pages (in progress)
    • Chat interface with streaming (in progress)
    • Comparison charts (in progress)
    • Profile management (in progress)
    • PDF report generation (to be implemented)

Built with ❀️ for Indian students pursuing global education

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published