{"id":32525581,"url":"https://github.com/infinitypaul/laravel-dynamodb-auditing","last_synced_at":"2026-05-31T01:31:18.610Z","repository":{"id":320873966,"uuid":"1083605487","full_name":"infinitypaul/laravel-dynamodb-auditing","owner":"infinitypaul","description":"DynamoDB driver for Laravel Auditing package\"","archived":false,"fork":false,"pushed_at":"2025-10-26T12:05:13.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-26T14:18:11.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infinitypaul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-26T11:20:39.000Z","updated_at":"2025-10-26T12:02:39.000Z","dependencies_parsed_at":"2025-10-26T14:18:14.623Z","dependency_job_id":"7bf21363-b1c0-4d5b-b3b8-77bcf906f23d","html_url":"https://github.com/infinitypaul/laravel-dynamodb-auditing","commit_stats":null,"previous_names":["infinitypaul/laravel-dynamodb-auditing"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/infinitypaul/laravel-dynamodb-auditing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-dynamodb-auditing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-dynamodb-auditing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-dynamodb-auditing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-dynamodb-auditing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infinitypaul","download_url":"https://codeload.github.com/infinitypaul/laravel-dynamodb-auditing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-dynamodb-auditing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281418064,"owners_count":26497723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-28T09:50:57.022Z","updated_at":"2026-05-31T01:31:18.605Z","avatar_url":"https://github.com/infinitypaul.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel DynamoDB Auditing\n\nA DynamoDB driver for the [Laravel Auditing](https://github.com/owen-it/laravel-auditing) package, allowing you to store audit logs in AWS DynamoDB instead of a traditional database.\n\n## Features\n\n-  **High Performance**: Store audit logs in DynamoDB for better scalability\n-  **Auto-scaling**: DynamoDB handles scaling automatically\n-  **TTL Support**: Automatic cleanup of old audit logs\n-  **Flexible Schema**: NoSQL structure for varying audit data\n-  **Query Service**: Built-in service for querying audit logs\n-  **Laravel Integration**: Seamless integration with Laravel Auditing\n-  **Queue Support**: Optional queue processing for improved performance\n\n## Installation\n\n### 1. Install via Composer\n\n```bash\ncomposer require infinitypaul/laravel-dynamodb-auditing\n```\n\n### 2. Publish Configuration\n\n```bash\nphp artisan vendor:publish --tag=dynamodb-auditing-config\n```\n\n### 3. Configure Environment Variables\n\nAdd the following to your `.env` file:\n\n```env\n# Enable DynamoDB auditing\nAUDIT_DRIVER=dynamodb\n\n# DynamoDB Configuration\nDYNAMODB_AUDIT_TABLE=your-audit-table-name\nDYNAMODB_AUDIT_TTL_DAYS=730\nDYNAMODB_AUDIT_RECENT_DAYS=7\n\n# Queue Configuration (optional - improves performance)\nDYNAMODB_AUDIT_QUEUE_ENABLED=false\n# DYNAMODB_AUDIT_QUEUE_CONNECTION=redis  # Optional: override default queue connection\n# DYNAMODB_AUDIT_QUEUE_NAME=audits       # Optional: override default queue\n\n# AWS Credentials (production)\nAWS_ACCESS_KEY_ID=your-access-key\nAWS_SECRET_ACCESS_KEY=your-secret-key\nAWS_DEFAULT_REGION=us-east-1\n\n# Local Development (optional)\nDYNAMODB_ENDPOINT=http://localhost:8000\nDYNAMODB_ACCESS_KEY_ID=dummy\nDYNAMODB_SECRET_ACCESS_KEY=dummy\n```\n\n### 4. Configure Laravel Auditing Driver\n\nAdd the DynamoDB driver configuration to your `config/audit.php` file in the `drivers` array:\n\n```php\n'drivers' =\u003e [\n    'database' =\u003e [\n        'table' =\u003e 'audits',\n        'connection' =\u003e null,\n    ],\n    'dynamodb' =\u003e [\n        'table' =\u003e env('DYNAMODB_AUDIT_TABLE', 'your-audit-logs'),\n        'region' =\u003e env('DYNAMODB_REGION', env('AWS_DEFAULT_REGION', 'us-east-1')),\n    ],\n],\n```\n\n### 5. Create DynamoDB Table\n\n```bash\n# For local development\nphp artisan audit:setup-dynamodb --local\n\n# For production\nphp artisan audit:setup-dynamodb\n```\n\n## DynamoDB Table Structure\n\nThe package uses the following DynamoDB table structure:\n\n### Primary Key Design\n- **Partition Key (PK)**: `{auditable_type}#{auditable_id}` (e.g., `App\\Models\\Wallet#12345`)\n- **Sort Key (SK)**: `{timestamp}#{audit_id}` (for chronological ordering)\n\n### Global Secondary Index (GSI)\n- **CreatedAtIndex**: For recent audit browsing\n- **Partition Key**: `audit_type` (always \"AUDIT\")\n- **Sort Key**: `created_at` (timestamp)\n\n### Attributes\n- `audit_id` - Unique identifier for the audit\n- `user_id` - ID of the user who performed the action\n- `event` - Type of event (created, updated, deleted, etc.)\n- `auditable_type` - Model class name\n- `auditable_id` - Model ID\n- `old_values` - JSON of old values\n- `new_values` - JSON of new values\n- `url` - Request URL\n- `ip_address` - User's IP address\n- `user_agent` - User's browser/client\n- `created_at` - Timestamp\n- `TTL` - Time-to-live for automatic cleanup\n\n## Setup\n\n### Quick Setup (Recommended)\n\n```bash\n# Interactive installer - handles complete setup\nphp artisan audit:install-dynamodb\n\n# For local development\nphp artisan audit:install-dynamodb --local\n\n# Skip all confirmations\nphp artisan audit:install-dynamodb --local --force\n```\n\nThe installer automatically:\n- ✅ Checks for migration conflicts\n- ✅ Publishes configuration\n- ✅ Creates DynamoDB table with GSI\n- ✅ Tests the installation\n- ✅ Provides next steps\n\n### Manual Setup (Advanced)\n\nIf you prefer step-by-step control:\n\n#### 1. Create DynamoDB Table\n\n```bash\n# Setup local DynamoDB table (requires DynamoDB Local running on port 8000)\nphp artisan audit:setup-dynamodb --local\n\n# Or force recreate if table exists\nphp artisan audit:setup-dynamodb --local --force\n```\n\n#### 2. Test the Setup\n\n```bash\n# Test DynamoDB audit functionality\nphp artisan audit:test-dynamodb\n\n# Test with specific model\nphp artisan audit:test-dynamodb --model=\"App\\Models\\User\" --id=1\n```\n\n## Usage\n\n### Basic Usage\n\nOnce configured, the package works automatically with Laravel Auditing:\n\n```php\nuse OwenIt\\Auditing\\Contracts\\Auditable;\n\nclass User extends Model implements Auditable\n{\n    use \\OwenIt\\Auditing\\Auditable;\n    \n    // Your model code\n}\n```\n\n### Queue Processing (Recommended for Production)\n\nFor high-traffic applications, enable queue processing to improve performance:\n\n```env\n# Enable queue processing (uses your existing Laravel queue configuration)\nDYNAMODB_AUDIT_QUEUE_ENABLED=true\n\n# Optional: Override default queue settings\n# DYNAMODB_AUDIT_QUEUE_CONNECTION=redis  # Use specific queue connection\n# DYNAMODB_AUDIT_QUEUE_NAME=audits       # Use specific queue name\n```\n\n**Benefits of Queue Processing:**\n- **Faster Response Times**: Audit writes don't block user requests\n- **Better Scalability**: Handle high-volume audit operations\n- **Resilience**: Failed audit writes are automatically retried\n- **Non-blocking**: User operations continue even if DynamoDB is temporarily unavailable\n\n**Queue Worker Setup:**\n```bash\n# If using default queue configuration, just run your normal queue workers\nphp artisan queue:work\n\n# If using a specific queue name, target that queue\nphp artisan queue:work --queue=audits\n```\n\n**Note:** When queue processing is enabled, audit logs are processed asynchronously, so they may not be immediately available for querying.\n\n### Querying Audit Logs\n\nUse the provided `AuditQueryService`:\n\n```php\nuse InfinityPaul\\LaravelDynamoDbAuditing\\AuditQueryService;\n\n$auditService = app(AuditQueryService::class);\n\n// Get all audits with pagination\n$result = $auditService-\u003egetAllAudits(\n    limit: 25,\n    lastEvaluatedKey: null,\n    filters: [\n        'entity_type' =\u003e 'App\\\\Models\\\\Wallet',  // Required for fast search\n        'entity_id' =\u003e '12345',                  // Required for fast search\n        'start_date' =\u003e '2024-01-01T00:00:00',  // Optional date filtering\n        'end_date' =\u003e '2024-12-31T23:59:59',    // Optional date filtering\n    ]\n);\n\n```\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `AUDIT_DRIVER` | Audit driver to use | `database` |\n| `DYNAMODB_AUDIT_TABLE` | DynamoDB table name | `your-audit-logs` |\n| `DYNAMODB_AUDIT_TTL_DAYS` | Days before auto-deletion (null = infinite) | `730` |\n| `DYNAMODB_AUDIT_RECENT_DAYS` | Days to look back for recent audit browsing | `1` |\n| `DYNAMODB_AUDIT_QUEUE_ENABLED` | Enable queue processing for better performance | `false` |\n| `DYNAMODB_AUDIT_QUEUE_CONNECTION` | Queue connection to use (null = use default) | `null` |\n| `DYNAMODB_AUDIT_QUEUE_NAME` | Queue name for audit jobs (null = use default) | `null` |\n| `DYNAMODB_ENDPOINT` | Local DynamoDB endpoint | `null` |\n| `AWS_ACCESS_KEY_ID` | AWS access key | Required for production |\n| `AWS_SECRET_ACCESS_KEY` | AWS secret key | Required for production |\n| `AWS_DEFAULT_REGION` | AWS region | `us-east-1` |\n\n### Configuration File\n\nThe `config/dynamodb-auditing.php` file allows you to customize:\n\n- AWS credentials and region\n- Table name and TTL settings\n- Local vs production configurations\n\n### TTL (Time-To-Live) Configuration\n\nControl automatic cleanup of audit logs:\n\n```env\n# Auto-delete after 2 years (default)\nDYNAMODB_AUDIT_TTL_DAYS=730\n\n# Auto-delete after 1 year\nDYNAMODB_AUDIT_TTL_DAYS=365\n\n# Auto-delete after 30 days\nDYNAMODB_AUDIT_TTL_DAYS=30\n\n# Infinite retention (never auto-delete)\nDYNAMODB_AUDIT_TTL_DAYS=null\n```\n\n**Important**: Setting `DYNAMODB_AUDIT_TTL_DAYS=null` will keep audit logs forever, which may increase storage costs over time.\n\n## Performance Considerations\n\n### Why DynamoDB for Audit Logs?\n\n**DynamoDB excels at audit log storage because:**\n\n-  **Consistent Performance**: O(1) read/write operations regardless of table size\n-  **Horizontal Scaling**: Automatically scales to handle millions of records\n-  **Efficient Queries**: Partition + Sort key design enables fast lookups\n-  **No Performance Degradation**: Unlike SQL databases, performance doesn't degrade with table growth\n\n## Testing\n\nRun the package tests:\n\n```bash\ncomposer test\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Submit a pull request\n\n## Commands\n\nThe package provides several Artisan commands for setup and testing:\n\n| Command | Description | Options |\n|---------|-------------|---------|\n| `audit:install-dynamodb` | **🚀 Interactive installer - complete setup** | `--local`, `--production`, `--force` |\n| `audit:setup-dynamodb` | Create DynamoDB table with GSI for audit logs | `--local`, `--force` |\n| `audit:test-dynamodb` | Test DynamoDB audit functionality | `--model`, `--id` |\n| `audit:prevent-migration` | Remove conflicting MySQL audit migrations | `--check` |\n\n### Command Examples\n\n```bash\n# 🚀 RECOMMENDED: Interactive installer (does everything)\nphp artisan audit:install-dynamodb --local\n\n# Individual commands (if you prefer manual control)\nphp artisan audit:setup-dynamodb --local\nphp artisan audit:test-dynamodb\nphp artisan audit:prevent-migration --check\n\n# Advanced usage\nphp artisan audit:setup-dynamodb --force  # Force recreate table\nphp artisan audit:test-dynamodb --model=\"App\\Models\\Product\" --id=5\nphp artisan audit:prevent-migration       # Remove MySQL migrations\n```\n\n## Repository \u0026 Support\n\n- 📦 **GitHub Repository**: [https://github.com/infinitypaul/laravel-dynamodb-auditing](https://github.com/infinitypaul/laravel-dynamodb-auditing)\n- 📚 **Documentation**: Available in the repository\n- 🐛 **Issues \u0026 Bug Reports**: [GitHub Issues](https://github.com/infinitypaul/laravel-dynamodb-auditing/issues)\n- 💬 **Feature Requests**: [GitHub Issues](https://github.com/infinitypaul/laravel-dynamodb-auditing/issues)\n\n## License\n\nThis package is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitypaul%2Flaravel-dynamodb-auditing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinitypaul%2Flaravel-dynamodb-auditing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitypaul%2Flaravel-dynamodb-auditing/lists"}