jasper-th-wang / mongo-unicorns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


MONGO UNICORNS

β—¦ Developed with the software and tools below.

JavaScript NodeJS Tailwind Express HTML5 JSON

GitHub license git-last-commit GitHub commit activity GitHub top language

πŸ“– Table of Contents


πŸ“ Overview

The Unicorn Data Service provides a web-based interface for users to query, filter, and sort information about unicorns. (Unicorns data provided from The Little MongoDB Book.)

Utilizing a combination of a frontend UI built with Tailwind and a backend server, it allows interaction with a MongoDB database storing unicorn data.

Features include a dynamic table for displaying results, multiple filter options, and sortable fields. Tailored for ease of use and customization, it's designed to deliver specific data on unicorns based on user preferences, with support for cross-origin requests. It's a user-friendly tool for accessing and visualizing unicorn information.


🎈 Demo

Here is the link to the live demo of this app deployed on Heroku:

https://mongo-unicorns-7e6fc0ffcea8.herokuapp.com/


πŸ“‚ Repository Structure

└── mongo-unicorns/
    β”œβ”€β”€ frontend/
    β”‚   β”œβ”€β”€ index.html
    β”‚   └── script.js
    β”œβ”€β”€ package.json
    └── server.js

βš™οΈ Modules

Root
File Summary
server.js The server.js script sets up an Express.js web server with a connected MongoDB database, using Mongoose to define and interact with unicorns data. It serves static files from the frontend directory and offers a RESTful API endpoint /unicorns to query and return unicorn data based on provided search parameters and sorting options. The server handles cross-origin requests, listens on a configurable port, and provides unicorns' validation through defined schema constraints.
package.json The package.json file defines a node.js project named assignment3 with version 1.0.0, which serves as an API for a Unicorn service using Express and MongoDB. It is set up to start with server.js and lacks test specifications. The project uses packages cors for Cross-Origin Resource Sharing, dotenv for environment variable management, express as the web framework, and mongoose to interact with MongoDB. The required Node engine version is specified as 21.x. The project's main file is incorrectly listed as playground-1.mongodb.js.
Frontend
File Summary
index.html The HTML document is a user interface for querying and displaying data about unicorns, presumably from a MongoDB database given the directory name. It features a TailwindCSS-styled form enabling users to filter unicorns by name, date of birth, likes, weight, gender, vampire encounters, and vaccination status. Users can specify sorting preferences. Form submission triggers a JS function (referenced script.js). Results are displayed in a table where users can choose column visibility via checkboxes. Invalid input formats elicit error messages.
script.js The code defines the functionality for an interactive web-based table that displays and filters data on unicorns. It retrieves unicorn data from a server according to user-specified filters, validates and sanitizes the sort input, and dynamically alters the visibility of table columns based on checkboxes. The table is refreshed with relevant data upon user request via a button click, and checkboxes control which columns are visible, allowing customizability of the displayed information.

πŸš€ Getting Started

Dependencies

Please ensure you have the following dependencies installed on your system:

- ℹ️ mongoose

- ℹ️ Express

- ℹ️ Nodemon

πŸ”§ Installation

  1. Clone the mongo-unicorns repository:
git clone https://github.com/jasper-th-wang/mongo-unicorns
  1. Change to the project directory:
cd mongo-unicorns
  1. Install the dependencies:
npm install

πŸ€– Running mongo-unicorns

nodemon server.js

About


Languages

Language:HTML 62.6%Language:JavaScript 37.4%