Skip to content

jah09/Farm2Table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Farm2Table MVP

A modern farm-to-table marketplace connecting local producers with consumers, featuring AI-powered recommendations and intelligent conversation management.

Features

  • 🌱 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

Tech Stack

  • 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

Getting Started

Prerequisites

  • Node.js 18+
  • MongoDB database (local or MongoDB Atlas)
  • OpenAI API key

Installation

  1. Clone the repository ```bash git clone cd farm2table-mvp ```

  2. Install dependencies ```bash npm install ```

  3. Set up environment variables ```bash cp .env.example .env ```

Fill in your environment variables:

  • DATABASE_URL: Your MongoDB connection string
  • JWT_SECRET: A secure random string for JWT signing
  • OPENAI_API_KEY: Your OpenAI API key
  1. Set up the database ```bash

Generate Prisma client

npm run db:generate

Push schema to database

npm run db:push

Seed with sample data

npm run db:seed

Seed knowledge base

npm run db:seed-knowledge ```

  1. Start the development server ```bash npm run dev ```

Visit http://localhost:3000 to see the application.

Sample Accounts

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

Database Schema

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

AI Features

Conversation Management

  • 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

Knowledge Base

  • 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

Enhanced Recommendations

  • 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

API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login

Produce

  • GET /api/produce - Get all active produce
  • POST /api/produce - Create new produce (producers only)

AI Assistant

  • POST /api/ai/recommend - Get AI recommendations with context
  • GET /api/conversations - Get conversation history
  • GET /api/knowledge - Search knowledge base
  • POST /api/knowledge - Create knowledge entry

Development

Database Management

```bash

View database in Prisma Studio

npm run db:studio

Reset database and reseed

npm run db:push --force-reset npm run db:seed npm run db:seed-knowledge ```

Project Structure

``` β”œβ”€β”€ 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 ```

AI Conversation Features

For Consumers

  • 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

For Producers

  • 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

Deployment

  1. Set up a MongoDB database (MongoDB Atlas recommended)
  2. Deploy to Vercel or your preferred platform
  3. Set environment variables in your deployment platform
  4. Run database migrations: npm run db:push
  5. Seed with sample data: npm run db:seed && npm run db:seed-knowledge

Contributing

  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 licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages