Skip to content

Document Service API

πŸ“„

A robust, multi-tenant document management REST API built with Java, Spring Boot, and PostgreSQL. Supports file upload, download, metadata management, and integration with multiple cloud storage providers: AWS, GCP, Azure, Cloudinary, and Local storage.


Features

Feature Description Icon
Multi-Tenant Support Isolates documents per tenant 🏒
File Upload/Download Upload and download documents (local & all supported providers) ⬆️⬇️
Metadata Management Store and query document metadata 🏷️
Pagination & Filtering Efficiently list and search documents πŸ“„πŸ”
Cloud Storage Integrates with AWS, GCP, Azure, Cloudinary, and Local storage ☁️
RESTful API Clean, documented endpoints (OpenAPI/Swagger) πŸ”—
Auditing Tracks created/updated by and timestamps πŸ•’

Architecture Overview

flowchart TD
    A[Client] -->|REST API| B(DocumentController)
    B --> C[DocumentService]
    C --> D[DocumentRepository]
    C --> E[BucketProviderServices]
    D --> F[(PostgreSQL)]
    E --> G[(AWS/GCP/Azure/Cloudinary/Local)]
Hold "Alt" / "Option" to enable pan & zoom

API Endpoints

Note: Real API endpoints to be provided and included here.

Method Endpoint Description Notes/Parameters
POST /api/v1/documents Upload a new document tenantId header, multipart form
GET /api/v1/documents/{documentId}/download Download a document by ID tenantId header
GET /api/v1/documents/{id} Get document information by ID
GET /api/v1/documents List all documents (paginated, filter) tenantId param, q param, pageable

Sequence: Document Upload

sequenceDiagram
    participant U as User
    participant API as DocumentController
    participant S as DocumentService
    participant R as DocumentRepository
    participant B as BucketProviderService
    U->>API: POST /documents/upload (file, metadata)
    API->>S: validate & process
    S->>B: upload to selected provider (AWS/GCP/Azure/Cloudinary/Local)
    B-->>S: return file URL
    S->>R: save metadata
    R-->>S: confirm
    S-->>API: DocumentUploadResponse
    API-->>U: 201 Created + metadata
Hold "Alt" / "Option" to enable pan & zoom

Database Schema

erDiagram
    documents {
        UUID id PK
        TIMESTAMP created
        TIMESTAMP updated
        VARCHAR created_by
        VARCHAR updated_by
        VARCHAR file_name
        UUID user_id
        UUID tenant_id
        VARCHAR file_type
        VARCHAR file_size
        VARCHAR provider_id
        VARCHAR download_url
        VARCHAR bucket_provider
    }
Hold "Alt" / "Option" to enable pan & zoom

Supported Bucket Providers

The service supports the following storage providers: - AWS (Amazon Web Services S3) - GCP (Google Cloud Storage) - Azure (Microsoft Azure Blob Storage) - Cloudinary - Local (local file system)

You can configure which provider to use per document or tenant.


Getting Started

Prerequisites

  • Java 17+
  • PostgreSQL
  • Gradle

Setup

git clone https://github.com/Olanna-tech/document-service-java.git
cd document-service-java
./gradlew build

Database

  • Configure your PostgreSQL credentials in src/main/resources/application.yml.
  • Run Flyway migrations (auto on startup).

Run

./gradlew bootRun

Cloud & Bucket Provider Integration

  • Set your credentials for AWS, GCP, Azure, or Cloudinary in application.yml as needed.
  • Documents can be stored and served from any supported provider or the local file system.

Contributing

Pull requests are welcome! For major changes, please open an issue first.


License

MIT


Contact