Skip to content

A virtual directory system that simulates a hierarchical file/folder structure using a single database table or collection.

Notifications You must be signed in to change notification settings

donaghosh/virtual-directory-system

Repository files navigation

Virtual Directory System

A virtual directory system built with Node.js, Express.js, MongoDB, and Mongoose. This system simulates a complete file system structure within a database, supporting all standard CRUD operations through a RESTful API with comprehensive validation and error handling.

🏗️ Architecture

HTTP Client → Express Router → Controllers → Services → Mongoose Models → MongoDB

📂 Log Files

File Purpose Content
logs/requests.log HTTP Traffic Request/response data, status codes, duration, IP addresses
logs/application.log Business Logic Directory operations, validation, errors, success details

📚 Documentation

🛠️ Installation & Setup

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (v4.4 or higher) - Local installation or MongoDB Atlas

Quick Start

  1. Clone the repository

    git clone <repository-url>
    cd virtual-directory-system
  2. Install dependencies

    npm install
  3. Set up environment variables

    # Create .env file (optional - defaults to local MongoDB)
    echo "MONGODB_URI=mongodb://localhost:27017/virtual-directory-system" > .env
  4. Start MongoDB (if using local installation)

    # macOS/Linux
    mongod
  5. Start the server

    npm start : "node --env-file=.env server.js",
    npm run dev : "nodemon --watch --env-file=.env server.js",
    npm run auto : "node --env-file=.env app.js",
    npm run auto-dev : "nodemon --watch --env-file=.env app.js",
  6. Verify installation

    curl http://localhost:3000/api/directory \
      -X POST \
      -H "Content-Type: application/json" \
      -d '{"name": "root", "type": "folder", "parentId": null}'

Environment Variables

Variable Default Description
MONGODB_URI mongodb://localhost:27017/virtual-directory-system MongoDB connection string
PORT 3000 Server port

🧪 Testing

The project includes comprehensive test coverage with 119/119 tests passing:

Running Tests

# Run all tests
npm test

# Run tests with coverage report
npm test -- --coverage

# Run specific test suites
npm test -- --testPathPattern=controllers
npm test -- --testPathPattern=models
npm test -- --testPathPattern=validation
npm test -- --testPathPattern=integration

🔧 Technology Stack

Layer Technology Purpose
API Express.js RESTful API server
Database MongoDB + Mongoose Document storage with ODM
Validation Custom Utils Input sanitization
Testing Jest + Supertest Unit & integration testing
Architecture Layered MVC Separation of concerns

🗑️ Soft Delete Strategy

The system implements a production-ready soft delete strategy with automatic cleanup. Instead of hard delete, it uses deletedAt + periodic cleanup.

📸 API Screenshots

Create

Create

List

List

Rename

Rename

Move

Move

Delete

Delete

About

A virtual directory system that simulates a hierarchical file/folder structure using a single database table or collection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published