Skip to content

richasriva/Farmers-E-comm

Repository files navigation

Farmers E-commerce is a project made for farmers to sell their surplus. This will help them to sell their excess products. The "Backend" folder contains the following structure:

app.js: This is likely the main application entry point.

server.js: Likely handles server setup and configurations.

config/: Configuration files (e.g., database, environment variables).

controllers/: Business logic for handling requests and responses.

middleware/: Custom middleware for request processing (e.g., authentication).

models/: Database schemas and models.

routes/: Route definitions for API endpoints.

utils/: Utility functions or helper modules.

Farmers E-Commerce Backend The backend for the Farmers E-Commerce platform is built to connect farmers with customers, enabling the sale of surplus products efficiently. This backend handles API requests, data storage, user authentication, and business logic for seamless operations.

Table of Contents Features Tech Stack Project Structure Installation Usage API Endpoints

Features

User Authentication: Secure login and registration for farmers and customers. Product Management: Add, update, and delete surplus products. Order Handling: Manage orders placed by customers. Real-Time Updates: Synchronization of data across the platform. Middleware: Custom middleware for security and validation. Tech Stack Node.js: Backend runtime environment. Express.js: Web framework for building APIs. MongoDB: Database for storing user and product data. Mongoose: ODM for MongoDB.

Project Structure

Backend/ ├── app.js # Entry point of the application

├── server.js # Server setup and configuration

├── config/ # Configuration files (e.g., database, environment variables)

├── controllers/ # Handles business logic

├── middleware/ # Custom middleware (e.g., authentication)

├── models/ # Database schemas and models

├── routes/ # API routes

└── utils/ # Utility functions and helpers

Installation Clone the repository:

bash Copy code git clone https://github.com/richasriva/Farmers-E-comm.git cd Farmers-E-comm/Backend Install dependencies:

npm install

Set up environment variables: Create a .env file in the root directory with the following variables:

env PORT=5000 MONGO_URI=<your_mongo_db_connection_string>

JWT_SECRET=<your_jwt_secret>

Start the server:

npm start Usage

Access the APIs via http://localhost:5000 (or the port you configured). Use tools like Postman to test the endpoints.

API Endpoints Here is a brief overview of the available endpoints:

Authentication:

POST /api/auth/register - Register a new user.

POST /api/auth/login - Login for farmers and customers.

Products:

GET /API/products - Get all products.

POST /API/products - Add a new product (requires authentication).

PUT /api/products/:id - Update product details.

DELETE /api/products/:id - Remove a product.

Orders:

POST /api/orders - Place an order.

GET /api/orders/:userId - Get orders for a user.

Contributing

Contributions are welcome! Please follow these steps:

Fork the repository. Create a feature branch:

git checkout -b feature-name Commit changes:

git commit -m "Add feature-name" Push to the branch:

git push origin feature-name Open a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •