# LockNKey Backend Developer Plugin

Expert backend development plugin for LockNKey password manager.

## Features

### 🛠️ Backend Development Tools
- **Supabase Integration**: PostgreSQL database, authentication, real-time subscriptions
- **Stripe Integration**: Payment processing, subscription management, webhooks
- **Pieces LTM**: Long-term memory for architectural decisions and code patterns

### 🎯 Specializations
- Python FastAPI for quantum encryption service
- Node.js Express for vault and collaboration services
- TDD (Test-Driven Development) methodology
- 1% Solution principle for efficient problem-solving
- Quantum-resistant cryptography implementation
- RESTful API design and security

### 🔧 MCP Servers
- `supabase`: PostgreSQL database management and Supabase features
- `stripe`: Payment processing and subscription management
- `Pieces`: Development decision memory and context

## Agent: developer

The `developer` agent provides:
- API endpoint development with FastAPI and Express
- Database schema design and migrations
- Payment integration with Stripe
- Quantum cryptography implementation
- TDD workflow with comprehensive test coverage
- Security best practices and vulnerability prevention

### Use Cases
- "Create API endpoints for password vault CRUD operations"
- "Design database schema for quantum-encrypted password storage"
- "Implement Stripe subscription with 3-tier pricing"
- "Build quantum key rotation background job"
- "Add Row-Level Security policies for multi-tenant isolation"

## Installation

```bash
/plugin marketplace add ./claude-marketplace
/plugin install lockkey-backend@lockkey-local-marketplace
```

After installation, restart Claude Code to activate the `developer` agent.

## Post-Installation Setup

**IMPORTANT**: After installation, you must update the agent's tool list with actual tool names:

1. Check available tools:
   ```bash
   /context
   ```

2. Look for tools starting with:
   - `mcp__plugin_lockkey-backend_supabase__*`
   - `mcp__plugin_lockkey-backend_stripe__*`

3. Update `agents/developer.md` tools field with actual tool names

### Supabase Setup

Ensure Supabase is running locally:
```bash
supabase start
# Supabase MCP server runs at: http://localhost:54321/mcp
```

The MCP endpoint includes features: `database`, `docs`, `development`

### Stripe Setup

The plugin uses Stripe test API key for development. Webhook events can be tested with:
```bash
stripe listen --forward-to localhost:3000/webhooks/stripe
```

## Verify Installation

```bash
/agents      # Should show developer
/mcp         # Should show supabase, stripe, Pieces servers
/context     # Check actual tool names → UPDATE AGENT
```

## Usage

The developer agent is available for backend development tasks:

```
@developer Implement the password vault encryption API:
- POST /vault/items - Create encrypted password entry
- GET /vault/items/:id - Retrieve and decrypt password
- PUT /vault/items/:id - Update encrypted password
- DELETE /vault/items/:id - Delete password entry
Use quantum-resistant encryption and include comprehensive tests
```

The agent will:
1. Write failing tests first (TDD RED phase)
2. Implement minimal working code (TDD GREEN phase)
3. Refactor for quality (TDD REFACTOR phase)
4. Add production hardening (error handling, security, performance)
5. Create API documentation

## LockNKey Context

The agent is pre-configured with LockNKey password manager context:
- Quantum-resistant cryptography (CRYSTALS-Kyber, Dilithium, SPHINCS+)
- Zero-knowledge architecture
- Supabase Auth integration
- Stripe subscription billing
- Browser extension backend APIs
- Secure sharing and collaboration
- TDD with 1% solution methodology

## TDD Workflow

The agent follows strict TDD methodology:

1. **RED**: Write failing test
2. **GREEN**: Minimal code to pass
3. **REFACTOR**: Improve code quality
4. **PRODUCTION**: Error handling, security, performance

**1% Solution Principle**: Always try minimal targeted fixes before complex refactoring.

## Technology Stack

### Python FastAPI (Quantum Service)
- Post-quantum cryptography algorithms
- Hybrid encryption (Kyber + AES-256-GCM)
- Digital signatures (Dilithium)
- Async operations for performance

### Node.js Express (Vault Service)
- Password CRUD operations
- Secure sharing and collaboration
- Browser extension APIs
- Real-time sync with WebSockets

### Supabase
- PostgreSQL database
- Row-Level Security (RLS)
- Authentication and authorization
- Real-time subscriptions
- Database functions and triggers

### Stripe
- Subscription management
- Payment processing
- Webhook handling
- Invoice generation
- Tax calculation

### Redis
- Session storage
- Key caching (7-day expiration)
- Rate limiting
- Message queues

## Development

Plugin structure:
```
lockkey-backend/
├── .mcp.json                      # MCP server configurations
├── .claude-plugin/
│   └── plugin.json                # Plugin metadata
├── agents/
│   └── developer.md              # Agent definition
└── README.md                      # This file
```

## Security Notes

- **Zero-Knowledge**: Server never sees plaintext passwords
- **Quantum-Resistant**: Post-quantum cryptography for future-proofing
- **Encrypted at Rest**: Database encryption enabled
- **Encrypted in Transit**: TLS for all communications
- **Input Validation**: Strict schema validation on all endpoints
- **Rate Limiting**: Protection against brute force attacks

## License

MIT License - LockNKey Team
