DEV Community

Cover image for Building a Full-Stack Notes Application with Node.js, Express, React, and Tailwind CSS πŸš€βœ¨
Mohamed Ibrahim
Mohamed Ibrahim

Posted on

Building a Full-Stack Notes Application with Node.js, Express, React, and Tailwind CSS πŸš€βœ¨

Introduction

In this project, I developed a robust full-stack notes application designed to manage and organize notes efficiently. The application showcases several modern web development practices, including a RESTful API, dynamic UI updates, and state management, ensuring a great user experience.

This project demonstrates how to build a full-stack application with modern technologies and best practices. It’s a great starting point for anyone looking to build similar CRUD-based applications. You can explore the code and contribute to the project on GitHub.

ScreenShots

Note Home Page

Add Note

Note About

Note Delete With Modal

Features

Here are the key features of the application:

  • Add Notes: Users can create new notes with a title and rich text content.

  • Edit Notes: Existing notes can be updated seamlessly with an intuitive UI.

  • Delete Notes: Notes can be deleted with a confirmation modal for added safety.

  • Search Notes: Users can search for notes dynamically with real-time filtering.

  • Responsive Design: The application is styled with Tailwind CSS for a clean and responsive interface.

  • Loading Indicators: A loading spinner or skeleton UI is displayed during data fetching to enhance UX.

  • Toast Notifications: Success and error messages are shown using the react-toastify library for better feedback.

  • Reusable Components: Components like modals, note cards, and the navbar are modular and reusable.

Backend Overview

The backend is built using Node.js and Express, with SQLite as the database. It exposes a RESTful API for CRUD operations.

Endpoints:

  • GET /api/notes: Fetch all notes.

  • GET /api/notes/:id: Fetch a specific note by ID.

  • POST /api/notes: Add a new note.

  • PUT /api/notes/:id: Update a specific note.

  • DELETE /api/notes/:id: Delete a specific note.

Example Code for Backend:

const express = require('express');
const router = express.Router();
const { addNote, getNotes, getNoteById, updateNote, deleteNote } = require('../controllers/noteController');

router.get('/', getNotes);
router.get('/:id', getNoteById);
router.post('/', addNote);
router.put('/:id', updateNote);
router.delete('/:id', deleteNote);

module.exports = router;
Enter fullscreen mode Exit fullscreen mode

Frontend Overview

The frontend is developed using React and styled with Tailwind CSS. Routing is handled by react-router-dom.

Components:

  • Navbar: Contains links to different pages like Home, Add Note, and About.

  • NoteCard: Displays individual notes with options to view, edit, or delete.

  • Search Bar: Filters notes dynamically based on the user's input.

  • Add/Edit Note Form: Allows users to create or edit notes with a rich text editor.

  • Confirmation Modal: Ensures safety when deleting notes.

Context API for State Management

To manage global loading states, I used the Context API:

LoadingContext.js:

import { createContext, useState } from 'react';

export const LoadingContext = createContext();

export const LoadingProvider = ({ children }) => {
  const [loading, setLoading] = useState(false);

  return (
    <LoadingContext.Provider value={{ loading, setLoading }}>
      {children}
    </LoadingContext.Provider>
  );
};
Enter fullscreen mode Exit fullscreen mode

Axios Configuration

To manage API requests more efficiently, I created a centralized Axios config file:

axiosConfig.js:

import axios from 'axios';

const axiosInstance = axios.create({
  baseURL: 'http://localhost:5000/api/',
  headers: { 'Content-Type': 'application/json' },
});

export default axiosInstance;
Enter fullscreen mode Exit fullscreen mode

Folder Structure

The project is structured to ensure scalability and maintainability:

frontend/
β”œβ”€β”€ src/
   β”œβ”€β”€ components/
   β”‚   β”œβ”€β”€ Navbar.js
   β”‚   β”œβ”€β”€ NoteCard.js
   β”‚   └── DeleteModal.js
   β”œβ”€β”€ pages/
   β”‚   β”œβ”€β”€ Home.js
   β”‚   β”œβ”€β”€ AddNote.js
   β”‚   └── EditNote.js
   β”œβ”€β”€ config/
   β”‚   └── axiosConfig.js
   β”œβ”€β”€ context/
   β”‚   └── LoadingContext.js
   └── App.js

backend/
β”œβ”€β”€ controllers/
β”œβ”€β”€ models/
β”œβ”€β”€ routes/
└── server.js
Enter fullscreen mode Exit fullscreen mode

Challenges Faced

  • Dynamic Filtering: Ensuring the search function updates the note list in real time.

  • User Experience: Balancing performance and a polished UI with features like skeleton loading and toast notifications.

Things you can add to improve your skills:

  • User Authentication: Add login/signup functionality to secure user notes.

  • Tagging and Categorization: Allow users to organize notes with tags.

  • Export Notes: Provide an option to export notes as PDFs or text files.

  • Dark Mode: Enhance UI by adding a dark theme toggle.

Conclusion

This project demonstrates how to build a full-stack application with modern technologies and best practices. It’s a great starting point for anyone looking to build similar CRUD-based applications. You can explore the code and contribute to the project on GitHub.

I hope you find this project useful and inspiring! Feel free to leave feedback or suggestions. πŸš€

Follow Me

Thank you for reading my blog. πŸš€ You can follow me on GitHub and connect on Twitter

Top comments (0)