Skip to content

Conversation

Copy link

Copilot AI commented Oct 26, 2025

Implements a production-ready object storage service with multi-tenant namespace isolation, resumable uploads for large files, and complete audit trails per the 001-modern-storage-service specification.

Architecture

Storage Layer

  • PostgreSQL + TypeORM for metadata (Namespace, Object, UploadSession, AuditEvent entities)
  • S3-compatible binary storage (MinIO local, AWS S3 production) via AWS SDK v3
  • Pre-signed URLs for time-limited upload/download access

Multi-tenancy

  • Namespace-scoped isolation with per-tenant quotas (bytes + object count)
  • Automatic usage tracking with increment/decrement on object lifecycle
  • Soft delete with deletedAt timestamp for recovery workflows

Resumable Uploads

  • S3 multipart API with session tracking in PostgreSQL
  • 7-day session expiration with cleanup capability
  • SHA-256 checksum validation at S3 layer
  • Idempotent initiation (returns existing session if in progress)

API Surface (12 endpoints)

// Namespace management
POST   /api/v1/namespaces
GET    /api/v1/namespaces/:name

// Object operations
POST   /api/v1/objects                          // Returns pre-signed upload URL
GET    /api/v1/objects/:id
POST   /api/v1/objects/:id/signed-url           // Generates download URL (60s-7d)
DELETE /api/v1/objects/:id                      // Soft delete
GET    /api/v1/namespaces/:namespace/objects    // Paginated list with prefix filter

// Multipart uploads
POST   /api/v1/uploads/initiate
PUT    /api/v1/uploads/:sessionId/parts/:partNumber
POST   /api/v1/uploads/:sessionId/complete

// Health
GET    /api/v1/health/live
GET    /api/v1/health/ready                     // DB + S3 connectivity check

Example Usage

# Create namespace
curl -X POST /api/v1/namespaces -d '{
  "name": "org-acme",
  "quotaBytes": 1073741824
}'

# Create object, get pre-signed upload URL
curl -X POST /api/v1/objects -d '{
  "namespace": "org-acme",
  "name": "invoice.pdf",
  "contentType": "application/pdf",
  "sizeBytes": 2048576
}'
# Response includes 15-min pre-signed URL for PUT upload

# Generate download URL
curl -X POST /api/v1/objects/{id}/signed-url -d '{
  "expiresIn": 3600
}'

Configuration

Added database, Redis, and enhanced storage config:

// config.interface.ts
interface DatabaseConfig {
  host: string;
  port: number;
  username: string;
  password: string;
  database: string;
  synchronize: boolean;  // Auto-migrations for dev
}

Docker Compose extended with PostgreSQL and Redis services. Environment template includes all required variables.

Security

  • Input validation via class-validator DTOs
  • Credential masking in config logging (fixed CodeQL alert)
  • Namespace isolation at query level
  • Pre-signed URL expiration enforcement

Notes

  • Tests not included per spec (no explicit test requirements)
  • Cleanup job method exists but not scheduled (Bull queue integration deferred)
  • TypeORM synchronize enabled for development (production should use migrations)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • scarf.sh
    • Triggering command: node ./report.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

implement 001-modern-storage-service


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Oct 26, 2025
Co-authored-by: npsg02 <150496964+npsg02@users.noreply.github.com>
Copilot AI and others added 5 commits October 26, 2025 14:00
…ry 1

Co-authored-by: npsg02 <150496964+npsg02@users.noreply.github.com>
Co-authored-by: npsg02 <150496964+npsg02@users.noreply.github.com>
Co-authored-by: npsg02 <150496964+npsg02@users.noreply.github.com>
Co-authored-by: npsg02 <150496964+npsg02@users.noreply.github.com>
Co-authored-by: npsg02 <150496964+npsg02@users.noreply.github.com>
@sonarqubecloud
Copy link

Copilot AI changed the title [WIP] Implement modern storage service Implement modern storage service with namespace isolation, multipart uploads, and audit logging Oct 26, 2025
Copilot AI requested a review from npsg02 October 26, 2025 14:13
Copilot finished work on behalf of npsg02 October 26, 2025 14:13
@npsg02 npsg02 changed the base branch from main to feat/storage-service October 26, 2025 15:06
@npsg02 npsg02 marked this pull request as ready for review October 26, 2025 15:06
@npsg02 npsg02 merged commit 38d6f0a into feat/storage-service Oct 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants