A UNIX-style, in-memory file system simulator built in Java, exposed via RESTful APIs using Spring Boot and a CLI for interactive shell-based access.
Supports core file and directory operations (mkdir, ls, cd, touch, write, cat) with persistence via Java serialization and is fully Dockerized for portable deployment.
- 🗂️ Simulates a hierarchical file system using an n-ary tree structure
- 🛠️ Shell-like operations:
mkdir,cd,ls,touch,cat,write - 🌐 Exposed via Spring Boot REST APIs
- 💻 Interactive CLI for direct terminal usage
- 💾 Persistent state using Java serialization (
filesystem.ser) - 🐳 Dockerized for consistent deployment
- Language: Java 17
- Framework: Spring Boot
- Build Tool: Maven
- Persistence: Java Object Serialization
- Containerization: Docker
- CLI: Java Console (Scanner)
src/main/java/com/memfs/memfs
├── MemfsApplication.java # Spring Boot entry point
├── model/
│ └── FileNode.java # Represents files/directories
├── service/
│ └── FileSystemService.java # Core logic & persistence
├── controller/
│ └── FileSystemController.java # REST API layer
└── cli/
└── MemfsCliRunner.java # Terminal-based CLI interface
Base URL: http://localhost:8080/api/fs
| Method | Endpoint | Description |
|---|---|---|
| POST | /mkdir |
Create directory |
| GET | /ls |
List directory contents |
| POST | /touch |
Create empty file |
| GET | /cat |
Read file content |
| POST | /write |
Write content to file |
| POST | /cd |
Change directory |
Run MemfsCliRunner to use the interactive shell:
> mkdir projects
> cd projects
> touch readme.txt
> write readme.txt Hello MemFS!
> cat readme.txt
Hello MemFS!
> ls
[readme.txt]
docker build -t memfs .
docker run -p 8080:8080 memfs