Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dynamodb_local_latest/
194 changes: 39 additions & 155 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,186 +1,70 @@
# Agrinet - Decentralized Agricultural Marketplace 🌱
# Getting Started with Create React App

## Overview
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

Agrinet is a decentralized agricultural trading and service platform built to enhance transparency, trust, and efficiency in agricultural markets. It connects producers, consumers, and service providers while ensuring secure transactions, reputation-based ratings, and localized economic sustainability.
## Available Scripts

## Features
In the project directory, you can run:

#### Marketplace System 🏪
### `npm start`

- Direct Market Access: Producers list goods, services, and contracts.
- Agrotourism Integration: Farmers can offer farm tours, events, and educational workshops.
- Service Marketplace: Users can provide or request agricultural services (e.g., logistics, maintenance).
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

#### Secure Transactions 🔒
The page will reload when you make changes.\
You may also see any lint errors in the console.

- LBTAS (Leveson-Based Trade Assessment Scale): Ensures a trust-based rating system.
- Dialog Recorder: Logs key transaction details for security and auditing.
- Machine Scrub Module: Filters and verifies transaction data.
### `npm test`

#### Key & Authentication System 🔑
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

- McEliese Key Generation: Ensures secure user identification.
- Key Transmission Limits: Auto-retirement after 3, 6, 9, 12, or 365 transmissions.
- Multi-Factor Verification: Email/phone validation with retry & lockout security.
### `npm run build`

#### PING System 📡
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

- Production Progress Reporting: Allows contract buyers to track order status.
- Real-Time Notifications: Updates on market trends, contract changes, and service requests.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

#### SMS Access 📱
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

- Query market and weather data through SMS using simple text commands.
- Supports local languages and queues messages offline with delivery confirmation.
### `npm run eject`

#### Financial Transactions 🏦
**Note: this is a one-way operation. Once you `eject`, you can't go back!**

- Deposit & Donations to NTARI Account: Supports decentralized funding.
- Automated Payouts: Ensures secure fund disbursements upon transaction completion.
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

#### Decentralized Data Management 🌍
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

- User Profiles & Logs: Maintains key issuance logs parallel to user profiles.
- Geo-Filtering & Search Optimization: Enables market visibility based on location.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

#### Square Foot Gardening Calculator 🌿
## Learn More

- Plant spacing recommendations for common crops.
- Compatibility matrix to plan companion planting.
- Growth projections and seasonal schedules with visual grid layouts.
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

## Technology Stack
To learn React, check out the [React documentation](https://reactjs.org/).

- Frontend: React with Next.js (responsive site structure)
- Backend: Node.js (API handling)
- Database: Amazon DynamoDB (for storing users, contracts, and transactions)
- Security: OAuth 2.0 / McEliese Key Cryptography
- Real-Time Processing: Webhooks & PING System

## Installation & Setup
### Code Splitting

1. Clone the repository
```
git clone https://github.com/YOUR_USERNAME/Fruitful.git
cd Agrinet
```
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

2. Setup the backend
```
cd backend
npm install
node server.js
```
### Analyzing the Bundle Size

3. Deploy the frontend
```
cd frontend
npm install
npm run dev
```
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

For local development, set the `NEXT_PUBLIC_BACKEND_URL` environment variable to your backend's URL before running the frontend, for example:
```
NEXT_PUBLIC_BACKEND_URL=http://localhost:5000 npm run dev
```
Only environment variables prefixed with `NEXT_PUBLIC_` are exposed to the browser, so this prefix is required.
Alternatively, configure a proxy so that requests to `/api` are forwarded to the backend.
### Making a Progressive Web App

### Environment Variables
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

The backend now uses Amazon DynamoDB. Set the following variables in your environment or `.env` file:
### Advanced Configuration

- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_REGION`
- `DYNAMODB_ENDPOINT` *(optional, for DynamoDB Local e.g. `http://localhost:8000`)*
- `TWILIO_SID`
- `TWILIO_AUTH_TOKEN`
- `TWILIO_FROM_NUMBER`
- `TWILIO_STATUS_CALLBACK_URL` *(optional for delivery confirmation)*
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

## Square Foot Gardening Usage
### Deployment

The backend includes a utility for planning square foot gardens.
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

```javascript
const { planSeason } = require('./backend/utils/squareFootGardening');

const layout = [
['tomato', 'basil'],
['lettuce', null],
];

const plan = planSeason(layout, '2024-03-01', 'spring');
console.log(plan.grid);
console.log(plan.schedule);
```

The planner validates companion planting, projects growth timelines, and renders an ASCII grid of the garden.

## API Endpoints

Additional chat interface endpoints (e.g., `/conversations`, `/messages/:id`, `/stream/:id`) and their expected JSON
structures are documented inline in the frontend components
[`Sidebar.jsx`](frontend/chat-ui/src/components/Sidebar.jsx) and
[`ChatWindow.jsx`](frontend/chat-ui/src/components/ChatWindow.jsx).
### User Registration
#### POST /userRegistration
```
{
"name": "John Doe",
"email": "johndoe@example.com",
"location": "Kentucky, USA",
"role": "producer"
}
```

### Create Contract
#### POST /createContract
```
{
"producerId": "user123",
"type": "Tomato",
"variety": "Roma",
"category": "food",
"amountNeeded": "500 lbs",
"dateNeeded": "2025-03-15",
"pingRate": "weekly"
}
```

### Submit LBTAS Rating
#### POST /submitRating
```
{
"transactionId": "tx987",
"rating": 4
}
```

## Contributing
We welcome contributions from the community! 🚀

1. Fork the repo
2. Create a feature branch
3. Submit a pull request

### Checking for hardcoded URLs

Run the following script to detect any hardcoded `localhost` references before committing code:

```bash
./scripts/list-hardcoded-urls.sh
```

The script lists offending lines and exits with a nonzero status if any are found.
Existing references known to be safe are tracked in `scripts/hardcoded-url-allowlist.txt`.

## License
MIT License – Feel free to modify and share. 📜

## Contact & Support
- NTARI https://www.ntari.org/
- Email - tech@ntari.org
- Slack - [Join our community for discussions!](https://ntari.slack.com)
### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
25 changes: 25 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,28 @@ node_modules/
.next/

chat-ui/dist/

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

6 changes: 3 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"test-connection": "node test-connection.js"
},
"dependencies": {
"next": "14.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
"next": "^14.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"eslint": "8.56.0",
Expand Down
17 changes: 17 additions & 0 deletions frontend/public/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import AgrotourismBookingDashboard from './AgrotourismBookingDashboard';

function App() {
return (
<Container maxWidth="md" sx={{ py: 4 }}>
<Typography variant="h3" align="center" gutterBottom>
Agrotourism Booking Platform
</Typography>
<AgrotourismBookingDashboard />
</Container>
);
}

export default App;
Binary file added frontend/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
42 changes: 42 additions & 0 deletions frontend/src/ActivitiesList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { useEffect, useState } from 'react';
import { Grid, Card, CardContent, CardActions, Button, Typography } from '@mui/material';

function ActivitiesList({ onSelect }) {
const [activities, setActivities] = useState([]);
const [loading, setLoading] = useState(true);

useEffect(() => {
fetch('/api/agrotourism/all')
.then(res => res.json())
.then(data => {
setActivities(data);
setLoading(false);
});
}, []);

//if (loading) return <Typography>Loading activities...</Typography>;

return (
<Grid container spacing={3}>
{activities.map(activity => (
<Grid item xs={12} sm={6} md={4} key={activity.id}>
<Card>
<CardContent>
<Typography variant="h5">{activity.title}</Typography>
<Typography>{activity.description}</Typography>
<Typography variant="body2"><strong>Location:</strong> {activity.location}</Typography>
<Typography variant="body2"><strong>Date:</strong> {activity.date}</Typography>
<Typography variant="body2"><strong>Capacity:</strong> {activity.maxGuests}</Typography>
<Typography variant="body2"><strong>Pricing:</strong> {activity.pricingTiers}</Typography>
</CardContent>
<CardActions>
<Button variant="contained" onClick={() => onSelect(activity)}>Book</Button>
</CardActions>
</Card>
</Grid>
))}
</Grid>
);
}

export default ActivitiesList;
Loading