# io8 Project Manager Agent - Customized for This Project

## Project-Specific Instructions

```markdown
# io8 Product Manager (PM) Agent Instructions for "Messaging App" Project

**Project Name:** Messaging App
**User Prompt:** messaging app
**Timestamp:** 2025-10-10_040350

## 1. Project Management Methodology

For the "Messaging App" project, an **Agile Scrum-based methodology with a strong MVP (Minimum Viable Product) focus** will be employed. This approach is ideal for real-time communication applications as it allows for iterative development, continuous feedback, and rapid adaptation to user needs and technical challenges inherent in building scalable real-time systems.

*   **Iterations:** Short sprints (e.g., 2-week cycles) to deliver demonstrable increments of the product.
*   **Prioritization:** Backlog grooming and prioritization based on business value, technical feasibility, and alignment with the product vision, emphasizing core MVP features first (1:1 chat, authentication, persistence).
*   **Flexibility:** Adapt to emerging requirements and technical insights, especially concerning real-time performance and scalability.
*   **Transparency:** Regular stand-ups, sprint reviews, and retrospectives to ensure all stakeholders are informed and aligned.

## 2. PRD Development Approach

The Product Requirements Document (PRD) for the "Messaging App" will be a living document, iteratively refined throughout the project lifecycle. Initially, it will focus on defining the core MVP features, as detailed in the `analysis_document.md`, `architecture_document.md`, and `tech_stack_document.md` reference files.

*   **User-Centric Focus:** All requirements will be framed from the perspective of the end-user (messaging app user), as well as developers using the underlying boilerplate (for extensibility).
*   **Phased Definition:** The PRD will clearly delineate MVP features (Phase 1: User Auth, 1:1 Chat, Persistence) from future enhancements (Phase 2: Group Chat, Notifications, Media Sharing), aligning with the project phases identified in `analysis_document.md`'s "Project Phases and Milestones."
*   **Detailed Epic and User Stories:** Each major feature area will be broken down into Epics, which will further decompose into granular User Stories with clear "As a... I want... So that..." statements, acceptance criteria, story points, and priority. This level of detail is critical for development teams.
*   **Traceability:** Requirements will be linked to business objectives, technical architecture, and testing plans to ensure comprehensive coverage.
*   **Append-Only:** Consistent with the project's base handling instructions, all updates to `.sureai/prd_document.md` will be appended with clear section headers and timestamps.

## 3. Project Planning Framework

The project planning will be structured around key phases and milestones, ensuring a systematic approach from conception to deployment.

*   **Phased Delivery:** The project will be executed in phases, as outlined in the `analysis_document.md` ("Update: Project Phases and Milestones").
    *   **Phase 1: Discovery & Architecture (Completed by io8architect/analyst, PRD is key output)**
    *   **Phase 2: Core Messaging MVP Development** (Focus on Auth, 1:1 Chat, Persistence)
    *   **Phase 3: Feature Expansion & Quality Assurance** (Group Chat, Notifications, Media, Testing)
    *   **Phase 4: Deployment Readiness & Operations** (CI/CD, Monitoring)
*   **Work Breakdown Structure (WBS):** Epics and User Stories from the PRD will form the basis of the WBS, providing detailed tasks for the development team.
*   **Resource Allocation:** Identify required roles (frontend, backend, DevOps, QA) and estimated efforts (Story Points).
*   **Risk Management:** Continuously monitor and address identified risks (Scalability, Performance, Security, Integration, Scope Creep) as per `analysis_document.md`'s "Initial Risk Assessment Summary."

## 4. Timeline and Milestone Strategy

The project will follow a time-boxed approach, with clear milestones defining the completion of major feature sets.

*   **Milestone 1 (MVP Completion):** Deliver fully functional User Authentication, User Profile Management, One-to-One Real-time Messaging, and Message Persistence.
    *   **Target:** End of Phase 2.
    *   **Success Criteria:** All core 1:1 chat user stories are shippable, secure, and performant.
*   **Milestone 2 (Feature Expansion):** Deliver Group Chat, Real-time Notifications, and initial Media Sharing capabilities.
    *   **Target:** End of Phase 3.
    *   **Success Criteria:** New features are integrated, stable, and tested.
*   **Milestone 3 (Deployment Readiness):** Establish production-ready deployment, CI/CD, monitoring, and logging.
    *   **Target:** End of Phase 4.
    *   **Success Criteria:** Application is deployed to a staging environment, passes all E2E tests, and operational tools are in place.

Story points will be used for estimation within sprints, and release planning will align with these larger milestones.

## 5. Customized io8pm Workflow for "Messaging App"

1.  **Review & Synthesize:** Thoroughly review the `analysis_document.md`, `architecture_document.md`, and `tech_stack_document.md` for the "Messaging App" to ensure a deep understanding of the project's current state, requirements, and technical foundations.
2.  **Define Core PRD Sections:** Populate all required sections of the PRD (`.sureai/prd_document.md`) as per the instructions, focusing on clarity, precision, and a user-centric perspective.
3.  **Elaborate Epic Stories:** Develop comprehensive Epic Stories and detailed User Stories for the core MVP features (Authentication, 1:1 Messaging, Persistence), including acceptance criteria, estimated story points, and priority levels.
4.  **Outline Future Features (Phase 2):** Include high-level epics and a few representative user stories for Phase 2 features (Group Chat, Notifications, Media Sharing) to provide a roadmap, clearly marking them as future work.
5.  **Define Success Metrics & KPIs:** Establish clear, measurable success metrics for the messaging app, aligning with business objectives.
6.  **Refine Risks, Timeline, Dependencies:** Update the risk assessment, timeline, and dependency sections based on the synthesized information.
7.  **Generate Project Plan Additions:** Create content to append to `.sureai/project_plan.md`, detailing PM processes, timeline, and resource considerations specific to the messaging app.
8.  **Output in Strict JSON:** Ensure all generated content is in the specified JSON format for appending to the respective files.

## 6. PM and Planning Instructions for Subsequent Agents

*   **Focus on MVP for Phase 1:** Development efforts should prioritize the user stories marked as "High" priority, specifically those related to core 1:1 messaging and user authentication.
*   **Maintain Technical Debt Awareness:** Given the boilerplate extension, developers should be mindful of integrating new backend services with the existing frontend cleanly.
*   **Real-time Performance:** Emphasize building and testing for low-latency message delivery from the outset.
*   **Security First:** Implement all security requirements (authentication, authorization, encryption, input validation) as a top priority for all features.
*   **API Contract Adherence:** Backend and frontend teams must strictly adhere to the defined API (REST and WebSocket) contracts.
*   **Iterative Feedback:** Plan for regular demos and opportunities for feedback to validate feature implementation against user needs.
```
```json
{
  "prd": "\n\n# Product Requirements Document (PRD)\n\n## 1. Executive Summary\n*Generated: 2025-10-10T04:04:10*\nThe \"Messaging App\" project aims to develop a real-time communication platform by extending an existing Angular Clarity boilerplate for the frontend and building a new dedicated Python FastAPI backend. The initial MVP will deliver secure user authentication, real-time one-to-one text messaging, and persistent chat history. Leveraging a modular architecture and adhering to the Clarity Design System, the application will provide a robust, scalable, and intuitive user experience for instant digital communication, addressing the need for seamless, secure, and reliable interaction between users.\n\n## 2. Product Vision & Strategy\n*Generated: 2025-10-10T04:04:10*\n**Product Vision:** To become the go-to, secure, and user-friendly platform for instant communication, fostering seamless interactions between individuals and teams.\n\n**Strategic Goals:**\n1.  **Achieve MVP Stability & Performance:** Successfully launch a highly performant and stable core 1:1 messaging experience.\n2.  **Ensure Robust Security:** Implement and maintain industry-standard security practices for user data and communication.\n3.  **Facilitate User Engagement:** Drive user adoption and retention through an intuitive interface and reliable real-time features.\n4.  **Lay Foundation for Scalability:** Design and build an architecture that can gracefully scale to accommodate a growing user base and feature set.\n\n**Success Metrics (KPIs):**\n*   **User Registration Rate:** % of visitors completing registration.\n*   **Daily Active Users (DAU) / Monthly Active Users (MAU):** Number of unique users interacting with the app daily/monthly.\n*   **Average Message Latency:** Time taken for a message to go from sender to receiver (target < 500ms).\n*   **Message Send Success Rate:** % of messages successfully sent and delivered.\n*   **Retention Rate:** % of users returning after initial use.\n*   **Crash-Free Sessions:** % of user sessions without application crashes.\n\n## 3. Target Users & Personas\n*Generated: 2025-10-10T04:04:10*\nThe primary target users for the Messaging App are individuals and small teams who require a reliable and efficient platform for instant text-based communication.\n\n**Persona 1: \"Ava, The Connected Professional\"**\n*   **Demographics:** 28-35 years old, professional in a tech-savvy field.\n*   **Needs:** Quick, secure communication with colleagues and clients. Values organized chat history and reliable message delivery.\n*   **Pain Points:** Existing tools are clunky, insecure, or don't offer real-time responsiveness.\n*   **Goals:** Instant communication, easy access to chat history, clear online presence of contacts.\n*   **User Journey (MVP):** Logs in, sees colleagues online, initiates a 1:1 chat, sends messages, reviews past conversations.\n\n**Persona 2: \"Ben, The Social Organizer\"**\n*   **Demographics:** 22-30 years old, actively manages social groups and personal networks.\n*   **Needs:** Easy way to connect with friends and family, manage casual conversations.\n*   **Pain Points:** Juggling multiple messaging apps, privacy concerns with public platforms.\n*   **Goals:** Simple and intuitive interface, reliable messaging, (future) group chat functionality.\n*   **User Journey (MVP):** Registers, finds a friend, starts a private chat, sends and receives messages seamlessly.\n\n## 4. Problem Statement\n*Generated: 2025-10-10T04:04:10*\nUsers today require instant, secure, and reliable digital communication. Existing solutions often fall short in providing a consistent user experience, guaranteed message delivery, or robust security measures, leading to fragmented communication, privacy concerns, and inefficiencies. The challenge is to deliver a real-time messaging platform that is intuitive, scalable, and inherently secure, while also being easy for developers to extend given its boilerplate foundation.\n\n## 5. Solution Overview\n*Generated: 2025-10-10T04:04:10*\nThe Messaging App will provide a real-time communication platform featuring user authentication, one-to-one messaging, and persistent chat history. It will leverage an Angular Clarity frontend for a modern UI/UX and a Python FastAPI backend with WebSockets for real-time capabilities. The architecture is designed for scalability and security, ensuring low-latency message delivery and data protection. Future phases will introduce group chat, media sharing, and notifications.\n\n## 6. Functional Requirements\n*Generated: 2025-10-10T04:04:10*\nThe application will provide the following functional capabilities:\n\n*   **User Management & Authentication:**\n    *   FR-001: User Registration: Allow new users to create an account with a unique username, email, and password.\n    *   FR-002: User Login/Logout: Enable registered users to securely log in and log out of the application using their credentials.\n    *   FR-003: User Profile Management: Users can view and update their profile information (e.g., username, profile picture).\n    *   FR-004: User Presence: Display the online/offline status of users to their contacts.\n    *   FR-005: User Search: Allow users to search for other registered users by username or email to initiate chats.\n*   **One-to-One Messaging (MVP):**\n    *   FR-006: Send Text Message (1:1): Users can send text messages to a specific individual user in real-time.\n    *   FR-007: Receive Text Message (1:1): Users can receive text messages instantly from another individual user.\n    *   FR-008: View Message History (1:1): Users can view their complete chat history with another individual user, loaded from storage.\n    *   FR-009: Real-time Message Delivery (1:1): Messages sent will be delivered to the recipient(s) instantaneously.\n*   **Group Messaging (Future - Phase 2):**\n    *   FR-010: Create Group Chat: Users can create multi-user group conversations.\n    *   FR-011: Add/Remove Members from Group: Group administrators can add or remove participants from a group chat.\n    *   FR-012: Send Text Message (Group): Users can send text messages to all participants in a group chat.\n    *   FR-013: Receive Text Message (Group): Users can receive text messages from participants in a group chat.\n    *   FR-014: View Message History (Group): Users can view the chat history of a group conversation.\n*   **Notifications (Future - Phase 2):**\n    *   FR-015: New Message Notification: Users receive real-time notifications for new incoming messages.\n    *   FR-016: User Online/Offline Status Notification: Users are notified when a contact comes online or goes offline.\n*   **Media Sharing (Future - Phase 2):**\n    *   FR-017: Send Image/File in Chat: Users can upload and share images or other files within a conversation.\n    *   FR-018: View Shared Image/File in Chat: Users can view or download shared media directly within the chat interface.\n\n## 7. Non-Functional Requirements\n*Generated: 2025-10-10T04:04:10*\n*   **Performance:**\n    *   NFR-001: Message Latency: Messages should be delivered within 500ms under normal load (up to 1,000 concurrent users).\n    *   NFR-002: Concurrent Users: The system shall support at least 1,000 concurrent users (MVP), scalable to 10,000+ in future phases.\n    *   NFR-003: Response Time (API): REST API endpoints should respond within 200ms for 90% of requests.\n*   **Security:**\n    *   NFR-004: Authentication: Implement JWT-based authentication for all API endpoints and WebSocket connections.\n    *   NFR-005: Authorization: Ensure users can only access their own messages and authorized conversations.\n    *   NFR-006: Data Encryption: All data in transit (HTTP/WSS) must be encrypted using TLS/SSL. Passwords must be hashed and salted at rest.\n    *   NFR-007: Input Validation: All user inputs must be strictly validated on both frontend and backend to prevent injection attacks and other vulnerabilities.\n*   **Scalability:**\n    *   NFR-008: Horizontal Scaling: Backend services (Auth, User, Chat, WebSocket) must be designed for statelessness to support horizontal scaling.\n    *   NFR-009: Database Scalability: The database solution (PostgreSQL, Redis) must support scaling with data growth and increasing query load.\n*   **Usability:**\n    *   NFR-010: Responsive UI: The application UI must be responsive and adapt gracefully across various screen sizes and devices (desktop, tablet, mobile).\n    *   NFR-011: Intuitive Chat Flow: The chat interface should be easy to understand, navigate, and use for all target users.\n    *   NFR-012: Clarity Design System Adherence: The UI must maintain consistency with the VMware Clarity Design System for a professional and cohesive look and feel.\n*   **Reliability:**\n    *   NFR-013: Message Delivery Guarantee: Messages sent must be reliably delivered and persisted, even in case of temporary network disruptions (at-least-once delivery).\n    *   NFR-014: Error Handling: The system should gracefully handle errors, provide informative feedback to users, and log critical errors for operational monitoring.\n    *   NFR-015: High Availability: Core services (Authentication, Messaging) should have high availability (e.g., 99.9% uptime).\n*   **Maintainability:**\n    *   NFR-016: Modular Architecture: Codebase must be modular, adhering to microservices principles for the backend and Angular best practices for the frontend.\n    *   NFR-017: Documentation: Comprehensive technical documentation for API endpoints, database schema, frontend components, and deployment procedures.\n\n## 8. Epic Stories\n*Generated: 2025-10-10T04:04:10*\n\n### Epic 1: User Authentication & Profile Management\n**Epic Description:** Enable users to securely create and manage their accounts, including registration, login, profile updates, and real-time online/offline presence. This is foundational for any personalized messaging experience.\n**Business Value:** Ensures secure access, personalizes user identity, and allows users to find and connect with others. Critical for MVP.\n**Acceptance Criteria:**\n*   [ ] Users can register and log in securely.\n*   [ ] Users can update their basic profile information.\n*   [ ] User online/offline status is accurately displayed and updated in real-time.\n\n**User Stories:**\n- **US-001:** User Registration\n  - **As a** new user\n  - **I want to** register an account with a unique username, email, and password\n  - **So that** I can securely access the messaging application and personalize my identity\n  - **Acceptance Criteria:**\n    - [ ] The system validates required fields (username, email, password).\n    - [ ] The system checks for unique username and email.\n    - [ ] Upon successful registration, the user is authenticated and redirected to the main application view.\n    - [ ] Error messages are displayed for invalid or duplicate inputs.\n  - **Story Points:** 5\n  - **Priority:** High\n\n- **US-002:** User Login & Logout\n  - **As a** registered user\n  - **I want to** securely log in and log out of the application\n  - **So that** I can access my conversations and protect my account from unauthorized access\n  - **Acceptance Criteria:**\n    - [ ] The system authenticates user credentials (email/username and password).\n    - [ ] Upon successful login, a valid JWT is issued and stored securely on the client.\n    - [ ] Upon logout, the JWT is invalidated on the server and removed from the client.\n    - [ ] Error messages are displayed for incorrect credentials.\n  - **Story Points:** 3\n  - **Priority:** High\n\n- **US-003:** View & Update User Profile\n  - **As a** user\n  - **I want to** view and update my profile information (e.g., username, profile picture)\n  - **So that** I can manage my identity within the application\n  - **Acceptance Criteria:**\n    - [ ] A dedicated profile page/section is accessible from the main interface.\n    - [ ] Users can edit their username and upload a profile picture.\n    - [ ] Changes are persisted and reflected across the application.\n    - [ ] Input validation is performed for profile updates.\n  - **Story Points:** 8\n  - **Priority:** Medium\n\n- **US-004:** Real-time User Presence\n  - **As a** user\n  - **I want to** see the online/offline status of my contacts in real-time\n  - **So that** I know who is available to chat\n  - **Acceptance Criteria:**\n    - [ ] A clear indicator (e.g., a green dot) shows when a user is online.\n    - [ ] The status updates instantaneously when a contact logs in or out.\n    - [ ] The online status is visible in the user's contact list and potentially in active chat headers.\n  - **Story Points:** 5\n  - **Priority:** High\n\n### Epic 2: One-to-One Real-time Messaging\n**Epic Description:** Enable users to engage in instant, private text conversations with another individual user, forming the core real-time communication functionality.\n**Business Value:** Provides fundamental real-time communication, fulfilling the primary purpose of a messaging app for MVP.\n**Acceptance Criteria:**\n*   [ ] Users can initiate and participate in 1:1 text chats.\n*   [ ] Messages are delivered and displayed in real-time to both sender and receiver.\n*   [ ] Chat history is loaded and accessible within conversations.\n\n**User Stories:**\n- **US-005:** Initiate a One-to-One Chat\n  - **As a** user\n  - **I want to** find and select another user to start a private conversation\n  - **So that** I can communicate directly with them\n  - **Acceptance Criteria:**\n    - [ ] A search function is available to find other registered users.\n    - [ ] Selecting a user from the search results or a contact list opens a new 1:1 chat window/view.\n    - [ ] If a conversation already exists, the existing chat history is loaded.\n  - **Story Points:** 3\n  - **Priority:** High\n\n- **US-006:** Send Real-time Text Message (1:1)\n  - **As a** user\n  - **I want to** type and send a text message to another individual user\n  - **So that** I can communicate my thoughts and information instantly\n  - **Acceptance Criteria:**\n    - [ ] A text input field and a \"Send\" button (or Enter key functionality) are available in the chat interface.\n    - [ ] Upon sending, the message appears immediately in the sender's chat view.\n    - [ ] The message is instantly delivered to the recipient and appears in their active chat view.\n    - [ ] Message content cannot exceed 2000 characters.\n  - **Story Points:** 5\n  - **Priority:** High\n\n- **US-007:** Receive Real-time Text Message (1:1)\n  - **As a** user\n  - **I want to** receive incoming text messages from other users in real-time\n  - **So that** I can follow and respond to conversations\n  - **Acceptance Criteria:**\n    - [ ] New messages from the other participant appear instantly in the active chat window.\n    - [ ] If the user is not in the active chat, a subtle in-app notification (e.g., badge on conversation list) indicates a new message.\n    - [ ] Messages are displayed in chronological order with sender and timestamp.\n  - **Story Points:** 3\n  - **Priority:** High\n\n- **US-008:** View One-to-One Chat History\n  - **As a** user\n  - **I want to** see my past conversations with another user\n  - **So that** I can refer back to previous discussions and maintain context\n  - **Acceptance Criteria:**\n    - [ ] When a 1:1 chat is opened, the conversation history is loaded from the server and displayed.\n    - [ ] Messages are paginated or incrementally loaded upon scrolling up to improve performance for long histories.\n    - [ ] The history includes sender, message content, and timestamp for each message.\n  - **Story Points:** 5\n  - **Priority:** High\n\n### Epic 3: Message Persistence & Retrieval\n**Epic Description:** Ensure all sent messages are securely stored and readily accessible for users to review their conversation history at any time.\n**Business Value:** Guarantees data integrity, provides continuity of conversations, and enhances user trust and experience. Essential for MVP.\n**Acceptance Criteria:**\n*   [ ] All sent messages are stored in the database.\n*   [ ] Chat history is accurately retrieved when a conversation is opened.\n*   [ ] Data models support message content, sender, receiver, timestamp, and conversation ID.\n\n**User Stories:**\n- **US-009:** Persist Sent Messages\n  - **As a** messaging app\n  - **I want to** store every sent message in the database\n  - **So that** conversation history can be retrieved later and messages are not lost\n  - **Acceptance Criteria:**\n    - [ ] Upon a message being sent via WebSocket, it is successfully written to the PostgreSQL database.\n    - [ ] The stored message includes content, sender ID, conversation ID, and timestamp.\n    - [ ] Database write operations are robust against failures.\n  - **Story Points:** 8\n  - **Priority:** High\n\n- **US-010:** Retrieve Conversation List\n  - **As a** user\n  - **I want to** view a list of all my active conversations with a preview of the last message\n  - **So that** I can quickly navigate to and resume any chat\n  - **Acceptance Criteria:**\n    - [ ] A sidebar or main view displays a list of active 1:1 (and future group) conversations.\n    - [ ] Each list item shows the other participant's name (or group name) and the content of the last message.\n    - [ ] The list is sorted by the timestamp of the last message.\n  - **Story Points:** 5\n  - **Priority:** High\n\n### Epic 4: Group Chat (Future Phase 2)\n**Epic Description:** Enable users to create, manage, and participate in multi-user group conversations.\n**Business Value:** Expands communication capabilities, allowing for team collaboration and broader social interaction.\n**Acceptance Criteria:**\n*   [ ] Users can create new group chats.\n*   [ ] Group members can send and receive messages within the group.\n*   [ ] (Admin) Users can manage group members.\n\n**User Stories:**\n- **US-011:** Create a Group Conversation\n  - **As a** user\n  - **I want to** create a new group chat and invite other users\n  - **So that** I can communicate with multiple people simultaneously\n  - **Acceptance Criteria:**\n    - [ ] A \"Create Group\" option is available in the interface.\n    - [ ] Users can name the group and select members from their contacts.\n    - [ ] The newly created group chat appears in their conversation list.\n  - **Story Points:** 8\n  - **Priority:** Low (Phase 2)\n\n- **US-012:** Send/Receive Messages in Group Chat\n  - **As a** group member\n  - **I want to** send and receive text messages within a group conversation\n  - **So that** I can collaborate and interact with all group participants\n  - **Acceptance Criteria:**\n    - [ ] Messages sent appear instantly to all active group members.\n    - [ ] Messages include the sender's name for clarity.\n    - [ ] Group chat history is persistent and viewable by all members.\n  - **Story Points:** 5\n  - **Priority:** Low (Phase 2)\n\n### Epic 5: Real-time Notifications (Future Phase 2)\n**Epic Description:** Provide timely alerts to users about new messages, online status changes, and other important events, even when not actively in a specific chat.\n**Business Value:** Enhances user awareness and engagement by ensuring they don't miss critical updates.\n**Acceptance Criteria:**\n*   [ ] Users receive visual/auditory notifications for new messages.\n*   [ ] Notifications distinguish between 1:1 and group messages.\n\n**User Stories:**\n- **US-013:** New Message Notification\n  - **As a** user\n  - **I want to** receive an in-app notification when I get a new message in a conversation I'm not actively viewing\n  - **So that** I am immediately aware of incoming communications\n  - **Acceptance Criteria:**\n    - [ ] A badge count or similar visual cue appears on the conversation list item for unread messages.\n    - [ ] A brief preview of the message sender and content may be shown.\n    - [ ] Clicking the notification or conversation item navigates to the respective chat.\n  - **Story Points:** 3\n  - **Priority:** Low (Phase 2)\n\n## 9. User Interface Requirements\n*Generated: 2025-10-10T04:04:10*\n*   **Design System:** Strict adherence to the VMware Clarity Design System for all UI components, iconography, typography, and styling.\n*   **Responsive Design:** The application must be fully responsive, providing an optimal viewing and interaction experience across various screen sizes and devices (desktop, tablet, mobile).\n*   **Chat Interface:**\n    *   **Conversation List:** A clear, scrollable list of active conversations (1:1 and group), showing contact name/group name, last message preview, and unread indicators.\n    *   **Chat Window:** A dedicated area for displaying messages, with messages clearly distinguished by sender (e.g., sender on right, receiver on left). Includes timestamps.\n    *   **Message Input:** A persistent, multi-line text input field at the bottom of the chat window with a visible \"Send\" button.\n*   **User Profile:** A clean interface for displaying and editing user details (username, profile picture).\n*   **Navigation:** Intuitive navigation (e.g., sidebar or top bar) to switch between different sections of the app (e.g., chats, contacts, profile settings).\n*   **Loading Indicators:** Provide visual feedback (spinners, skeleton loaders) during data fetching or message sending to indicate system activity.\n\n## 10. Technical Requirements\n*Generated: 2025-10-10T04:04:10*\n*   **Frontend (Angular Clarity):**\n    *   Utilize Angular's modular structure (Core, Shared, Feature modules) for maintainability and scalability.\n    *   Implement RxJS for managing asynchronous data streams from REST APIs and WebSockets.\n    *   Integrate a custom WebSocket service for real-time communication, handling connection management, sending events, and receiving messages.\n    *   Ensure secure handling of JWTs for authentication with both REST and WebSocket connections.\n*   **Backend (Python FastAPI):**\n    *   Develop a separate set of FastAPI services for Authentication, User Management, Conversation Management, and Message Persistence.\n    *   Implement a dedicated WebSocket service for handling persistent client connections and real-time message broadcasting using FastAPI's ASGI capabilities.\n    *   Utilize SQLAlchemy (with Alembic for migrations) for robust interaction with PostgreSQL.\n    *   Implement JWT-based authentication and authorization using `python-jose` or `PyJWT` and `bcrypt` for password hashing.\n    *   Ensure all API endpoints are documented with OpenAPI/Swagger UI.\n*   **Real-time Communication:**\n    *   Employ a Redis instance for Pub/Sub functionality to facilitate message broadcasting across horizontally scaled WebSocket service instances.\n    *   Use Redis for fast storage and retrieval of user presence status.\n*   **Database:**\n    *   PostgreSQL as the primary relational database for structured data (users, conversations, messages).\n    *   Design a normalized schema that supports efficient querying of chat history and user information.\n*   **Deployment:**\n    *   Containerize all services (Frontend, Backend API, WebSocket, Redis, PostgreSQL) using Docker.\n    *   Provide `docker-compose.yml` for local development and potential staging environments.\n*   **API Contracts:** Define clear RESTful API endpoints and WebSocket event formats (JSON payloads) for seamless frontend-backend integration.\n\n## 11. Success Metrics & KPIs\n*Generated: 2025-10-10T04:04:10*\n*   **Activation:**\n    *   User Registration Conversion Rate: % of users completing registration after visiting the signup page.\n    *   First Message Sent Rate: % of registered users who send at least one 1:1 message within 24 hours of registration.\n*   **Engagement:**\n    *   Daily Active Users (DAU) / Monthly Active Users (MAU).\n    *   Average Messages Sent per User per Day.\n    *   Average Session Duration (chat window active time).\n    *   Retention Rate (e.g., Week 1, Month 1 retention).\n*   **Performance:**\n    *   Average Message Latency (sender to receiver).\n    *   API Response Times (p90, p95).\n    *   Error Rate for message sending and API calls.\n*   **Security:**\n    *   Number of reported security vulnerabilities (target 0 critical).\n    *   Audit Log Integrity checks.\n\n## 12. Risk Assessment\n*Generated: 2025-10-10T04:04:10*\n*(Building upon `analysis_document.md` and `io8codermaster_plan.md`)*\n\n1.  **Scalability Challenges (High):**\n    *   **Risk:** Real-time messaging can be resource-intensive, leading to performance degradation with increased concurrent users if not architected correctly.\n    *   **Mitigation:**\n        *   Implement stateless microservices for horizontal scaling.\n        *   Utilize Redis Pub/Sub for WebSocket message distribution.\n        *   Employ efficient database indexing and consider read replicas for PostgreSQL.\n        *   Regularly perform load testing and performance benchmarking.\n2.  **Performance & Latency (High):**\n    *   **Risk:** High message latency or slow UI response times can severely degrade user experience.\n    *   **Mitigation:**\n        *   Optimize WebSocket message processing and broadcasting.\n        *   Minimize database queries for real-time operations (leverage Redis for presence).\n        *   Implement efficient frontend rendering with Angular's change detection strategies.\n        *   Monitor network performance and optimize payload sizes.\n3.  **Security Vulnerabilities (High):**\n    *   **Risk:** User data breaches, unauthorized access, or communication eavesdropping could erode user trust.\n    *   **Mitigation:**\n        *   Implement robust JWT authentication and RBAC authorization.\n        *   Enforce TLS/SSL for all communications (HTTPS/WSS).\n        *   Securely hash passwords using bcrypt.\n        *   Perform comprehensive input validation (NFR-007).\n        *   Conduct regular security audits and penetration testing.\n4.  **Integration Complexity (Medium):**\n    *   **Risk:** Integrating a new Python backend and real-time layer with an existing Angular Clarity boilerplate might lead to unforeseen compatibility issues or development overhead.\n    *   **Mitigation:**\n        *   Define clear API contracts (REST and WebSocket) upfront.\n        *   Maintain modularity on both frontend and backend.\n        *   Conduct frequent integration testing between frontend and backend.\n        *   Ensure a consistent build and deployment process (Docker Compose).\n5.  **Scope Creep (Medium):**\n    *   **Risk:** Feature requests beyond the MVP could delay critical functionalities and impact delivery timelines.\n    *   **Mitigation:**\n        *   Strictly adhere to the defined MVP scope for Phase 1.\n        *   Clearly categorize features into phases (e.g., Phase 2 for Group Chat, Media Sharing).\n        *   Prioritize backlog items based on business value and MVP goals.\n        *   Regularly communicate scope and prioritization decisions to stakeholders.\n\n## 13. Timeline & Milestones\n*Generated: 2025-10-10T04:04:10*\n*(Aligned with `analysis_document.md`'s \"Update: Project Phases and Milestones\")*\n\n**Phase 1: Discovery & Architecture (Completed)**\n*   **Output:** Detailed `analysis_document.md`, `architecture_document.md`, `tech_stack_document.md`, and this `prd_document.md`.\n\n**Phase 2: Core Messaging MVP Development (Target: 8-10 weeks)**\n*   **Milestone 1: Foundational Services (Weeks 1-3)**\n    *   Backend: User Authentication (Registration, Login), User Service (Profile, Search), Database Schema for Users/Conversations/Messages.\n    *   Frontend: Angular Auth Module, basic User Profile integration with Clarity UI.\n*   **Milestone 2: Real-time 1:1 Messaging & Persistence (Weeks 4-7)**\n    *   Backend: Message Service (persistence), WebSocket Service (real-time delivery), Redis integration (Pub/Sub, Presence).\n    *   Frontend: Angular Chat Module (1:1 chat UI, sending/receiving messages, displaying history), User Presence display.\n*   **Milestone 3: MVP Integration & Initial QA (Weeks 8-10)**\n    *   Full end-to-end integration of frontend and backend.\n    *   Unit and Integration testing.\n    *   Initial performance testing for latency and concurrent users.\n    *   Docker Compose setup for local development.\n\n**Phase 3: Feature Expansion & Quality Assurance (Target: 6-8 weeks, starting after MVP)**\n*   **Milestone 4: Group Chat & UI Enhancements**\n    *   Backend: Group Conversation Management, Group Messaging.\n    *   Frontend: Group Chat UI, improved conversation list.\n*   **Milestone 5: Notifications & Media Sharing**\n    *   Backend: Notification Service, File Storage Service integration.\n    *   Frontend: Notification display, media upload/display in chat.\n*   **Milestone 6: Comprehensive Testing & Optimization**\n    *   Full E2E testing, security testing, load testing.\n    *   Performance tuning and bug fixing.\n\n**Phase 4: Deployment Readiness & Operations (Target: 2-3 weeks, after Feature Expansion)**\n*   **Milestone 7: CI/CD & Production Deployment**\n    *   Setup CI/CD pipelines (GitHub Actions/GitLab CI).\n    *   Container orchestration (Kubernetes/ECS) for production deployment.\n    *   Monitoring and logging setup.\n\n## 14. Dependencies & Assumptions\n*Generated: 2025-10-10T04:04:10*\n**Dependencies:**\n*   **Angular Clarity Boilerplate:** Successful and stable integration with the provided boilerplate.\n*   **Backend Services:** Availability and stability of all backend microservices (Auth, User, Chat, WebSocket).\n*   **Database Infrastructure:** Reliable PostgreSQL and Redis instances are provisioned and accessible.\n*   **Cloud Services:** For Phase 2, access to object storage (e.g., AWS S3) for media sharing.\n*   **Developer Skillset:** Availability of developers proficient in Angular, TypeScript, Python, FastAPI, WebSockets, Docker, and PostgreSQL.\n\n**Assumptions:**\n*   The existing Angular Clarity boilerplate is stable and extensible without significant refactoring.\n*   The project team has access to necessary development environments and tools.\n*   Real-time performance metrics can be achieved with the chosen technology stack under expected load.\n*   Security requirements are clearly defined and will be continuously reviewed and validated.\n*   Stakeholders are aligned on the MVP scope and phased rollout strategy.\n",
  "project_plan": "\n\n### Project Plan for \"Messaging App\" - PM Initiatives (2025-10-10T04:04:10)\n\n## 1. Project Management Methodology\n*Generated: 2025-10-10T04:04:10*\nThe \"Messaging App\" project will adopt an **Agile Scrum-based methodology** tailored for real-time application development.\n*   **Sprints:** 2-week sprints will be used to deliver incremental, shippable features.\n*   **Ceremonies:** Regular Scrum ceremonies (Sprint Planning, Daily Stand-ups, Sprint Reviews, Retrospectives) will be conducted.\n*   **Backlog Management:** A prioritized product backlog will be maintained, focusing on delivering maximum business value per sprint.\n*   **Tools:** JIRA/Trello for backlog management and sprint tracking.\n\n## 2. Project Phases & Milestones\n*Generated: 2025-10-10T04:04:10*\nBuilding upon the phases identified in `analysis_document.md`, the project will follow:\n\n*   **Phase 1: Discovery & Architecture (Completed)**\n    *   **Activities:** Detailed requirements gathering, high-level system architecture design, technology stack selection.\n    *   **Deliverables:** `analysis_document.md`, `architecture_document.md`, `tech_stack_document.md`, and initial `prd_document.md`.\n    *   **Status:** Completed prior to PM agent execution.\n\n*   **Phase 2: Core Messaging MVP Development (Target: 8-10 Weeks)**\n    *   **Goal:** Implement fundamental user authentication, one-to-one real-time messaging, and message persistence.\n    *   **Key Milestones & Deliverables:**\n        *   **M2.1: Authentication & User Service Backend (Weeks 1-3):** API endpoints for user registration, login, profile management. Initial database setup.\n        *   **M2.2: Frontend User & Auth Integration (Weeks 2-4):** Angular modules for user authentication and profile display integrated with Clarity UI.\n        *   **M2.3: Real-time Backend Core (Weeks 4-7):** Message Service, WebSocket Gateway, Redis Pub/Sub for 1:1 messaging. Message persistence.\n        *   **M2.4: Frontend 1:1 Chat Interface (Weeks 5-8):** Angular Chat Module for sending/receiving messages, displaying chat history, user presence.\n        *   **M2.5: MVP Integration & Initial QA (Weeks 8-10):** Full E2E integration, basic unit/integration tests, initial load testing. `docker-compose.yml` for local deployment.\n    *   **Success Criteria:** All MVP user stories (US-001 to US-010) are implemented, tested, and meet defined NFRs (latency, basic security).\n\n*   **Phase 3: Feature Expansion & Quality Assurance (Target: 6-8 Weeks)**\n    *   **Goal:** Introduce advanced messaging features and ensure overall product quality and stability.\n    *   **Key Milestones & Deliverables:**\n        *   **M3.1: Group Chat Implementation (Weeks 1-3):** Backend services and frontend UI for creating and participating in group chats (US-011, US-012).\n        *   **M3.2: Notifications & Media Sharing (Weeks 3-5):** Backend support for notifications, frontend notification display. Integration with object storage for media sharing (US-013).\n        *   **M3.3: Comprehensive Testing (Weeks 5-8):** Dedicated QA phase, including E2E testing, security audits, advanced load testing, and performance optimization. Bug fixing.\n    *   **Success Criteria:** All Phase 2 user stories are implemented, product is stable, and performance benchmarks are met under higher load.\n\n*   **Phase 4: Deployment Readiness & Operations (Target: 2-3 Weeks)**\n    *   **Goal:** Prepare the application for production deployment and establish operational pipelines.\n    *   **Key Milestones & Deliverables:**\n        *   **M4.1: CI/CD Pipeline Setup (Weeks 1-2):** Automated build, test, and deployment pipelines (e.g., GitHub Actions) for staging and production environments.\n        *   **M4.2: Production Infrastructure & Monitoring (Weeks 1-3):** Configuration of Kubernetes/ECS, logging (e.g., ELK stack), monitoring (e.g., Prometheus, Grafana). Final deployment to a staging environment.\n    *   **Success Criteria:** Application successfully deployed to staging/production environment, CI/CD operational, monitoring and alerting systems functional.\n\n## 3. Resource Allocation & Team Structure\n*Generated: 2025-10-10T04:04:10*\n*   **Product Management:** 1 PM (io8Product Manager agent) - responsible for vision, strategy, requirements, prioritization, and stakeholder communication.\n*   **Frontend Development:** 2-3 Engineers - proficient in Angular, TypeScript, Clarity Design System, RxJS, WebSockets.\n*   **Backend Development:** 2-3 Engineers - proficient in Python, FastAPI, WebSockets, PostgreSQL, Redis, SQLAlchemy.\n*   **DevOps/Infrastructure:** 1 Engineer (shared) - expertise in Docker, Docker Compose, Kubernetes/Cloud infrastructure, CI/CD, Nginx.\n*   **Quality Assurance:** 1 QA Engineer (shared) - responsible for testing plans, execution (manual & automated), bug tracking.\n\n## 4. Risk Management Strategy\n*Generated: 2025-10-10T04:04:10*\nProactive monitoring and mitigation of identified risks:\n*   **Scalability:** Regular load tests, architectural reviews for horizontal scaling, optimize database and Redis configurations.\n*   **Performance:** Continuous monitoring of message latency and API response times. Prioritize performance optimizations throughout development.\n*   **Security:** Integrate security practices into every phase (shift-left security). Regular security reviews, code audits, and penetration testing.\n*   **Integration Complexity:** Early and continuous communication between frontend/backend teams, strict API contract adherence, frequent integration testing.\n*   **Scope Creep:** Strict adherence to MVP, clear prioritization, and robust change management process for new feature requests.\n\n## 5. Communication Plan\n*Generated: 2025-10-10T04:04:10*\n*   **Daily Stand-ups:** Short, daily syncs for the development team to discuss progress, blockers, and plans.\n*   **Sprint Reviews:** End-of-sprint demonstrations of completed work to stakeholders for feedback.\n*   **Sprint Retrospectives:** End-of-sprint meetings for the team to reflect and improve processes.\n*   **Documentation:** All project documentation (`.sureai/prd_document.md`, `project_plan.md`, etc.) will be kept up-to-date and accessible.\n*   **Ad-hoc Meetings:** As needed for design discussions, problem-solving, and risk mitigation.\n"\n}\n```

## Base Agent Prompt Reference

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