MERN_bookstore is a full-stack web application for managing a book inventory, developed as a project from freeCodeCamp. It demonstrates the implementation of CRUD operations using the MERN (MongoDB, Express, React, Node.js) stack, providing a practical example of building a complete web application using these technologies.
The project is divided into two main parts:
- Frontend (React application)
- Backend (Node.js/Express API)
The React frontend is structured around the following components:
App.jsx
: Sets up routing using React RouterHome.jsx
: Main page of the applicationCreateBooks.jsx
: Handles creation of new booksShowBook.jsx
: Displays details of a specific bookEditBook.jsx
: Allows editing of book informationDeleteBook.jsx
: Handles book deletion
The backend provides RESTful API endpoints for:
- Retrieving all books
- Getting a single book by ID
- Creating a new book
- Updating a book
- Deleting a book
This project leverages the MERN stack:
- MongoDB: NoSQL database for storing book information
- Express: Web application framework for Node.js
- React: JavaScript library for building user interfaces
- Node.js: JavaScript runtime for server-side code
Additional tools and libraries:
- React Router: For handling frontend routing
- Axios: For making HTTP requests from the frontend to the backend
- Mongoose: ODM library for MongoDB and Node.js
- dotenv: For managing environment variables
- cors: For handling Cross-Origin Resource Sharing
- Navigate to the frontend directory
- Install dependencies:
npm install
- Start the development server:
npm start
- Navigate to the backend directory
- Install dependencies:
npm install
- Set up your MongoDB connection string in a
.env
file - Start the server:
npm start
Ensure MongoDB is installed and running on your system.
- GET /api/books: Retrieve all books
- GET /api/books/:id: Retrieve a specific book
- POST /api/books: Create a new book
- PUT /api/books/:id: Update a book
- DELETE /api/books/:id: Delete a book
Refer to the API documentation for more details on request/response formats.
Contributions to improve MERN_bookstore are welcome. Please follow the standard fork-and-pull request workflow.