A modern farm-to-table marketplace connecting local producers with consumers, featuring AI-powered recommendations and intelligent conversation management.
- 🌱 Producer dashboard for managing produce listings
- 🛒 Consumer marketplace with AI-powered recommendations
- 🤖 OpenAI integration for intelligent produce suggestions
- 💬 AI conversation storage and analytics
- 📚 Knowledge base management with embeddings
- 🔍 Semantic search with vector embeddings
- 📱 Mobile-friendly responsive design
- 🔐 Secure authentication with JWT
- 💾 MongoDB database with Prisma ORM
- Frontend: Next.js 14, React, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Prisma ORM
- Database: MongoDB
- Authentication: JWT with bcrypt
- AI: OpenAI GPT-3.5-turbo, text-embedding-3-small
- UI Components: shadcn/ui, Radix UI
- Node.js 18+
- MongoDB database (local or MongoDB Atlas)
- OpenAI API key
-
Clone the repository ```bash git clone cd farm2table-mvp ```
-
Install dependencies ```bash npm install ```
-
Set up environment variables ```bash cp .env.example .env ```
Fill in your environment variables:
DATABASE_URL: Your MongoDB connection stringJWT_SECRET: A secure random string for JWT signingOPENAI_API_KEY: Your OpenAI API key
- Set up the database ```bash
npm run db:generate
npm run db:push
npm run db:seed
npm run db:seed-knowledge ```
- Start the development server ```bash npm run dev ```
Visit http://localhost:3000 to see the application.
After seeding, you can use these accounts:
Producers:
- Email:
juan@farm.com/ Password:password123 - Email:
maria@farm.com/ Password:password123
Consumer:
- Email:
customer@example.com/ Password:password123
The application uses the following main models:
- User: Stores user accounts (producers and consumers)
- Produce: Product listings from producers with AI-generated descriptions and embeddings
- Order: Customer orders
- OrderItem: Individual items within orders
- AIConversation: Enhanced conversation logs with context and metadata
- KnowledgeBase: Structured knowledge entries with embeddings for AI responses
- Session-based conversations: Track user interactions across sessions
- Context awareness: AI considers user preferences, location, and conversation history
- Metadata tracking: Store response times, recommended categories, and user interactions
- Analytics: View conversation insights, popular questions, and user engagement
- Semantic search: Find relevant knowledge using vector embeddings
- Category organization: Organize knowledge by farming, nutrition, recipes, storage, etc.
- Tag system: Flexible tagging for better categorization
- Producer management: Producers can add and manage knowledge entries
- Semantic similarity: Find produce using natural language queries
- Context-aware suggestions: Consider user location, season, and preferences
- Knowledge integration: AI responses include relevant farming and nutrition information
- Real-time learning: System improves recommendations based on conversation patterns
POST /api/auth/register- User registrationPOST /api/auth/login- User login
GET /api/produce- Get all active producePOST /api/produce- Create new produce (producers only)
POST /api/ai/recommend- Get AI recommendations with contextGET /api/conversations- Get conversation historyGET /api/knowledge- Search knowledge basePOST /api/knowledge- Create knowledge entry
```bash
npm run db:studio
npm run db:push --force-reset npm run db:seed npm run db:seed-knowledge ```
``` ├── app/ # Next.js app directory │ ├── api/ # API routes │ │ ├── ai/ # AI recommendation endpoints │ │ ├── conversations/ # Conversation history │ │ └── knowledge/ # Knowledge base management │ ├── consumer/ # Consumer pages │ ├── producer/ # Producer pages │ └── globals.css # Global styles ├── components/ # React components │ ├── auth/ # Authentication components │ ├── consumer/ # Consumer-specific components │ ├── producer/ # Producer-specific components │ │ ├── knowledge-base-manager.tsx # Knowledge base management │ │ └── conversation-analytics.tsx # Conversation insights │ ├── shared/ # Shared components │ └── ui/ # UI components (shadcn) ├── lib/ # Utility libraries │ ├── auth.ts # Authentication utilities │ ├── openai.ts # OpenAI integration with conversation management │ ├── embeddings.ts # Vector embedding utilities │ └── prisma.ts # Prisma client ├── prisma/ # Database schema and migrations │ ├── seed.ts # Sample produce data │ └── seed-knowledge.ts # Knowledge base seeding └── public/ # Static assets ```
- Natural language queries: Ask questions like "What's good for juicing?"
- Contextual responses: AI remembers your preferences and previous questions
- Semantic search: Find produce using natural descriptions
- Personalized recommendations: Based on location, season, and dietary preferences
- Knowledge management: Add farming tips, nutrition info, and recipes
- Conversation analytics: See what customers are asking about
- Market insights: Understand customer preferences and trends
- AI-enhanced listings: Automatically generate rich product descriptions
- Set up a MongoDB database (MongoDB Atlas recommended)
- Deploy to Vercel or your preferred platform
- Set environment variables in your deployment platform
- Run database migrations:
npm run db:push - Seed with sample data:
npm run db:seed && npm run db:seed-knowledge
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.