Metadata-Version: 2.4
Name: n1-document-manager
Version: 0.1.0
Summary: Unified storage library for S3 and GCS with N1-specific path conventions
Author-email: N1 Healthcare <dev@n1.care>
License: Proprietary
Requires-Python: >=3.10
Requires-Dist: boto3>=1.28.0
Requires-Dist: google-cloud-storage>=2.10.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: moto[s3]>=4.2.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# N1 Document Manager

Unified storage library for S3 and GCS with N1 path conventions.

## Installation

```bash
pip install n1r-document-manager
```

## Quick Start

```python
from n1_document_manager import DocumentManager, StorageConfig

# S3
config = StorageConfig(provider="s3", bucket_name="n1-staging-user-data")
manager = DocumentManager(config)

# Upload
path = DocumentManager.user_path("user-123", "record", "mr-456", "doc.pdf")
with open("doc.pdf", "rb") as f:
    manager.upload_file(f, path)

# Signed URL
url = manager.get_signed_url(path)
```

## Configuration

Set via environment variables:

```bash
export STORAGE_PROVIDER=s3          # or "gcs"
export BUCKET_NAME=n1-staging-user-data
export AWS_REGION=us-east-2
```

Or pass directly:

```python
config = StorageConfig(
    provider="s3",
    bucket_name="n1-staging-user-data",
    aws_region="us-east-2",
)
```

## Bucket Names

| Provider | Staging | Production |
|----------|---------|------------|
| S3 | `n1-staging-user-data` | `n1-prod-user-data` |
| GCS | `dev-n1-bucket-us` | `prod-n1-bucket-us` |

## Path Convention

All files use: `users/{user_id}/{object_type}/{type_id}/{filename}`

```python
path = DocumentManager.user_path("user-123", "record", "mr-456", "file.pdf")
# Result: "users/user-123/record/mr-456/file.pdf"
```

## Integration

**KEEP IT SIMPLE** - Replace your storage module with DocumentManager:

```python
from n1_document_manager import DocumentManager, StorageConfig

config = StorageConfig(
    provider="s3",
    bucket_name=os.getenv("BUCKET_NAME"),
)
manager = DocumentManager(config)

# Upload
manager.upload_file(file_obj, path)

# Download
manager.download_file(path, local_path)

# Signed URL
url = manager.get_signed_url(path)

# Delete
manager.delete_file(path)
```

## Docs

See `docs/` for full documentation.

## License

Proprietary - N1 Healthcare
