A Next.js + FastAPI platform for oilseed commodity forward contracts and hedging.
- JWT Authentication - Secure login for farmers and buyers
- Listings Management - Create and browse commodity listings with photos
- Contract Flow - Make offers, accept contracts, track status
- Notifications - Real-time updates on offers and contract changes
- Audit Logs - Complete transaction history
- Mobile-first UI - Responsive design with Tailwind CSS
- Frontend: Next.js 15, TypeScript, Tailwind CSS, React Query, React Hook Form
- Backend: FastAPI, SQLAlchemy, PostgreSQL, JWT auth
- Database: PostgreSQL with Docker Compose
- File Storage: Local file system with static serving
- Node.js 18+ and npm
- Python 3.9+ and pip
- Docker and Docker Compose
# Start PostgreSQL database
docker-compose up -dcd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file
cp .env.example .env
# Run database migrations and seed data
python seed_data.py
# Start FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Backend will be available at http://localhost:8000 API docs at http://localhost:8000/docs
cd frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will be available at http://localhost:3000
After running the seed script:
- Farmer:
[email protected]/password123 - Buyer:
[email protected]/password123
All seeded users use password: password123
POST /auth/signup- User registrationPOST /auth/login- User login
GET /listings- List all listings (with filters)POST /listings- Create new listing (farmers only)GET /listings/{id}- Get listing details
GET /contracts- List user's contractsPOST /contracts- Create offer (buyers only)POST /contracts/{id}/accept- Accept offer (sellers only)POST /contracts/{id}/confirm-delivery- Confirm deliveryPOST /contracts/{id}/raise-dispute- Raise dispute
GET /notifications- Get user notificationsPOST /notifications/mark-read- Mark notifications as read
- Signup/Login as farmer or buyer
- Farmer: Create listing with commodity details and photos
- Buyer: Browse listings and make offers
- Farmer: Accept offers to create contracts
- Track: Contract status and receive notifications
- Complete: Delivery confirmation and contract closure
backend/
├── app/
│ ├── core/ # Config and database
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ ├── routers/ # FastAPI routes
│ ├── services/ # Business logic
│ └── utils/ # Utilities (auth, file storage)
├── seed_data.py # Database seeding script
└── requirements.txt # Python dependencies
frontend/
├── src/
│ ├── app/ # Next.js app router pages
│ ├── lib/ # Utilities (API, auth, types)
│ └── components/ # Reusable UI components
├── package.json # Node dependencies
└── tailwind.config.js # Tailwind configuration
DATABASE_URL=postgresql://demo:demo123@localhost:5433/hedge_db
JWT_SECRET_KEY=your-secret-key
CORS_ORIGINS=http://localhost:3000
No additional environment variables required for development.
- Set production environment variables
- Build frontend:
npm run build - Use production WSGI server for backend
- Configure reverse proxy (nginx)
- Set up SSL certificates
- Use managed PostgreSQL database
MIT License - see LICENSE file for details.