A Spring Boot microservices-based file management system that allows users to upload, download, organize files into folders, and search across the system.
The system is composed of three independent microservices:
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ File Service │ │ Folder Service │ │ Search Service │
│ :8081 │ │ :8082 │ │ :8083 │
│ │ │ │ │ │
│ /api/files │ │ /api/folders │ │ /api/search │
└─────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
└───────────────────────┴────────────────────────┘
Feign Clients / REST
| Service | Package | Responsibility |
|---|---|---|
| File Service | com.cfs.File_service |
Upload, download, and manage files |
| Folder Service | com.CFS.Folder_Service |
Create and organize folder hierarchy |
| Search Service | com.cfs.search_service |
Search files and folders by name |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/files |
Get all files |
GET |
/api/files/{id} |
Get file by ID |
GET |
/api/files/folder/{folderId} |
Get all files in a folder |
PUT |
/api/files |
Create a file record |
DELETE |
/api/files/{id} |
Delete a file by ID |
POST |
/api/files/upload |
Upload a file (multipart) |
GET |
/api/files/download/{id} |
Download a file by ID |
Request (multipart/form-data):
| Parameter | Type | Description |
|---|---|---|
name |
String |
Display name for the file |
folderId |
Long |
Target folder ID |
file |
MultipartFile |
The file binary |
Response:
{
"success": true,
"file": {
"id": 1718000000000,
"name": "report.pdf",
"size": 204800,
"folderId": 1,
"path": "/files/1718000000000"
}
}Returns the file as a binary stream with Content-Disposition: attachment header.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/folders |
Get all folders |
GET |
/api/folders/{id} |
Get folder by ID |
GET |
/api/folders/name/{name} |
Get folder by name |
GET |
/api/folders/parent/{parentId} |
Get child folders by parent ID |
POST |
/api/folders |
Create a folder (entity body) |
POST |
/api/folders/create |
Create a folder (JSON body) |
DELETE |
/api/folders |
Delete a folder by ID |
Request Body:
{
"name": "Documents",
"parentId": null
}Response:
{
"success": true,
"folder": {
"id": 1718000000001,
"name": "Documents",
"parentId": null
}
}Folders support a hierarchical structure — set
parentIdto nest a folder inside another.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/search?query= |
Search both files and folders |
GET |
/api/search/files?query= |
Search files only |
GET |
/api/search/folder?query= |
Search folders only |
Response:
{
"files": [
{ "id": 1718000000000, "name": "annual-report.pdf", ... }
],
"folders": [
{ "id": 1718000000001, "name": "Reports", ... }
]
}Search is case-insensitive and uses substring matching.
Uploaded files are stored on disk under the uploads/ directory relative to the File Service:
uploads/
└── {fileId}/
└── {originalFileName}
The path is recorded in the database as /files/{fileId} for reference.
- Java 17+
- Maven 3.8+
- A running relational database (configured per service)
Each microservice is an independent Spring Boot application. Run each in a separate terminal:
# File Service
cd file-service
mvn spring-boot:run
# Folder Service
cd folder-service
mvn spring-boot:run
# Search Service
cd search-service
mvn spring-boot:runConfigure each service's application.properties or application.yml:
# File Service
server.port=8081
spring.datasource.url=jdbc:your-db-url
spring.datasource.username=your-username
spring.datasource.password=your-password
# Folder Service
server.port=8082
# Search Service
server.port=8083
file.service.url=http://localhost:8081
folder.service.url=http://localhost:8082DELETE /api/foldersis missing the@PathVariableannotation — theidpath variable is not bound correctly.downloadFilehas a malformed header:CONTENT_LENGTHis concatenated with the value string instead of being set as a separate header value.- File and Folder IDs are generated using
System.currentTimeMillis()— consider using a UUID or database-generated sequence for production use. - Search service fetches all records from File and Folder services and filters in memory — may not scale well with large datasets.
- No authentication or authorization is implemented.
cfs/
├── file-service/
│ └── src/main/java/com/cfs/File_service/
│ ├── controller/FileController.java
│ ├── model/FileEntity.java
│ └── repo/FileRepository.java
├── folder-service/
│ └── src/main/java/com/CFS/Folder_Service/
│ ├── controller/FolderController.java
│ ├── model/FolderEntity.java
│ └── repo/FolderRepository.java
└── search-service/
└── src/main/java/com/cfs/search_service/
├── controller/SearchController.java
├── client/FileSearchClient.java
└── client/FolderSearchClient.java
This project is for internal/educational use.