My Logo

PUBLISHED MAY 08, 2024

Teghen Donald Ticha
Lastly Updated: 3 months ago
Reading time 23 mins

Project Planning and Setup

Discuss the planning and design process for building our interactive file explorer in Node.js, focusing on core features, UI/UX design, and implementation approach and initial setup.
Project Planning and Setup

Prerequisite

For absolute beginners, it's recommended(not required) that you go back and complete the preceding chapters, first before returning to this one.However, if you've got some basic knowledge of Node.js and its core APIs, then you can get started straightway with this chapter.

Objectives and Scope

Purpose: The purpose of the Interactive File Explorer is to provide users with a command-line interface for navigating, managing, and interacting with files and folders on their local file system.

Scope: The initial version will focus on core file system navigation, displaying file/folder information, and basic interaction functionalities.

Advanced features like search, file creation/editing, and git integration will be added incrementally in subsequent chapters.

Core Features
  1. 1.File System Navigation: Allow users to browse through directories, view file/folder contents, and navigate back and forth within the file system.
  2. 2.Display File/Folder Information: Show details such as file size, modification date, and permissions for selected files and folders.
  3. 3.Basic Interaction: Support commands for listing directory contents, moving between directories, and viewing file contents.
Design User Interface (UI)
  • Command-Line Interface (CLI): The application will primarily use a command-line interface for interaction, providing a text-based menu for navigating and executing commands.
  • Clean and Intuitive Design: The CLI will have a simple and intuitive layout, with clear prompts and instructions for users to follow.
  • Keyboard Navigation: Users can navigate through menus and options using arrow keys and keyboard shortcuts for efficient interaction.

Development Process Outline
  1. 1.Setting Up the Project: Create a new Node.js project and initialize a Git repository for version control.
  2. 2.Basic Functionality: Implement core functionalities such as directory navigation, file listing, and basic commands for interacting with files and folders.
  3. 3.Adding Advanced Features: Incrementally add advanced features like search, file creation/editing, and git integration based on user feedback and requirements.
  4. 4.Testing and Debugging: Conduct thorough testing to ensure the application functions as expected and address any bugs or issues.
  5. 5.Documentation and Deployment: Provide comprehensive documentation for users and developers, including installation instructions and usage guidelines.
    Deploy the application to a version control repository for public access and collaboration.


By following this comprehensive plan and design, we can ensure that the Interactive File Explorer application meets our expectations. Let's get started with the initial project setup.

In this section, we'll lay the foundation for our Interactive File Explorer app following these steps:

  • set up the project structure,
  • initialize an npm project,
  • install necessary dependencies
  • initialize version control with Git,
  • create a GitHub repository,
  • commit and push the initial setup to github
Folder Structure

Start by creating a new project directory named `interactive-file-explorer` to contain all project files and subdirectories.

Then, inside that directory, create subdirectories for organizing different aspects of the project

At this point you should have something similar to what we have below:

interactive-file-explorer/
  ├── src/
  ├── test/

Let's breakdown the roles of each subdirectory:

  • src/: This directory will contain all our source code files.
  • test/: We'll store test scripts and related files here.
npm Project Initialization

Initialize a new npm project with default settings by running this command in the root directory:

npm init -y

This will create a package.json file in the project's root directory.

Dependency Installations

Install these npm packages for our project:

npm install inquirer chalk fs-extra 


npm install -D prettier mocha chai nodemon

Breakdown: We've had a brief overview of inquire.js and chalk in our early discussions. You may review them or simply loop them on the npm website and read through the documentation.

  • inquirer: A library for creating interactive command-line interfaces.
  • chalk: A library for styling CLI output with colors.
  • fs-extra: An extension of the built-in fs module with additional functionality.
  • prettier: Tools for code formatting.
  • mocha, chai: Testing frameworks for unit testing.
  • nodemon: Tool for automatic app restart on each file change.

Add an `index.js` file in src folder and an `index.test.js` file in the test folder just so you can run some scripts to make sure the setup is successful.

// index.test.ts file
import { assert } from "chai";

describe('Test setup', function () {
    it('should pass', function () {
        const name = 'TEST'
        
        assert.typeOf(name, 'string');
    })
});



// index.js file
console.log('Ready to go!')


create a .prettierrc.json file in the root directory and add the follow:

{
    "trailingComma": "none",
    "tabWidth": 4,
    "semi": true,
    "singleQuote": true,
    "printWidth": 80
}


At this point, your package.json file should look like this:


{
    "name": "interactive-file-explorer-app",
    "version": "1.0.0",
    "description": "",
    "main": "src/index.js",
    "type": "module",
    "directories": {
        "test": "test",
        "src": "dev"
    },
    "scripts": {
        "format": "prettier --write src test",
        "start": "node src/index.js",
        "test": "mocha",
        "dev": "nodemon --exec \"npm run format && npm run start\""
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "chai": "^5.1.0",
        "mocha": "^10.4.0",
        "nodemon": "^3.1.0",
        "prettier": "^3.2.5"
    },
    "dependencies": {
        "chalk": "^5.3.0",
        "fs-extra": "^11.2.0",
        "inquirer": "^9.2.20"
    }
}



To make sure that everything is setup successfully thus far, run the following commands one at a time:

npm run test
npm run dev

If you didn't encounter any errors, then you're good to go!😎

Git Initialization

Navigate to the project's root directory and initialize a new Git repository:

git init

Create a .gitignore file to exclude unnecessary files from version control.

GitHub Repository Creation

Head over to GitHub and create a new repository named `interactive-file-explorer`. If you're new to git and repository hosting platforms, then follow this official github guide to help you levelup quickly.

When you're done with repository setup, return to the code editor and let's continue.

From your terminal, stage all changes and commit them with a descriptive message:

git add .
git commit -m "Initial project setup"


Push the initial commit to the GitHub repository

git remote add origin <repository-url>
git branch -M main
git push -u origin main
NB: Replace <repository-url> with the actual https url of your github repository.


By following these steps, we've set up our project directory, initialized version control, created a GitHub repository, and prepared our environment for developing the Interactive File Explorer application.

We're now ready to move on to implementing the core functionalities.

All Chapter Parts for NodeJs In Theory, An absolute Beginner’s Overview
  1. Chapter 1 , Part 1 : Introduction to NodeJS

    In this series part, I introduce nodeJS and some technical concepts associated with it. I also show how easy it is to setup and start a simple nodeJS web server.

  2. Chapter 1 , Part 2 : How to Install and Setup NodeJS

    In this series part, I run you through the various ways to install nodeJS. I also discuss how to install nvm and use it to switch between different node versions.

  3. Chapter 1 , Part 3 : How much JavaScript do you need to learn NodeJS

    In this series part, we explore the nuanced relationship between JavaScript and NodeJS, highlighting some subtle distinctions between the two environments.

  4. Chapter 1 , Part 4 : The v8 Engine and the difference Between NodeJS and the browser

    In this series part, we explore the V8 engine and how it interacts with nodeJS. We also discuss node’s event loop and uncover the mystery behinds node’s ability to handle concurrent operations.

  5. Chapter 1 , Part 5 : NPM, the NodeJS package manager

    Discover the essentials of npm, the powerful package manager for Node.js. Learn installation, management, publishing, and best practices

  6. Chapter 1 , Part 6 : NodeJS in Development Vs Production

    Explore how Node.js behaves differently in development and production environments. Learn key considerations for deploying Node.js applications effectively.

  7. Chapter 2 , Part 1 : Asynchronous Flow Control

    In this series part, we'll explore various aspects of asynchronous flow control in Node.js, from basic concepts to advanced techniques.

  8. Chapter 2 , Part 2 : Blocking vs Non-blocking I/O

    Explore the differences between blocking and non-blocking I/O in Node.js, and learn how to optimize performance and scalability.

  9. Chapter 2 , Part 3 : Understanding NodeJS Event loop

    Exploring the Node.js event loop by understanding its phases, kernel integration, and processes enabling seamless handling of asynchronous operations in your applications.

  10. Chapter 2 , Part 4 : The NodeJS EventEmitter

    Explore the power of Node.js EventEmitter: an essential tool for building scalable and event-driven applications. Learn how to utilize it effectively!

  11. Chapter 3 , Part 1 : Working with files in NodeJS

    Gain comprehensive insights into file management in Node.js, covering file stats, paths, and descriptors, to streamline and enhance file operations in your applications.

  12. Chapter 3 , Part 2 : Reading and Writing Files in NodeJS

    Uncover the fundamentals of reading and writing files in nodeJS with comprehensive examples and use cases for some widely used methods.

  13. Chapter 3 , Part 3 : Working with Folders in NodeJS

    Unlock the secrets of folder manipulation in Node.js! Explore essential techniques and methods for working with directories efficiently

  14. Chapter 4 , Part 1 : Running NodeJS Scripts

    Master the command line interface for executing nodeJS scripts efficiently. Learn common options and best practices for seamless script execution

  15. Chapter 4 , Part 2 : Reading Environment Variables in NodeJS

    Learn how to efficiently manage environment variables in nodeJS applications. Explore various methods and best practices for security and portability

  16. Chapter 4 , Part 3 : Writing Outputs to the Command Line in NodeJS

    Learn essential techniques for writing outputs in nodeJS CLI. From basic logging to formatting and understanding stdout/stderr.

  17. Chapter 4 , Part 4 : Reading Inputs from the Command Line in NodeJS

    Learn the various ways and strategies to efficiently read command line inputs in nodeJS, making your program more interactive and flexible.

  18. Chapter 4 , Part 5 : The NodeJS Read, Evaluate, Print, and Loop (REPL)

    Explore the power of nodeJS's Read, Evaluate, Print, and Loop (REPL). Learn how to use this interactive environment for rapid prototyping, debugging, and experimentation.

  19. Chapter 5 , Part 1 : Introduction to Testing in NodeJS

    Discover the fundamentals of testing in nodeJS! Learn about testing types, frameworks, and best practices for building reliable applications.

  20. Chapter 5 , Part 2 : Debugging Tools and Techniques in NodeJS

    Explore essential debugging tools and techniques in Node.js development. From built-in options to advanced strategies, and best practices for effective debugging.

  21. Chapter 6 , Part 1 : Project Planning and Setup

    Discuss the planning and design process for building our interactive file explorer in Node.js, focusing on core features, UI/UX design, and implementation approach and initial setup.

  22. Chapter 6 , Part 2 : Implementing Basic functionalities

    In this guide, we'll implement the basic functionalities of our app which will cover initial welcome and action prompts.

  23. Chapter 6 , Part 3 : Implementating Core Features and Conclusion

    In this guide, we'll complete the rest of the more advanced functionalities of our app including, create, search, sort, delete, rename and navigate file directories.