This is a full-stack web application for an online farming magazine. It includes a frontend built with React and a backend built with Node.js, Express.js, and MongoDB.
- React
- HTML
- CSS
- JavaScript
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT for authentication
- Bcrypt for password hashing
The project is divided into two main parts:
farming-magazine-frontend
: Contains the React frontend application.- Backend: The root directory contains the backend application, including:
controllers
: Request handlers for different routes.middleware
: Custom middleware for authentication, error handling, etc.models
: Mongoose schemas for database models.routes
: Express routes for different API endpoints.services
: Business logic for various features.utils
: Utility functions.config
: Configuration files (e.g., database connection).
- Node.js and npm installed
- MongoDB installed and running
- Clone the repository.
- Navigate to the root directory of the project.
- Install dependencies:
npm install
- Create a
.env
file in the root directory and add the following environment variables:PORT=5000 MONGODB_URI=mongodb://localhost:27017/farming_magazine JWT_SECRET=your_jwt_secret
- Start the backend server:
Or, to run in development mode with nodemon:
npm start
npm run dev
- Navigate to the
farming-magazine-frontend
directory:cd farming-magazine-frontend
- Install dependencies:
npm install
- Start the frontend development server:
The frontend will be accessible at
npm start
http://localhost:3000
.
The following scripts are available in the package.json
file in the root directory:
npm start
: Starts the backend server.npm run dev
: Starts the backend server in development mode with nodemon.npm run lint
: Lints the backend code using ESLint.npm test
: Runs backend tests using Jest.npm run test:watch
: Runs backend tests in watch mode.npm run test:coverage
: Generates a backend test coverage report.npm run frontend:test
: Runs frontend tests.npm run frontend:build
: Builds the frontend application for production.npm run frontend:install
: Installs frontend dependencies.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Submit a pull request.