# io8 System Architect Agent - Customized for This Project

## Project-Specific Instructions

```json
{
  "file_creation": [
    {
      "file_path": ".sureai/.io8architect_agent_password_generator_password_generator_20251010_054000.md",
      "content": "# io8Architect Agent Prompt: Password Generator Project\n\n**Project Name:** Password Generator\n**Timestamp:** 2025-10-10 05:40:00\n\n## 1. Project Context and Goal\n\nAs the io8Architect, your primary goal is to design a secure, scalable, and maintainable architecture for the \"Password Generator\" project. This involves integrating a new password generation feature into an existing Angular Clarity Boilerplate frontend and designing a robust, secure backend microservice. Adherence to the \"Security First\" principle and modularity, as outlined in the `io8codermaster_breakdown.md` and `analysis_document.md`, is paramount.\n\n## 2. Architecture Design Methodology\n\nYour design process will follow a hybrid approach:\n\n*   **Evolutionary Design for Frontend:** Extend the existing Angular Clarity Boilerplate (`analysis_document.md`, `requirements_document.md`) by adding new feature modules, components, and services to accommodate the password generator UI.\n*   **Greenfield Design for Backend:** Design a new, independent backend service specifically for secure password generation, adhering to microservice principles for clear separation of concerns and independent scalability.\n*   **Security-Driven Design:** Prioritize security from the ground up, particularly for the backend's generation logic and API communication. Implement best practices for randomness, input validation, and secure data handling.\n*   **API-First Approach:** Define the clear contract between the frontend and backend through a well-specified RESTful API.\n*   **Document-Driven:** Continuously reference `analysis_document.md` and `requirements_document.md` to ensure all functional and non-functional requirements (especially security-related ones) are met in the architectural design.\n\n## 3. Technical Architecture Approach\n\n### Frontend Architecture (Building on Angular Clarity Boilerplate)\n*   **Modular Features:** Create a dedicated lazy-loaded Angular `FeatureModule` (e.g., `PasswordGeneratorModule`) to encapsulate all UI components, services, and routing related to password generation.\n*   **Component Structure:** Design clear components for:\n    *   Password parameter input (length, character types, exclusion).\n    *   Password display and feedback.\n    *   Copy-to-clipboard functionality.\n*   **State Management:** Utilize Angular's service-based approach for managing UI state and interactions with the backend API.\n*   **API Interaction:** Leverage Angular's `HttpClient` within a dedicated service (e.g., `PasswordApiService`) in the `CoreModule` or `PasswordGeneratorModule` to abstract backend communication.\n\n### Backend Architecture (New Microservice)\n*   **Stateless Microservice:** The backend will be a stateless service responsible *only* for generating passwords based on provided parameters. It *must not* store generated passwords or user-specific data.\n*   **API Gateway (Conceptual):** While not a full-fledged API Gateway for this small project, the single backend endpoint will serve as the entry point for all generation requests.\n*   **Secure Generation Logic:** Implement the core password generation algorithm using a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) and robust character set handling.\n*   **Input Validation:** Strict server-side validation of all incoming parameters to prevent invalid inputs or potential attacks.\n\n## 4. System Design Framework\n\n*   **Microservices Pattern:** Apply the microservice pattern to separate the password generation logic into an independent deployable unit, distinct from the frontend boilerplate.\n*   **RESTful API Principles:** Design the API endpoints, methods, request/response payloads, and status codes following RESTful best practices for clear, predictable interaction.\n*   **Layered Architecture (within backend):** Structure the backend service into distinct layers (e.g., API layer, service/logic layer, utility layer for randomness) to enhance maintainability and testability.\n\n## 5. Technology Selection Strategy\n\n*   **Frontend:** Continue with **Angular** and **VMware Clarity Design System** as per the base project. Utilize standard Angular CLI, TypeScript, and RxJS for reactive programming.\n*   **Backend:** Select a modern, lightweight, and secure language/framework for the backend that is well-suited for a stateless API. **Python with Flask/FastAPI** or **Node.js with Express/Fastify** are strong candidates due to their efficiency and extensive library support for cryptographic operations.\n*   **API Communication:** **HTTPS** for secure transport. **JSON** for request/response bodies.\n*   **Deployment:** Containerization with **Docker** for both frontend (optional, for consistency) and backend, allowing for flexible deployment to cloud platforms (e.g., AWS Lambda/ECS, GCP Cloud Run/App Engine, Azure App Services) that support stateless microservices.\n\n## 6. Customized io8Architect Workflow\n\n1.  **Document Analysis (Current Step):** Thoroughly review `analysis_document.md`, `requirements_document.md`, and `io8codermaster_breakdown.md` for project context, existing architecture, functional/non-functional requirements (especially security, modularity, no password storage), and user stories.\n2.  **Frontend Extension Design:** Detail how the password generator UI will integrate into the existing Angular Clarity boilerplate:\n    *   Identify necessary new `FeatureModule(s)`, components, and services.\n    *   Sketch UI wireframes (conceptual) based on user stories in `analysis_document.md`.\n    *   Outline routing configurations.\n3.  **Backend Microservice Design:** Define the independent backend service:\n    *   Specify the secure password generation algorithm requirements (CSPRNG, character sets, exclusion).\n    *   Design the RESTful API contract (endpoints, request/response schemas, error handling).\n    *   Outline security measures (input validation, rate limiting, secure communication).\n4.  **Overall System Architecture:** Create a high-level system overview showing the interaction between the Angular frontend, the new backend microservice, and external interfaces.\n5.  **Technology Stack Selection & Justification:** Finalize technology choices for the backend and justify them based on requirements, performance, security, and maintainability.\n6.  **Documentation Generation:**\n    *   **Append** detailed architecture content to `.sureai/architecture_document.md` with clear, timestamped sections.\n    *   **Append** detailed technology stack content to `.sureai/tech_stack_document.md` with clear, timestamped sections.\n    *   Ensure all new content builds upon the existing boilerplate documentation and adheres to the `io8` guidelines.\n7.  **Review & Refinement:** Verify that the proposed architecture addresses all requirements, particularly the non-functional ones like security, performance, and scalability, and is actionable for subsequent agents.\n\nThis customized prompt ensures a focused architectural design that leverages the existing base project while introducing a secure, independent backend for the password generation feature, aligning with the "Security First" and modularity principles."
    }
  ],
  "architecture": "\n# Architecture Document\nGenerated: 2025-10-10T05:40:00.080312\n\n## System Overview - Password Generator (2025-10-10 06:15:00)\n\nThe Password Generator system is an enhancement to the existing Angular Clarity Boilerplate, transforming it into a functional, secure web application. It comprises a modern frontend built on Angular with the Clarity Design System, handling user interaction for password parameter selection, and a distinct, stateless backend microservice responsible for cryptographically secure password generation. The frontend and backend communicate via a RESTful API over HTTPS, ensuring data integrity and confidentiality. The system prioritizes security by generating truly random passwords on the server and never storing them.\n\n## Architecture Pattern - Password Generator (2025-10-10 06:15:00)\n\nThe architecture combines two primary patterns:\n\n1.  **Client-Server (Frontend as Client):** The Angular Clarity application acts as a rich client, providing the user interface and handling client-side logic and interactions. It consumes services from the backend.\n2.  **Microservice (Backend):** The password generation logic is encapsulated within a dedicated, stateless backend microservice. This allows for independent development, deployment, and scaling of the secure generation component, aligning with the modular architecture principle of the base project and enhancing the focus on security for this critical function. Communication between client and microservice is via a RESTful API.\n\n## Component Design - Password Generator (2025-10-10 06:15:00)\n\n### Frontend Components (within Angular Clarity Boilerplate)\n*   **`PasswordGeneratorModule` (Lazy-Loaded Feature Module):** Encapsulates all password generation-specific functionality.\n    *   **`PasswordFormComponent`:** Handles user input for password parameters (length slider/input, checkboxes for character sets - uppercase, lowercase, numbers, symbols, exclusion input). Implements client-side validation for parameters.\n    *   **`GeneratedPasswordDisplayComponent`:** Displays the generated password securely (e.g., using a non-input field to prevent accidental modification, with a toggle to show/hide for privacy). Provides a \"Copy to Clipboard\" button.\n    *   **`PasswordApiService`:** A service responsible for making HTTP requests to the backend password generation API. Handles request/response mapping and error handling.\n    *   **`CoreModule` Extensions:** May include an `HttpInterceptor` to globally handle API errors or add authentication headers (though authentication is out of scope for v1, the capability is considered).\n\n### Backend Components (New Microservice)\n*   **`PasswordGeneratorService`:** The core business logic component responsible for:\n    *   Receiving password generation parameters from the API.\n    *   Validating input parameters rigorously (e.g., length range, character set validity).\n    *   Utilizing a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) to select characters.\n    *   Constructing the password string based on specified length, character sets, and exclusion rules.\n*   **`PasswordGenerationAPIController`:** Exposes a single, secure RESTful endpoint (e.g., `/api/generate-password`) for the frontend to request password generation. Handles HTTP requests, calls the `PasswordGeneratorService`, and returns the generated password.\n*   **`SecurityMiddleware`:** (If applicable to chosen framework) Handles concerns like CORS, input sanitization, and potentially rate limiting to protect the API.\n\n## Data Architecture - Password Generator (2025-10-10 06:15:00)\n\nConsistent with the non-functional requirement \"No Password Storage,\" this system will have a **stateless data architecture** for password generation. No persistent storage (database, file system, session) will be used for generated passwords or user-specific generation parameters.\n\n*   **Frontend Data:** Password generation parameters are temporarily held in component state. The generated password string is held temporarily for display and copying.\n*   **Backend Data:** The backend service processes incoming parameters in memory during a request cycle. The generated password string is constructed in memory and immediately sent back in the API response. No data is stored between requests.\n\n### Data Elements:\n*   **Password Parameters (Request):** `length` (integer), `includeUppercase` (boolean), `includeLowercase` (boolean), `includeNumbers` (boolean), `includeSymbols` (boolean), `excludeCharacters` (string - optional).\n*   **Generated Password (Response):** `password` (string).\n\n## API Design - Password Generator (2025-10-10 06:15:00)\n\n### Endpoint:\n*   **`POST /api/generate-password`**\n    *   **Purpose:** To request a cryptographically secure password based on specified parameters.\n    *   **Request Body (JSON):**\n        ```json\n        {\n          \"length\": 16,\n          \"includeUppercase\": true,\n          \"includeLowercase\": true,\n          \"includeNumbers\": true,\n          \"includeSymbols\": false,\n          \"excludeCharacters\": \"\" \n        }\n        ```\n    *   **Response Body (JSON - Success 200 OK):**\n        ```json\n        {\n          \"password\": \"ExampleP@ssw0rd!\"\n        }\n        ```\n    *   **Response Body (JSON - Error 400 Bad Request):**\n        ```json\n        {\n          \"error\": \"Invalid parameters\",\n          \"details\": \"Password length must be between 4 and 128 characters.\"\n        }\n        ```\n    *   **Response Body (JSON - Error 500 Internal Server Error):**\n        ```json\n        {\n          \"error\": \"Internal server error\",\n          \"details\": \"An unexpected error occurred during password generation.\"\n        }\n        ```\n\n### API Design Principles:\n*   **Stateless:** The API is stateless; each request contains all necessary information.\n*   **Secure Communication:** All API communication will be over HTTPS.\n*   **CORS:** Appropriate Cross-Origin Resource Sharing (CORS) headers will be configured on the backend to allow requests only from the deployed frontend origin.\n*   **Validation:** Robust server-side input validation for all parameters.\n*   **Clear Error Messages:** Provide informative error messages for client-side debugging and user feedback.\n\n## Security Architecture - Password Generator (2025-10-10 06:15:00)\n\nSecurity is the paramount non-functional requirement for the Password Generator. The design incorporates security at multiple layers:\n\n1.  **Cryptographically Secure Randomness (Backend):**\n    *   Utilize the operating system's or programming language's built-in Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) (e.g., Python's `secrets` module, Node.js `crypto` module) for character selection. This is critical to ensure true randomness and prevent predictable passwords.\n    *   Avoid general-purpose `Math.random()` or similar pseudo-random generators.\n2.  **No Password Storage (Frontend & Backend):** Explicitly enforce that generated passwords are never logged, stored in databases, caches, session storage, local storage, or transmitted to any third-party services. They exist only in memory for the duration of display/copy operation.\n3.  **Secure API Communication (HTTPS):** All communication between the Angular frontend and the backend API will be encrypted using HTTPS to prevent eavesdropping and Man-in-the-Middle attacks.\n4.  **Input Validation (Backend):** Implement strict server-side validation for all incoming password generation parameters (e.g., minimum/maximum length, valid character set selections) to prevent denial-of-service attacks, injection attempts, or generation of overly simplistic passwords due to malformed requests.\n5.  **CORS Configuration (Backend):** Configure the backend API to accept requests only from trusted origins (the deployed frontend application) to prevent cross-site request forgery (CSRF) and other unauthorized access attempts.\n6.  **Environment Variable Management:** Critical configurations (e.g., allowed origins for CORS) will be managed via environment variables and not hardcoded.\n7.  **Minimal Dependencies:** Choose backend libraries with a strong security track record and keep the dependency tree minimal to reduce potential attack surfaces.\n8.  **Regular Security Audits:** (Operational, but considered in design) The code will be structured to facilitate easy security reviews.\n\n## Scalability Considerations - Password Generator (2025-10-10 06:15:00)\n\n1.  **Backend Horizontal Scaling:** The stateless nature of the backend microservice allows for easy horizontal scaling. Multiple instances of the service can run behind a load balancer, distributing requests and handling increased traffic without complex session management.\n2.  **Frontend Scalability:** The existing Angular Clarity boilerplate provides a scalable foundation. Lazy-loaded feature modules ensure that only necessary code is loaded, optimizing initial load times. Subsequent feature additions for the password generator will follow this pattern.\n3.  **API Performance:** The password generation logic is designed to be efficient. For typical password lengths, generation should be very fast, minimizing latency. The API is lightweight, primarily focused on computation rather than I/O-heavy operations.\n4.  **Containerization:** Using Docker for the backend (and potentially frontend) facilitates consistent deployment across different environments and simplifies scaling on container orchestration platforms (e.g., Kubernetes, AWS ECS/EKS, GCP GKE, Azure AKS).\n",
  "tech_stack": "\n# Technology Stack Document\nGenerated: 2025-10-10T05:40:00.080312\n\n## Frontend Technologies - Password Generator (2025-10-10 06:15:00)\n-   **Framework:** Angular (v12+ as per base project)\n-   **Styling:** VMware Clarity Design System (CSS framework and components)\n-   **State Management:** Angular Services (for component communication and API interaction)\n-   **Reactive Programming:** RxJS (for handling asynchronous operations and events)\n-   **HTTP Client:** Angular's `HttpClient` module for backend API communication.\n\n## Backend Technologies - Password Generator (2025-10-10 06:15:00)\n-   **Language:** Python\n-   **Framework:** Flask (lightweight and suitable for a single-purpose microservice)\n-   **API:** RESTful API with JSON data format\n-   **Randomness:** Python's `secrets` module (for cryptographically secure random number generation)\n-   **Web Server Gateway Interface (WSGI):** Gunicorn (for production deployment of Flask app)\n\n## Database Technologies - Password Generator (2025-10-10 06:15:00)\n-   **Primary Database:** *No database required* (Explicitly adheres to the \"No Password Storage\" non-functional requirement).\n-   **Caching:** *No caching required* (Stateless service).\n\n## Infrastructure - Password Generator (2025-10-10 06:15:00)\n-   **Deployment:** Docker (for containerizing the backend microservice and potentially the frontend for consistent environment).\n-   **Hosting (Backend):** Cloud Platform options (e.g., AWS Lambda, AWS ECS/Fargate, Google Cloud Run, Azure App Services) for stateless microservice deployment.\n-   **Hosting (Frontend):** Static site hosting on a CDN (e.g., AWS S3 + CloudFront, Google Cloud Storage, Netlify).\n\n## Development Tools - Password Generator (2025-10-10 06:15:00)\n-   **Version Control:** Git\n-   **Testing (Frontend):** Karma, Jasmine\n-   **Testing (Backend):** Pytest (for unit and integration testing of the Flask application and generation logic)\n-   **CI/CD:** GitHub Actions / GitLab CI / Jenkins (for automated testing and deployment pipelines for both frontend and backend).\n-   **IDE:** VS Code (or similar with Angular/Python extensions)\n"
}
```

## Base Agent Prompt Reference

This agent is based on the standard io8architect agent with project-specific customizations above.
Refer to the base io8architect agent prompt for general principles and workflow instructions.
