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.