Skip to content

ForliLabs/tavola-romagna

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

152 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ… Tavola Romagna

Local food marketplace connecting Romagna's artisan producers directly with consumers.

Farm-to-table e-commerce platform featuring subscription boxes, dynamic pricing, food rescue, agri-tourism, and a community hub — all built for the Forlì/Cesena area of Emilia-Romagna, Italy.

Next.js 16 TypeScript Prisma 7 Stripe Connect i18n


✨ Features at a Glance

Domain Capabilities
Marketplace Product catalog, producer profiles, full-text search, seasonal calendar, category filtering
Orders & Checkout Cart management, Stripe Checkout (Connect split payments), split orders per producer, order tracking, refunds
Subscriptions Weekly/monthly curated boxes, dietary profiling, box composition, A/B experiments, satisfaction tracking
Dynamic Pricing Rule engine (expiry markdown, bulk discount, surge, time-of-day, delivery slot), admin panel
Food Rescue Surplus listings, automatic expiry scanning, discounted near-expiry products
Gifts Gift box builder, unboxing experience with shareable tokens, occasion-based gifting
Events & Tourism Farm visit booking, agri-tourism itineraries, hospitality partnerships, ship-home service
Community Forum, recipe engine with basket builder, adoption programs (olive trees, vineyards), cooperative network
Recommendations Collaborative filtering ("also bought"), content-based similarity, personalized suggestions, trending, contextual (time/season)
Analytics Producer dashboards, customer cohorts, lifecycle analysis, revenue forecasting, category benchmarks, price alerts
Traceability Supply chain timeline, blockchain hash anchoring, certification verification, QR codes
Payments Stripe Connect (standard accounts), platform fees (15%), producer payouts, subscription billing
Auth & Security Session-based auth, OAuth (Google/Apple), MFA, CSRF, rate limiting, CORS, security headers, audit logging
GDPR Consent management, data export, account deletion, cookie consent banner
Notifications In-app, email (Resend), push (VAPID/Web Push), WhatsApp integration, notification digests
i18n Italian (default), English, German, French β€” with accept-language detection
Infrastructure Vercel deploy, Vercel Blob storage, Upstash Redis, Sentry observability, cron jobs, health checks

78 Prisma models Β· 70+ features Β· 75+ unit tests Β· 10 E2E test suites


πŸ—οΈ Tech Stack

Layer Technology
Framework Next.js 16 (App Router, React 19, Turbopack)
Language TypeScript 5
Database SQLite (dev) / Turso libSQL (prod) via Prisma 7
Payments Stripe Connect (real SDK with mock fallback)
Email Resend (transactional)
Storage Vercel Blob / Cloudinary
Cache Upstash Redis (rate limiting, sessions)
AI OpenAI GPT-4o-mini (recipe generation, menu planning)
CSS Tailwind CSS 4
Testing Vitest (unit) + Playwright (E2E)
Observability Sentry, structured JSON logging
Deployment Vercel (Frankfurt fra1 region)

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 18
  • npm β‰₯ 9

Installation

# Clone and install
git clone <repo-url>
cd tavola-romagna
npm install

# Set up environment
cp .env.example .env
# Edit .env with your keys (mock values work for local dev)

# Initialize database
npx prisma generate
npx prisma db push

# Seed sample data (optional)
curl -X POST http://localhost:3000/api/seed

# Start development server
npm run dev

Open http://localhost:3000.

Environment Variables

See .env.example for the full list. Key groups:

Variable Required Purpose
DATABASE_URL βœ… SQLite file path (dev) or Turso/PostgreSQL URL (prod)
STRIPE_SECRET_KEY Mock OK Stripe Connect payments (falls back to mock)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY Mock OK Stripe client-side
STRIPE_WEBHOOK_SECRET Mock OK Stripe webhook verification
RESEND_API_KEY Mock OK Transactional email
BLOB_READ_WRITE_TOKEN Optional Vercel Blob storage
OPENAI_API_KEY Optional AI recipe/menu generation
UPSTASH_REDIS_URL Optional Redis-backed rate limiting
SENTRY_DSN Optional Error tracking
VAPID_PUBLIC_KEY / VAPID_PRIVATE_KEY Optional Push notifications

πŸ’‘ Mock mode: The app runs fully offline with mock values. Stripe, email, and storage gracefully degrade to local stubs.


πŸ“ Project Structure

tavola-romagna/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma          # 78 models across 10+ domains
β”‚   β”œβ”€β”€ seed.ts                # Database seeding
β”‚   └── migrations/            # Prisma migrations
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                   # Next.js App Router pages & API routes
β”‚   β”‚   β”œβ”€β”€ api/               # ~60 REST API endpoints
β”‚   β”‚   β”œβ”€β”€ admin/             # Admin operations center
β”‚   β”‚   β”œβ”€β”€ auth/              # Login, register
β”‚   β”‚   β”œβ”€β”€ dashboard/         # Consumer & producer dashboards
β”‚   β”‚   β”œβ”€β”€ products/          # Product catalog
β”‚   β”‚   β”œβ”€β”€ producers/         # Producer profiles
β”‚   β”‚   β”œβ”€β”€ checkout/          # Checkout flow
β”‚   β”‚   β”œβ”€β”€ subscriptions/     # Subscription box management
β”‚   β”‚   β”œβ”€β”€ gifts/             # Gift boxes & unboxing
β”‚   β”‚   β”œβ”€β”€ events/            # Event booking
β”‚   β”‚   β”œβ”€β”€ community/         # Forum & adoptions
β”‚   β”‚   β”œβ”€β”€ recipes/           # Recipes & basket builder
β”‚   β”‚   β”œβ”€β”€ tourism/           # Agri-tourism & ship-home
β”‚   β”‚   β”œβ”€β”€ surplus/           # Food rescue
β”‚   β”‚   β”œβ”€β”€ moonshots/         # Innovation portfolio
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ components/            # 30+ React components
β”‚   β”œβ”€β”€ lib/                   # Core business logic (~40 modules)
β”‚   β”‚   β”œβ”€β”€ auth.ts            # Session-based authentication
β”‚   β”‚   β”œβ”€β”€ stripe.ts          # Stripe Connect integration
β”‚   β”‚   β”œβ”€β”€ prisma.ts          # Database client
β”‚   β”‚   β”œβ”€β”€ pricing-engine.ts  # Dynamic pricing rule engine
β”‚   β”‚   β”œβ”€β”€ recommendations.ts # ML-lite recommendation engine
β”‚   β”‚   β”œβ”€β”€ i18n.ts            # Internationalization (4 locales)
β”‚   β”‚   β”œβ”€β”€ validation.ts      # Input validation
β”‚   β”‚   β”œβ”€β”€ security.ts        # Security headers, CSRF, CORS
β”‚   β”‚   β”œβ”€β”€ rate-limit.ts      # Redis/in-memory rate limiter
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ generated/             # Prisma generated client
β”‚   └── types/                 # TypeScript type declarations
β”œβ”€β”€ e2e/                       # 10 Playwright E2E test suites
β”œβ”€β”€ vercel.json                # Vercel deployment config + cron jobs
β”œβ”€β”€ playwright.config.ts       # Playwright configuration
└── vitest.config.ts           # Vitest configuration

πŸ§ͺ Testing

# Unit tests (Vitest)
npm test                 # Watch mode
npx vitest run           # Single run

# E2E tests (Playwright)
npm run test:e2e         # Headless
npm run test:e2e:ui      # Interactive UI

# All tests
npm run test:all

Test Coverage

Suite Tests Scope
validation.test.ts Email, password, string, number validation Input sanitization
i18n.test.ts Locale detection, fallback, translation Internationalization
stripe.test.ts / stripe-fees.test.ts Stripe integration, fee calculations Payments
pricing-engine.test.ts Dynamic pricing rules, markdown, bulk Pricing
auth.test.ts Password hashing, sessions Authentication
recommendations.test.ts Recommendation algorithms ML
security.test.ts Headers, CSRF, sanitization Security
recipe-engine.test.ts Recipe generation Content
analytics.test.ts Analytics computations BI
email.test.ts Email templates Communications
E2E (10 suites) Browse→cart→checkout, auth, producer onboarding, recipes, gifts, search, events, admin, GDPR, API contracts Full flows

🚒 Deployment

Vercel (Recommended)

The project is pre-configured for Vercel with vercel.json:

  • Region: fra1 (Frankfurt β€” closest to Italy)
  • Build: npx prisma generate && next build
  • Cron jobs: Analytics (daily 2am), pricing scan (every 6h), surplus scan (daily 8am), notification digest (weekly Monday 9am)
  • Security headers: CSP, HSTS, X-Frame-Options, etc.
vercel deploy

Set production environment variables in the Vercel dashboard (see vercel.json env section for required secrets).


πŸ“š Documentation


🌍 Internationalization

Default locale is Italian (it). Supported: it, en, de, fr.

Locale is detected from the Accept-Language header and can be switched via the language switcher component. Message dictionaries live in src/lib/messages/.


πŸ“„ License

Source code is publicly available. No open-source license has been selected yet.

About

Local food marketplace connecting Romagna producers, restaurants, and consumers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages