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.
HTTP Client → Express Router → Controllers → Services → Mongoose Models → MongoDB
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 |
- API Documentation - Complete API reference with examples
- Architecture Diagram - Visual system architecture
- Problem Statement: Notion Link
- Node.js (v14 or higher)
- MongoDB (v4.4 or higher) - Local installation or MongoDB Atlas
-
Clone the repository
git clone <repository-url> cd virtual-directory-system
-
Install dependencies
npm install
-
Set up environment variables
# Create .env file (optional - defaults to local MongoDB) echo "MONGODB_URI=mongodb://localhost:27017/virtual-directory-system" > .env
-
Start MongoDB (if using local installation)
# macOS/Linux mongod
-
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",
-
Verify installation
curl http://localhost:3000/api/directory \ -X POST \ -H "Content-Type: application/json" \ -d '{"name": "root", "type": "folder", "parentId": null}'
Variable | Default | Description |
---|---|---|
MONGODB_URI |
mongodb://localhost:27017/virtual-directory-system |
MongoDB connection string |
PORT |
3000 |
Server port |
The project includes comprehensive test coverage with 119/119 tests passing:
# 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
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 |
The system implements a production-ready soft delete strategy with automatic cleanup. Instead of hard delete, it uses deletedAt + periodic cleanup.
Create
List
Rename
Move
Delete