This project is a RESTful API for a florist database management webpage developed using Node.js, Express, and MongoDB. The purpose of the project is to provide a backend service for managing and persisting florist inventories and sales with functionalities to create, retrieve, and delete the inventory. The frontend is built using React to ensure scalability, readability, and modularity of the frontend code. The notes are hosted and kept in a MongoDB database to ensure that the notes do not disappear after refreshing the page. Express.js and Node.js are used to frame the backend API and facilitate communication between the server and client.
The front end is created using Javascript (ES6), HTML, and CSS. React framework is used for its virtual DOM and performance optimization and its reusable components, which can enhance code reusability and codability. React also allows easy integration with other frontend and backend technologies to ensure the connection from the client to the server is stable.
MongoDB is used as the database to store the notes. Storing itmes in the backend is critical because it ensures that what the user entered will not be removed after refreshing or reopening the page. MongoDB is notable for its high speed and availability, its Atlas function which allows a simple and free setup and database connection, and its flexibility in terms of note structure. Compared to SQL, MongoDB allows for highly diverse and flexible data and allows building the webpage faster.
Express.js and Node.js are used for the backend development of this note-taking webpage. They are used to establish a server for MongoDB database connection and building API endpoints, which handle adding, retrieving, and deleting notes efficiently using RESTful API conventions and methodologies. The backend ensures that what user inputs and modifies gets transmitted to the database, and any changes in the database are accurately and promptly reflected back to the client. The backend serves as a crucial connection between the client and the server, ensuring their interactions and sent and reflected as expected.
The project structure is organized as follows:
/backend
: Contains the server-side code/models
: Defines the data models (e.g.,Note
model)/routes
: Handles different API routes for note operations
/public
: Contains the .html and .css file that outlines the frontend structure of the florist management system./src
: Contains .jsx files that outlines the webpage elements, including individual flower entries and an area to add new flowers to the florist management system.
The backend and frontend code are separated for best practices, and modifications in one shall in general not impact the other.
The Note
model represents a flower entity in the database with fields that document its title, description, price, and quantity.
The quantity item can be added or decreased by 1 by clicking the respective button. It serves to modify the quantity available for a specific flower.
POST /
: Creates a new flower itemGET /
: Retrieves all flower itemsDELETE /:id
: Deletes an item by IDPATCH /:id
: Modify the quantity of a flower entry by ID
- Creates a new entry
- Request Body:
{ "title": "Flower Title", "price": "FLower Price", "quantity": "Flower Quantity", "content": "Note Content" }
- Response (201 - Created):
{ "_id": "note_id", "title": "Flower Title", "price": "FLower Price", "quantity": "Flower Quantity", "content": "Note Content" }
- Retrieves all entries
- Response (200 - OK): Array of all entries
- Deletes an entry by ID
- Response (200 - OK): Deleted entry object
- Modifies a note by ID
- Response (200 - OK): Modified the quantity of the entry object
To run the project locally:
- Clone the repository from GitHub.
- Install dependencies using
npm install
. - Ensure that the command is currently in the backend folder by
cd backend/
if necessary. - Start the server with `` or
node server.js
. - On a separate shell command, run
npm start
. - The server will run on
http://localhost:3000
.
The project uses the following dependencies:
- Express: Web framework for Node.js
- Mongoose: MongoDB object modeling tool
- Body-parser: Parse incoming request bodies in a middleware
The dependencies are listed in the packages.json
file.
You can test the API endpoints using tools like Postman. The API endpoints documented above can all be tested:
- POST
- GET
- DELETE
Haolin Guo
This project is licensed under the MIT License - see the LICENSE.md file for details.