Index: jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/ApplicationServiceImpl.java
===================================================================
--- jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/ApplicationServiceImpl.java	(revision 28b3398dcd7f9cfd044c2cb7923434b06037fee2)
+++ jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/ApplicationServiceImpl.java	(revision 0f0add0e646bd880b8213e381f57f621bc0e6861)
@@ -41,5 +41,5 @@
     public ApplicationServiceImpl(@Value("${file.upload-dir}") String uploadDir, UserRepository userRepository, ApplicationRepository applicationRepository, JobAdvertisementRepository jobAdvertisementRepository,
                                   JobSeekerRepository jobSeekerRepository) {
-        this.fileStorageLocation = Paths.get(uploadDir).toAbsolutePath().normalize();
+        this.fileStorageLocation = Paths.get(uploadDir + "/applications").toAbsolutePath().normalize();
 
         try {
@@ -58,17 +58,12 @@
     public ApplicationDetailsDTO submitApplication(ApplicationDTO applicationDTO) {
 
+        JobSeeker jobSeeker = jobSeekerRepository.findById(applicationDTO.getJobSeekerId())
+                .orElseThrow(() -> new IllegalArgumentException("User not found."));
+        JobAdvertisement jobAdvertisement = jobAdvertisementRepository.findById(applicationDTO.getJobAdId())
+                .orElseThrow(() -> new IllegalArgumentException("Job advertisement not found."));
+
         if (applicationDTO.getResumeFile().isEmpty()) {
             throw new RuntimeException("Failed to store empty file.");
         }
-
-        Path targetLocation = this.fileStorageLocation.resolve(applicationDTO.getResumeFile().getOriginalFilename());
-        try {
-            Files.copy(applicationDTO.getResumeFile().getInputStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-
-        JobSeeker jobSeeker = jobSeekerRepository.findById(applicationDTO.getJobSeekerId()).orElseThrow(() -> new IllegalArgumentException("User not found"));
-        JobAdvertisement jobAdvertisement = jobAdvertisementRepository.findById(applicationDTO.getJobAdId()).orElseThrow(() -> new IllegalArgumentException("Job Ad not found"));
 
         List<String> answers = new ArrayList<>();
@@ -77,6 +72,23 @@
         answers.add(applicationDTO.getAnswerThree());
 
-        Application application = new Application(jobSeeker, jobAdvertisement, applicationDTO.getResumeFile().getOriginalFilename(), answers, applicationDTO.getMessageToRecruiter());
-        applicationRepository.save(application);
+        Application application = new Application(jobSeeker, jobAdvertisement,
+                answers,applicationDTO.getMessageToRecruiter());
+        application = applicationRepository.save(application);
+
+        Path filePath = this.fileStorageLocation.resolve(String.valueOf(application.getId())).resolve("resume");
+        Path targetLocation = filePath.resolve(applicationDTO.getResumeFile().getOriginalFilename());
+
+        try {
+            Files.createDirectories(filePath);
+            Files.copy(applicationDTO.getResumeFile().getInputStream(), targetLocation);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        String relativePath = Paths.get("uploads","applications",String.valueOf(application.getId()),
+                "resume", applicationDTO.getResumeFile().getOriginalFilename()).toString();
+        application.setResumeFilePath(relativePath);
+        application = applicationRepository.save(application);
+
         return Application.mapToApplicationDetailsDTO(application);
     }
@@ -95,15 +107,20 @@
 
     @Override
-    public Resource loadResumeAsResource(String fileName) {
+    public Resource loadResumeAsResource(Long applicationId) {
+        Application application = applicationRepository.findById(applicationId).
+                orElseThrow(() -> new IllegalArgumentException("Application not found"));
+
+        String relativeFilePath = application.getResumeFilePath();
+        Path filePath = fileStorageLocation.getParent().getParent().resolve(relativeFilePath).normalize();
+
         try {
-            Path filePath = fileStorageLocation.resolve(fileName).normalize();
             Resource resource = new UrlResource(filePath.toUri());
             if (resource.exists()) {
                 return resource;
             } else {
-                throw new RuntimeException("File not found " + fileName);
+                throw new RuntimeException("File not found: " + relativeFilePath);
             }
         } catch (IOException ex) {
-            throw new RuntimeException("File not found " + fileName, ex);
+            throw new RuntimeException("File path is invalid: " + relativeFilePath, ex);
         }
     }
