We'll build a simple 3-tier application that manages a library of books. The application will allow users to add, view, and search for books. The three tiers are:
1. **Presentation Tier** (Front End): HTML forms served by Express for user interaction.
2. **Logic Tier** (Server): Node.js with Express handling HTTP requests.
3. **Data Tier** (Database): MongoDB storing book data.
### Workflow Instructions
1. **Set Up MongoDB**
2. **Set Up Node.js and Express**
3. **Create Mongoose Models**
4. **Create Routes and Controllers**
5. **Create Front End Forms**
6. **Run the Application**
### Step-by-Step Guide
#### Step 1: Set Up MongoDB
Ensure you have MongoDB installed and running. If using MongoDB Atlas, create a cluster and get the connection string.
#### Step 2: Set Up Node.js and Express
1. **Create Project Directory**
```bash
mkdir libraryApp
cd libraryApp
```
2. **Start the Application**:
```bash
node app.js
```
3. **Open Browser**:
- Go to `http://localhost:3000/`
- You should see the home page of the Library App.
4. **Add New Book**:
- Navigate to `http://localhost:3000/book/new`
- Fill out the form and submit to add a new book.
5. **View Books**:
- Navigate to `http://localhost:3000/books` to see the list of books.
### Conclusion
This guide walks you through the process of setting up a 3-tier Node.js application with a MongoDB backend. It includes setting up the database, creating models, defining routes and controllers, and building the front end with forms. By following these steps, students will gain practical experience in building a full-stack application.
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (