A digital marketplace platform connecting small organic farms in Tunisia to urban consumers through subscription boxes and weekly deliveries.
FarmBox enables local farmers to sell directly to consumers, cutting out middlemen and ensuring fresher produce at fair prices for both parties.
For Farmers:
- Digital storefront with farm profiles
- Product management with seasonal availability
- Order management and tracking
- Delivery zone configuration
For Consumers:
- Browse local farms and their offerings
- Add products to cart and checkout
- Track orders and delivery status
- Choose pickup or delivery options
- Frontend: Next.js 14, React, Tailwind CSS, Zustand
- Backend: Node.js, Express, TypeScript
- Database: PostgreSQL with Prisma ORM
- Authentication: JWT tokens
farmbox/
├── backend/ # Express API
│ ├── prisma/ # Database schema and migrations
│ ├── src/
│ │ ├── config/ # Database and service configs
│ │ ├── controllers/ # Route handlers
│ │ ├── middleware/ # Auth and validation
│ │ ├── routes/ # API routes
│ │ ├── services/ # Business logic
│ │ └── utils/ # Helper functions
│ └── package.json
├── frontend/ # Next.js app
│ ├── src/
│ │ ├── app/ # Pages (App Router)
│ │ ├── components/ # React components
│ │ ├── lib/ # API client, utilities
│ │ ├── store/ # Zustand stores
│ │ └── types/ # TypeScript types
│ └── package.json
├── docker-compose.yml # Docker development setup
├── DESIGN.md # Design document
└── IMPLEMENTATION_GUIDE.md # Implementation guide
- Node.js 18+
- PostgreSQL 14+ (or Docker)
- npm or yarn
# Start all services
docker-compose up -d
# The app will be available at:
# - Frontend: http://localhost:3000
# - Backend API: http://localhost:3001
# - Database: localhost:5432# Create PostgreSQL database
createdb farmbox
# Or use Docker for just the database
docker run --name farmbox-db -e POSTGRES_USER=farmbox -e POSTGRES_PASSWORD=farmbox123 -e POSTGRES_DB=farmbox -p 5432:5432 -d postgres:14-alpinecd backend
# Install dependencies
npm install
# Configure environment
cp ../.env.example .env
# Edit .env with your database credentials
# Run migrations
npx prisma migrate dev
# Seed the database
npm run db:seed
# Start development server
npm run devcd frontend
# Install dependencies
npm install
# Start development server
npm run devPOST /api/auth/register- Register new userPOST /api/auth/login- LoginGET /api/auth/profile- Get current user profilePUT /api/auth/profile- Update profile
GET /api/farms- List all farmsGET /api/farms/:slug- Get farm by slugPOST /api/farms- Create farm (auth required)PUT /api/farms/:id- Update farm (farmer only)GET /api/farms/me/farm- Get current user's farm
GET /api/products- List productsGET /api/products/:id- Get productPOST /api/products- Create product (farmer only)PUT /api/products/:id- Update product (farmer only)DELETE /api/products/:id- Delete product (farmer only)
POST /api/orders- Create order (auth required)GET /api/orders/my-orders- Get user's ordersGET /api/orders/:id- Get order detailsGET /api/orders/farm/orders- Get farm's orders (farmer only)PATCH /api/orders/:id/status- Update order status (farmer only)
After seeding the database:
| Role | Password | |
|---|---|---|
| Admin | admin@farmbox.tn | admin123 |
| Farmer | ahmed@fermebensalem.tn | farmer123 |
| Customer | sonia@example.tn | customer123 |
| Zone | Cities | Fee | Free Threshold |
|---|---|---|---|
| Zone A | Tunis, La Marsa, Carthage, Sidi Bou Said | 5 TND | 80 TND |
| Zone B | Ariana, Ben Arous, Manouba | 8 TND | 120 TND |
| Zone C | Outer suburbs | 12 TND | 150 TND |
NODE_ENV=development
PORT=3001
DATABASE_URL="postgresql://user:password@localhost:5432/farmbox"
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=7d
FRONTEND_URL=http://localhost:3000NEXT_PUBLIC_API_URL=http://localhost:3001/api# Backend
cd backend && npm test
# Frontend
cd frontend && npm testcd backend
# Open Prisma Studio
npm run db:studio
# Create migration
npx prisma migrate dev --name migration_name
# Reset database
npx prisma migrate reset# Build
npm run build
# Start
npm start# Deploy
vercel --prod- Design Document - Business requirements and architecture
- Implementation Guide - Step-by-step development guide
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE file for details
Built with love for Tunisian farmers and consumers.