Skip to content

Commit ec8f478

Browse files
Abir Gangulyvaibhavbhalla2505
authored andcommitted
Kiro Power added
1 parent 84526a6 commit ec8f478

38 files changed

Lines changed: 3191 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ dist
1818
/docs/services/
1919

2020
## Compiled export script
21-
export-typedocs.js
21+
export-typedocs.js
22+
CLAUDE.md

powers/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ARC by SourceLoop - Kiro Powers
2+
3+
This directory contains [Kiro Powers](https://kiro.dev/powers/) for the ARC microservice catalog. Each power provides specialized context and tools to Kiro agents for working with SourceLoop services.
4+
5+
## Available Powers
6+
7+
| Power | Description |
8+
|-------|-------------|
9+
| [`sourceloop`](./sourceloop/) | Core ARC framework, CLI scaffolding, and LoopBack 4 patterns |
10+
| [`sourceloop-authentication-service`](./sourceloop-authentication-service/) | Multi-tenant authentication with OAuth, MFA, SAML, JWT |
11+
| [`sourceloop-oidc-service`](./sourceloop-oidc-service/) | OpenID Connect identity server |
12+
| [`sourceloop-audit-service`](./sourceloop-audit-service/) | Audit logging with S3 archival |
13+
| [`sourceloop-notification-service`](./sourceloop-notification-service/) | Multi-channel notifications (email, SMS, push, WebSocket) |
14+
| [`sourceloop-chat-service`](./sourceloop-chat-service/) | Real-time chat messaging with groups |
15+
| [`sourceloop-in-mail-service`](./sourceloop-in-mail-service/) | Incoming email management |
16+
| [`sourceloop-video-conferencing-service`](./sourceloop-video-conferencing-service/) | Video conferencing with Vonage and Twilio |
17+
| [`sourceloop-payment-service`](./sourceloop-payment-service/) | Payments via PayPal, Stripe, Razorpay |
18+
| [`sourceloop-bpmn-service`](./sourceloop-bpmn-service/) | BPMN workflows with Camunda |
19+
| [`sourceloop-task-service`](./sourceloop-task-service/) | Event-driven task management (Kafka/SQS/HTTP) |
20+
| [`sourceloop-scheduler-service`](./sourceloop-scheduler-service/) | Job scheduling and cron tasks |
21+
| [`sourceloop-search-service`](./sourceloop-search-service/) | Full-text search and filtering |
22+
| [`sourceloop-survey-service`](./sourceloop-survey-service/) | Surveys, questionnaires, and feedback |
23+
| [`sourceloop-feature-toggle-service`](./sourceloop-feature-toggle-service/) | Feature flags and toggles |
24+
| [`sourceloop-user-tenant-service`](./sourceloop-user-tenant-service/) | User and tenant management with RBAC |
25+
| [`sourceloop-reporting-service`](./sourceloop-reporting-service/) | Report generation with S3 export |
26+
27+
## Installing a Power
28+
29+
In Kiro IDE:
30+
31+
1. Open the Powers panel
32+
2. Click **Add power from GitHub**
33+
3. Enter the repository URL with the subdirectory path (e.g., `https://github.com/sourcefuse/loopback4-microservice-catalog/powers/sourceloop-authentication-service`)
34+
35+
For local development:
36+
37+
1. Open the Powers panel
38+
2. Click **Add power from Local Path**
39+
3. Select the power directory
40+
41+
## Power Structure
42+
43+
Each power contains:
44+
45+
```
46+
power-name/
47+
├── POWER.md # Metadata, documentation, and agent guidance
48+
└── mcp.json # MCP server configuration (points to @sourceloop/cli)
49+
```
50+
51+
The core `sourceloop` power also includes steering files:
52+
53+
```
54+
sourceloop/
55+
├── POWER.md
56+
├── mcp.json
57+
└── steering/
58+
├── loopback4-patterns.md # LoopBack 4 conventions and patterns
59+
└── cli-usage.md # ARC CLI command reference
60+
```
61+
62+
## MCP Server
63+
64+
All powers reference the `@sourceloop/cli` MCP server, which provides tools for:
65+
66+
- Scaffolding monorepos and microservices
67+
- Adding AWS CDK deployment support
68+
- Generating Angular and React frontends
69+
- Updating project dependencies
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
name: 'sourceloop-audit-service'
3+
displayName: 'SourceLoop Audit Service'
4+
description: 'Track and record user actions with audit logging - inserts, updates, deletes with S3 archival and CSV export capabilities'
5+
keywords:
6+
[
7+
'audit',
8+
'logging',
9+
'audit-trail',
10+
'compliance',
11+
'tracking',
12+
'sourceloop',
13+
's3-archival',
14+
]
15+
author: 'SourceFuse'
16+
---
17+
18+
# SourceLoop Audit Service
19+
20+
## Overview
21+
22+
A LoopBack 4 microservice for audit logging that tracks and records user actions including inserts, updates, and deletes. Supports S3 archival for long-term storage and CSV export capabilities.
23+
24+
**Key capabilities:**
25+
26+
- **Action Tracking**: Record inserts, updates, and deletes across services
27+
- **S3 Archival**: Archive audit logs to AWS S3 for compliance
28+
- **CSV Export**: Export audit data as CSV via ExcelJS
29+
- **Repository Mixin**: Drop-in audit logging for any repository
30+
- **Multi-source Retrieval**: Query from both database and archive
31+
32+
## Available MCP Servers
33+
34+
### sourceloop-cli
35+
36+
**Package:** `@sourceloop/cli`
37+
**Connection:** Local stdio via npx
38+
39+
Use the `microservice` tool with `--baseOnService --baseService=audit-service` to scaffold a new audit service instance.
40+
41+
## Installation
42+
43+
```typescript
44+
import {AuditServiceComponent} from '@sourceloop/audit-service';
45+
import {BootMixin} from '@loopback/boot';
46+
import {ApplicationConfig} from '@loopback/core';
47+
import {RestApplication} from '@loopback/rest';
48+
49+
export class MyApplication extends BootMixin(RestApplication) {
50+
constructor(options: ApplicationConfig = {}) {
51+
super(options);
52+
53+
// Validate required environment variables
54+
this.validateAuditEnv();
55+
56+
try {
57+
this.component(AuditServiceComponent);
58+
console.log('✅ Audit service loaded successfully');
59+
} catch (error) {
60+
console.error('❌ Failed to initialize audit service:', error.message);
61+
throw error;
62+
}
63+
}
64+
65+
private validateAuditEnv() {
66+
const required = ['DB_HOST', 'DB_PORT', 'DB_DATABASE'];
67+
const missing = required.filter(env => !process.env[env]);
68+
if (missing.length > 0) {
69+
throw new Error(
70+
`Missing required environment variables: ${missing.join(', ')}`,
71+
);
72+
}
73+
74+
// Validate S3 config if archival is enabled
75+
if (process.env.ENABLE_ARCHIVAL === 'true') {
76+
const s3Required = [
77+
'AWS_ACCESS_KEY_ID',
78+
'AWS_SECRET_ACCESS_KEY',
79+
'S3_BUCKET_NAME',
80+
];
81+
const s3Missing = s3Required.filter(env => !process.env[env]);
82+
if (s3Missing.length > 0) {
83+
throw new Error(
84+
`S3 archival enabled but missing: ${s3Missing.join(', ')}`,
85+
);
86+
}
87+
}
88+
}
89+
}
90+
```
91+
92+
## Key Models
93+
94+
- **AuditLog** - Core audit log entry with action, actor, timestamp, before/after data
95+
- **CustomFilter** - Custom query filters for audit retrieval
96+
- **MappingLog** - Entity mapping audit records
97+
- **Job** - Background archival job tracking
98+
99+
## Key Controllers
100+
101+
- **AuditController** - CRUD operations for audit logs, export, archival
102+
103+
## Common Workflows
104+
105+
### Workflow 1: Setup Audit Service
106+
107+
```bash
108+
npx @sourceloop/cli microservice my-audit \
109+
--baseOnService \
110+
--baseService=audit-service \
111+
--datasourceName=auditdb \
112+
--datasourceType=postgresql \
113+
--includeMigrations
114+
```
115+
116+
### Workflow 2: Add Audit Logging to a Repository
117+
118+
Use the audit mixin from `@sourceloop/audit-log`:
119+
120+
```typescript
121+
import {AuditRepositoryMixin} from '@sourceloop/audit-log';
122+
123+
export class MyEntityRepository extends AuditRepositoryMixin<
124+
MyEntity,
125+
typeof MyEntity.prototype.id,
126+
MyEntityRelations
127+
>(DefaultCrudRepository) {
128+
constructor(@inject('datasources.db') dataSource: DataSource) {
129+
super(MyEntity, dataSource);
130+
}
131+
}
132+
```
133+
134+
## Best Practices
135+
136+
### Do:
137+
138+
- Archive old audit logs to S3 for cost-effective long-term storage
139+
- Use the repository mixin for automatic audit logging
140+
- Index audit logs by actor, action type, and timestamp
141+
- Configure retention policies for compliance requirements
142+
143+
### Don't:
144+
145+
- Store sensitive data (passwords, tokens) in audit log details
146+
- Skip audit logging for delete operations
147+
- Query large audit datasets without filters - use pagination
148+
149+
## Database
150+
151+
Requires PostgreSQL. Run migrations:
152+
153+
```bash
154+
npx db-migrate up --config database.json --migrations-dir migrations
155+
```
156+
157+
## Dependencies
158+
159+
- `@sourceloop/core`
160+
- `@sourceloop/audit-log`
161+
- `exceljs` (CSV export)
162+
- `csvtojson`
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"mcpServers": {
3+
"sourceloop-cli": {
4+
"command": "npx",
5+
"args": ["-y", "@sourceloop/cli", "mcp"],
6+
"env": {}
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)