How keyshade-xyz/keyshade works
Main Components
• API Server (Backend): Located under apps/api, this service is written using NestJS and is responsible for handling requests related to secrets, environments, projects, and user management. It includes controllers (for API key, auth, environment, event, integration, secret, user, workspace, etc.), modules for core functionality, Prisma integration for database migrations, caching (with Redis), and external providers (like Minio and Redis).
• CLI Application: Found under apps/cli, this command‐line tool offers commands to manage environments, projects, secrets, variables, workspaces, and roles. It interacts with the backend API to perform many administrative and operational tasks.
• Platform (Dashboard): Under apps/platform, this Next.js-based frontend serves as the user dashboard. It offers features such as secret creation, secret revision screens, environment management views, and integration with the API backend.
• Web Application: Under apps/web, likely the marketing or informational website of keyshade, built also using Next.js with separate pages to describe the product, pricing, about, and other public assets.
• API Client Package: Found in packages/api-client, this Node.js client package provides a programmatic way for users to interact with keyshade’s API directly from their own applications.
• Additional Packages: Other packages like packages/schema (defining TypeScript types and schemas) and packages/secret-scan (which detects secrets in code) further extend the tool’s functionality and developer integrations.
Relationships and Data Flow
• The API Server acts as the central hub. It receives requests from the Platform (dashboard), the CLI, and the API Client as well as possibly from other integrated external services.
• The API server interacts with the database (managed via Prisma migrations) for persistent secret storage, project and workspace configuration, and history (revisioning) of secrets.
• Caching mechanisms (using Redis) are leveraged to improve performance on repeat queries.
• The secrets and variables are encrypted using public key encryption; the frontend dashboard and API server must be architected to safely handle encryption and decryption while ensuring the private key is never exposed.
• The CLI and API Client packages provide different interfaces to access the same functionality offered by the API server.
• The Web (marketing) application is largely read-only and informational and may also provide links or authentication routing to the Platform.
• External integrations (e.g., Slack, Discord, GitHub, GitLab, Google for OAuth) connect to the API server to allow operations such as authentication and notification.
Architectural Patterns and Design Principles
• Modularity: The backend is organized into separate modules corresponding to functional domains (e.g., secret management, project management, authentication, role management).
• Microservices-as-Packages: Although contained in a monorepo, the packages (api-client, schema, secret-scan) might be used independently or integrated into other systems.
• Secure Data Flow: Emphasize that secrets are encrypted end-to-end (both at rest and in transit) and that live updates propagate changes in real time to the runtime environments.