# ssaisriharsha/cloud-storage architecture

> Architecture diagram of the GitHub repository ssaisriharsha/cloud-storage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ssaisriharsha/cloud-storage
- Repository: https://github.com/ssaisriharsha/cloud-storage

## Overview

##### Project type and purpose
- This is a standalone, monolithic backend service built on Spring Boot that provides REST-based cloud-storage functionality: user registration/login (JWT auth), file upload/download, metadata storage in a relational database, and in-filesystem (or pluggable) file persistence.

##### File structure
- Top level
- pom.xml, mvnw/mvnw.cmd: Maven wrapper and dependencies
- src/main/java/com/ssaisriharsha/cloud_storage: application root
- src/main/resources: three profiles (dev, test, default)
- Controllers
- AuthController: handles /auth endpoints
- FileHandlingController: handles /files endpoints
- DTOs: payload objects for user signup/login
- Entities: JPA-mapped classes (User, DataFile, AccessTable, FileStatus)
- Repos: Spring Data JPA interfaces (UserRepo, FileRepo)
- Services: business logic
- AuthService, JwtService
- ParentStorageService with two implementations (DbStorageService, FileSystemStorageService)
- SecurityConfig:
- Config: WebSecurityConfigurer with JwtAuthenticationFilter
- Permissions, SecureUser (UserDetails wrapper)
- Exception handling: ControllerAdvice and custom exceptions (e.g. PathTraversalException)

##### Key insights (README is empty)
- All logic lives in a single Spring Boot application
- Uses JWT for stateless auth
- Persistence layer split between RDBMS (metadata) and filesystem (payload)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Client["Client (Web/Mobile/CLI)"]:::external

    %% API Layer
    subgraph "API Layer"
        direction TB
        JWTFilter["JWTAuthenticationFilter"]:::filter
        AuthCtrl["AuthController"]:::controller
        FileCtrl["FileHandlingController"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        AuthService["AuthService"]:::service
        JwtService["JwtService"]:::service
        ParentStorage["ParentStorageService (interface)"]:::service
        FileSystemSvc["FileSystemStorageService"]:::service
        DbStorageSvc["DbStorageService"]:::service
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        subgraph "Relational DB"
            direction TB
            UserRepo["UserRepo"]:::repo
            FileRepo["FileRepo"]:::repo
            UserEntity["User"]:::entity
            DataFileEntity["DataFile"]:::entity
            AccessTable["AccessTable"]:::entity
            FileStatus["FileStatus"]:::entity
        end
        FileStore["File Store (Filesystem/Cloud)"]:::database
    end

    %% Exception Handling
    ExceptionHandler["ControllerAdvice"]:::exception
    PathErr["PathTraversalException"]:::exception

    %% Config & Security
    Config["Config (WebSecurityConfigurer)"]:::config
    Permissions["Permissions"]:::config
    SecureUser["SecureUser"]:::config

    %% Configuration Profiles
    subgraph "Configurations"
        direction TB
        AppProps["application.properties"]:::config
        DevProps["application-dev.properties"]:::config
        TestProps["application-test.properties"]:::config
    end

    %% Connections
    Client -->|HTTPS Request| JWTFilter
    JWTFilter --> AuthCtrl
    JWTFilter --> FileCtrl
    AuthCtrl -->|"calls"| AuthService
    AuthCtrl -->|"uses DTOs"| UserDTO
    AuthCtrl -->|"uses DTOs"| UserLoginDTO
    FileCtrl -->|"calls"| ParentStorage
    FileCtrl -->|"calls"| AuthService
    AuthService -->|"issues JWT via"| JwtService
    ParentStorage -->|implements| FileSystemSvc
    ParentStorage -->|implements| DbStorageSvc
    FileSystemSvc -->|writes/reads| FileStore
    DbStorageSvc -->|writes/reads| FileStore
    AuthService -->|accesses| UserRepo
    FileCtrl -->|accesses| FileRepo
    UserRepo -->|manages| UserEntity
    FileRepo -->|manages| DataFileEntity
    FileRepo -->|manages| AccessTable
    FileRepo -->|manages| FileStatus
    ExceptionHandler -.-> AuthCtrl
    ExceptionHandler -.-> FileCtrl
    ExceptionHandler -->|handles| PathErr
    Config --> JWTFilter
    Config --> AuthCtrl
    Config --> FileCtrl

    %% Click Events
    click CloudStorageApplication "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/CloudStorageApplication.java"
    click AuthCtrl "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Controllers/AuthController.java"
    click FileCtrl "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Controllers/FileHandlingController.java"
    click UserDTO "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/DTOs/UserDTO.java"
    click UserLoginDTO "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/DTOs/UserLoginDTO.java"
    click UserEntity "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Entities/User.java"
    click DataFileEntity "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Entities/DataFile.java"
    click AccessTable "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Entities/AccessTable.java"
    click FileStatus "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Entities/FileStatus.java"
    click UserRepo "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Repos/UserRepo.java"
    click FileRepo "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Repos/FileRepo.java"
    click AuthService "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Services/AuthService.java"
    click JwtService "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Services/JwtService.java"
    click ParentStorage "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Services/ParentStorageService.java"
    click FileSystemSvc "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Services/FileSystemStorageService.java"
    click DbStorageSvc "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Services/DbStorageService.java"
    click Config "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/SecurityConfig/Config.java"
    click Permissions "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/SecurityConfig/Permissions.java"
    click SecureUser "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/SecurityConfig/SecureUser.java"
    click JWTFilter "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Filters/JwtAuthenticationFilter.java"
    click ExceptionHandler "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/ExceptionHandlers/ControllerAdvice.java"
    click PathErr "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/java/com/ssaisriharsha/cloud_storage/Exceptions/PathTraversalException.java"
    click AppProps "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/resources/application.properties"
    click DevProps "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/resources/application-dev.properties"
    click TestProps "https://github.com/ssaisriharsha/cloud-storage/blob/main/src/main/resources/application-test.properties"

    %% Styles
    classDef controller fill:#cee4fd,stroke:#0b69a3,color:#0b69a3;
    classDef service fill:#d4edda,stroke:#2e7d32,color:#2e7d32;
    classDef repo fill:#fff3cd,stroke:#ff8f00,color:#ff8f00;
    classDef entity fill:#ffe5b4,stroke:#ff6f00,color:#ff6f00;
    classDef database fill:#ffd7d9,stroke:#d32f2f,color:#d32f2f;
    classDef filter fill:#e1bee7,stroke:#6a1b9a,color:#6a1b9a;
    classDef exception fill:#f8bbd0,stroke:#c2185b,color:#c2185b;
    classDef config fill:#cfd8dc,stroke:#455a64,color:#455a64;
    classDef external fill:#eceff1,stroke:#607d8b,color:#607d8b;
```
