How bkizilkayaa/spring-boot-filetransfer works
Project type and purpose
• This is a lightweight two-service Spring Boot “file transfer” microservice demo.
• The root module (port 8080) exposes endpoints to upload/download files and uses RestTemplate to forward requests to a second service.
• The cross-service module (port 8081) exposes its own file upload/download endpoints—acting as the “client side” storage.
File structure
• Top level:
• root pom.xml and /src → FiletransferApplication (port 8080).
• /cross-service/pom.xml and /cross-service/src → TargetpathApplication (port 8081).
• Each service follows a standard layered layout:
• controller/ → REST endpoints
• service/ → business logic
• utilities/ (or response/) → file I/O helpers
• model/ or response/ → DTOs
• resources/files → local storage
• RestTemplate is configured in the root service to call the client service.
README for additional insights
• Root service listens on 8080, client service listens on 8081.
• Three main flows:
a. GET from 8080 → reads file locally.
b. POST to 8080 → forwards file via RestTemplate to 8081.
c. GET directly on 8081 → reads file from client storage.
Main components & interactions
a. Components:
• External Client (e.g., Postman or front-end)
• FileTransferService (port 8080)
– FileTransferController
– FileUploadService & FileDownloadService
– FileUploadUtil & FileDownloadUtil
– Local filesystem (“server-side files”)
• TargetPathService (port 8081)
– FileController
– FileUploadService & FileDownloadService
– FileUploadUtil & FileDownloadUtil
– Local filesystem (“client-side files”)
• RestTemplate (embedded in FileUploadService of 8080)
b. Relationships & data flow:
1) External Client → (HTTP) → FileTransferController@8080
2) Controller → Service layer → if GET: reads from server FS → returns to client
3) if POST: Service → RestTemplate → 8081/FileController
4) 8081/FileController → writes to client FS → returns response → propagates back to original client
5) External Client can also directly call 8081 to verify download
c. Architectural patterns:
• Layered (Controller → Service → Utility)
• Two independent deployable Spring Boot “containers” (no API Gateway)
• Synchronous HTTP (RestTemplate) inter-service communication
d. Key technologies:
• Spring Boot (Web starter)
• Spring MVC controllers
• Spring’s RestTemplate
• Maven multi-module build
• Local file I/O
Elements
• Clear labels: service names, ports, layers (Controller, Service, Utility), storage location
• External Client → 8080 Controller
• 8080 Service → (RestTemplate) → 8081 Controller
• Controllers → Local FS
• Blue rectangles for services
• Orange stick figure or rectangle for External Client
Detailed yet concise capture
• Dual-flow: direct GET on 8080, forwarded POST to 8081, and optional direct GET on 8081.
• RestTemplate component explicitly in the inter-service flow.