Initial commit of io8 project

This commit is contained in:
user 2025-10-10 04:47:41 +00:00
parent 8e26f26685
commit 4eb4af3ec0
22 changed files with 1512 additions and 1 deletions

52
.sureai/.code_tree.txt Normal file
View File

@ -0,0 +1,52 @@
# Project Directory Structure (tree -L 2 -a output)
.
├── .git
│   ├── COMMIT_EDITMSG
│   ├── FETCH_HEAD
│   ├── HEAD
│   ├── ORIG_HEAD
│   ├── branches
│   ├── config
│   ├── description
│   ├── hooks
│   ├── index
│   ├── info
│   ├── logs
│   ├── objects
│   └── refs
├── .io8project
│   ├── .state.json
│   └── project_metadata.json
├── .sureai
│   ├── .code_tree.txt
│   ├── .developer_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .directory_structure.txt
│   ├── .directory_structure_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8analyst_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8architect_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8codermaster_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8pm_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8project_builder_messaging_app_20251010_040350.md
│   ├── .sm_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── io8_mcp
│   ├── sprint_plan.md
│   ├── tasks_list.md
│   └── uploads
├── Dockerfile.backend
├── Dockerfile.frontend
├── deployment_config.yml
├── docker-compose.yml
├── messaging_app_20251010_040350-messaging_app_20251010_040350-b-b
│   └── authsec_springboot
├── messaging_app_20251010_040350-messaging_app_20251010_040350-d-d
│   └── authsec_mysql
├── messaging_app_20251010_040350-messaging_app_20251010_040350-f-f
│   └── authsec_angular
├── nginx.conf
└── sureops
├── messaging_app_20251010_040350-messaging_app_20251010_040350-b-b
├── messaging_app_20251010_040350-messaging_app_20251010_040350-d-d
└── messaging_app_20251010_040350-messaging_app_20251010_040350-f-f
22 directories, 26 files

View File

@ -0,0 +1,535 @@
# Developer Agent Prompt: Messaging App
## Project Context
This document outlines the development methodology, code implementation approach, technology stack strategy, code organization, and customized workflow for the "Messaging App" project. The project aims to create a robust messaging application with a Spring Boot backend, MySQL database, and Angular Clarity frontend.
## Development Methodology
- **Document-Driven Development:** All implementation will strictly follow the requirements, architecture, and tech stack documents provided in the `.sureai/` directory.
- **Iterative Implementation:** Development will proceed in an iterative manner, breaking down main tasks into smaller, manageable subtasks.
- **Test-Driven Approach (Implicit):** While explicit TDD is not mandated for every subtask, main tasks will be thoroughly tested upon completion of all subtasks.
## Code Implementation Approach
### Backend (Spring Boot - Java)
- **Location:** All backend code MUST be written in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet`.
- **Package Naming:** New folders/packages under `com.realnet` should use underscores (`_`) instead of hyphens (`-`) to avoid naming conflicts and errors.
- **CRUD Operations:** Prioritize checking `README.txt` in the base project for existing CRUD operations. If found, mark corresponding subtasks as `[z]` (skipped).
- **Spring Security:** DO NOT modify any existing Spring Security configuration files. These are pre-configured and functional.
- **Lombok:** Utilize Lombok annotations (`@Data`, `@NoArgsConstructor`, `@AllArgsConstructor`, etc.) for boilerplate code (getters, setters, constructors) instead of manual implementation.
- **Error Handling:** Implement robust error handling mechanisms for API endpoints and business logic.
- **API Design:** Design RESTful APIs following best practices, ensuring clear endpoints, request/response structures, and appropriate HTTP status codes.
### Frontend (Angular Clarity - TypeScript)
- **Location:** All frontend code MUST be written in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master`.
- **Component-Based Architecture:** Develop UI components following Angular's component-based architecture.
- **Clarity Design System:** Adhere to the Clarity Design System for UI/UX consistency and component usage.
- **State Management:** Implement appropriate state management patterns (e.g., services, NgRx if specified in architecture) for managing application data.
- **Routing:** Configure Angular routing for navigation between different views/modules.
- **API Integration:** Integrate with the backend APIs using Angular's `HttpClient` module.
- **Form Handling:** Implement reactive forms for user input and validation.
- **Blank Screen Prevention:** Before marking any frontend subtask complete, rigorously validate that all created/modified frontend files contain actual content and are not empty. Verify critical files like `index.html`, `main.ts`, `app.component.ts`, and `styles.scss` for essential content.
### Database (MySQL)
- **Location:** Database-related files (e.g., `wf_table.sql`) are located in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-d-d/authsec_mysql/mysql/wf_table`.
- **Schema Management:** Ensure database schema changes are managed through SQL scripts or ORM migrations (if applicable and specified in architecture).
- **Data Models:** Align backend entities with the database schema.
## Technology Stack Implementation Strategy
- **Backend:** Spring Boot (Java) for RESTful APIs, business logic, and data persistence.
- **Frontend:** Angular with Clarity Design System for a responsive and user-friendly interface.
- **Database:** MySQL for relational data storage.
- **Build Tools:** Maven for Spring Boot backend, npm/Angular CLI for frontend.
## Code Organization and Structure Framework
- **Backend:** Standard Spring Boot project structure with `com.realnet` as the base package. Sub-packages for controllers, services, repositories, entities, and DTOs.
- **Frontend:** Standard Angular project structure with `src/app` containing modules, components, services, and models.
- **Shared Components:** Create reusable components and services for common functionalities.
- **Configuration:** Centralize application configurations in `application.properties` (backend) and `environment.ts` (frontend).
## Customized Development Workflow
1. **Read and Analyze Documents:** Before starting any coding, thoroughly review `requirements_document.md`, `architecture_document.md`, `tech_stack_document.md`, `tasks_list.md`, `sprint_plan.md`, `coding-standard.md`, and `ui-ux.md` from the `.sureai/` directory.
2. **Subtask Breakdown:** For each main task in `tasks_list.md`, break it down into 3-8 detailed subtasks.
3. **Implement Subtasks:**
* Update "Currently Working On" in `tasks_list.md` to the current subtask.
* Create or modify code files as required, adhering to the specified file locations and naming conventions.
* Run language-specific syntax/static checks (e.g., `npx tsc --noEmit` for TypeScript, Maven compile for Java).
* Mark the subtask as `[x]` (completed) or `[z]` (skipped if already exists in base project) in `tasks_list.md`.
* Move to the next subtask.
4. **Main Task Testing and Verification:**
* Once all subtasks for a main task are complete, run `tree -L 2` to verify file structure and identify any missing files. Create missing files (e.g., `reportWebVitals.js`) with appropriate content.
* Install all dependencies for both backend and frontend.
* Write and execute unit tests covering the main task's functionality.
* Append ` — TEST: PASS` or ` — TEST: FAIL` to the main task header in `tasks_list.md`.
* If tests fail, debug and fix the code, then re-test until successful.
5. **Mandatory Git Commit:** After completing main task testing (regardless of pass/fail), perform a mandatory git commit to the Gitea repository.
* Extract the project name from `.sureai/io8_mcp/responses/create_project.out`.
* Use the provided git commit sequence with fallbacks.
* Update the main task header in `tasks_list.md` with ` — COMMIT: SUCCESSFUL` or ` — COMMIT: UNSUCCESSFUL`.
6. **Update Task Status:** Add the completed main task to the "Completed Tasks" section in `tasks_list.md`.
7. **Proceed to Next Main Task:** Only start the next main task after the current one's testing and commit process is complete.
8. **Application Smoke Test (Task X):** After ALL other main tasks are completed, execute `Task X: Application Smoke Test` as described in the general instructions, including file structure verification, dependency installation, and starting both backend and frontend servers. Perform a mandatory git commit after Task X.
## Critical Instructions for io8 Workflow Execution
### Base Project Handling
- **Append-only mode:** ONLY append content to existing predefined documents.
- **Preserve existing content:** Never overwrite or replace existing content.
- **Use existing file structure:** Work within the existing `.sureai` directory structure.
- **Agent-specific prompts:** Create agent-specific prompt files in the `.sureai` folder.
- **CRITICAL EXCEPTION - SPRING SECURITY FILES:** Do NOT modify any Spring Security configuration files. These are pre-made and working, so no need to write new code or update existing code at all.
- **CRITICAL BACKEND DIRECTORY:** For Spring Boot projects, ALL backend code MUST be written in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet` directory. No backend code should be written anywhere else. And for any new folder name that you will create under realnet directory don't include hyphens in the folder name/package name as that will give an error instead use underscores while naming the folder or package name when you use it in code files.
#### CRITICAL OVERRIDE: Use existing dynamic codebase folders (do NOT create new frontend/ or backend/)
- Frontend lives in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/` and already contains the frontend codebase. Update code inside this folder. Do NOT create a new `frontend/` folder.
- Backend lives in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet` and already contains the backend codebase. Update code inside this folder ONLY. Do NOT create a new `backend/` folder. And for any new folder name that you will create under realnet directory don't include hyphens in the folder name/package name as that will give an error instead use underscores while naming the folder or package name when you use it in code files.
- Keep agent documents inside `.sureai/` as usual.
### Reference Inputs (Architecture & Tech Stack)
- Before coding, read the architecture and tech stack documents generated earlier under the dynamic frontend folder:
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/.sureai/architecture_document.md`
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/.sureai/tech_stack_document.md`
- Implement strictly according to these documents, and align subtasks with the SM tasks list.
### Agent-Specific Prompt Creation
For each io8 agent in the workflow, create a customized agent prompt file:
- **File location:** `.sureai/.io8{agent_name}_agent_{user_prompt}_{timestamp}.md`
- **Content:** Customized instructions specific to the project and user prompt
- **Purpose:** Guide downstream agents with project-specific context
### Document Update Process
When updating predefined documents:
- **File location:** Work within the existing `.sureai/` directory
- **Append content:** Add new content with clear section headers and timestamps
- **Preserve structure:** Maintain existing document structure and formatting
- **Link references:** Reference other documents as needed for context
## Critical Instructions
### Document Analysis Phase
When previous documents are provided in the prompt, you MUST:
1. **Read and analyze the provided documents:**
- If ` @requirements_document.md` is provided - analyze functional and non-functional requirements
- If ` @architecture_document.md` is provided - analyze system architecture and design patterns
- If ` @tech_stack_document.md` is provided - analyze technology choices and frameworks
- If ` @tasks_list.md` is provided - analyze development tasks created by SM agent
- If ` @sprint_plan.md` is provided - analyze development timeline and priorities
- If ` @.sureai/coding-standard.md` is provided - analyze the coding standards and conventions to follow
- If ` @.sureai/ui-ux.md` is provided - analyze the UI/UX components, design tokens, theming, and accessibility guidelines
- **CRITICAL:** If `.developer_agent` prompt already exists, do NOT create a new one - use the existing prompt for subsequent requests
2. **Extract key information from the documents:**
- What features need to be implemented (from requirements)
- Technical architecture and patterns (from architecture)
- Technology stack and frameworks (from tech stack)
- Data models and relationships (from requirements)
- User interface requirements (from requirements)
- Coding standards and conventions (from coding-standard)
- UI patterns, components, tokens, and theming (from ui-ux)
- **CRITICAL:** Main tasks created by SM agent in `.sureai/tasks_list.md` that need subtasks
### Task Management and Implementation Phase
#### CRUD Operations Already Implemented in Base Project
**CRITICAL: Check Base Project README.txt for Existing CRUD Operations**
- Before creating subtasks, check the base project's README.txt file for existing CRUD operations
- If CRUD operations are already documented in README.txt (e.g., task editing, deletion, task list UI), mark them as "Z" (skipped) instead of "X" (completed)
- **Marking Convention:**
- `- [x]` = Completed subtask (implemented by developer)
- `- [z]` = Skipped subtask (already exists in base project)
- **Examples of tasks to mark as "Z":**
- "Develop Task Editing and Deletion User Interface" - if task editing/deletion already exists
- "Develop Task List User Interface" - if task list display already exists
- Any CRUD operations (Create, Read, Update, Delete) that are documented in base project README.txt
#### Task Status Tracking
When working with `.sureai/tasks_list.md` created by SM agent, you MUST:
1. **Read Current Status:** Check the "Currently Working On" section to know which task/subtask to work on
2. **Add Subtasks:** For each main task created by SM agent, add multiple subtasks (3-8) to break down implementation
3. **Mark Completed Items:** Use `- [x]` to mark subtasks as completed as you implement them, or `- [z]` to mark as skipped if already exists in base project
4. **Update Current Task:** Change "Currently Working On" to the next subtask when moving forward
5. **Track Progress:** Update "Completed Tasks" when entire tasks are finished
6. **Maintain Structure:** Always preserve the hierarchical structure (Main Task → Subtask → Subtask items)
7. **Main Task Testing:** After completing ALL subtasks for a main task, test the entire main task functionality and append ` — TEST: PASS` or ` — TEST: FAIL` to the main task header.
8. **Main Task Commit Status:** After attempting git commit, append ` — COMMIT: SUCCESSFUL` or ` — COMMIT: UNSUCCESSFUL` to the main task header. Also Do the commit after Task X is completed
9. **Gate on Test Result:** Only mark a main task as completed when its overall functionality test passes. If the test fails, fix the code and re-test until it passes.
10. **Commit Status Tracking:** Always update commit status in the main task header regardless of test results. Plus after last task X are completed do the commit and git push.
11. **Strict Sequencing:** Implement main tasks strictly in order as created by the SM agent (Task 1 → Task 2 → …). **Do not create or run the Application Smoke Test (Task X) until ALL main tasks are fully completed (zero remaining `- [ ]` subtasks across all main tasks).**
12. **No Extraneous Output in tasks_list.md:** Never include quotes, code fences, raw terminal output, host prompts, or stray characters in `.sureai/tasks_list.md` (e.g., no `"""`, no `root @host:~#` lines). Keep it clean Markdown only.
#### Final Verification Task: Application Smoke Test + Git Commit after all Task X are completed.
After all other implementation tasks are complete, add a final main task called `Task X: Application Smoke Test` with subtasks:
- [ ] Check project file structure using `tree -L 2` command to identify any missing files
- [ ] Create any missing files found during structure check (e.g., userprompt_timestamp-f-f/src/reportWebVitals.js)
- [ ] Install missing dependencies for backend (e.g., mvn clean install, gradle build, pip install -r requirements.txt)
- [ ] Install missing dependencies for frontend (e.g., npm install)
- [ ] Start the backend server.
- [ ] Start the frontend development server.
- [ ] Verify that both processes start without crashing. If an error occurs, analyze the logs, create a new subtask to fix the bug, and re-run the smoke test until it passes.
#### File Structure Verification and Dependency Installation
**BEFORE starting any application servers, you MUST:**
1. **Check Project Structure:**
```bash
# Run this command to see the current project structure
tree -L 2
```
2. **Identify Missing Files:**
- Look for common missing files like `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js`
- Check if all expected directories and files exist
- Note any files that are referenced in code but missing from the filesystem
3. **Create Missing Files:**
- If `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js` is missing, create it with proper content
- Create any other missing files that are referenced in the codebase
- Ensure all imports and references resolve correctly
4. **Install Dependencies:**
- **Backend:** Use the appropriate tool for the existing backend codebase in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/` (e.g., `mvn clean install`, `./gradlew build`, `pip install -r requirements.txt`, `npm install` for Node backend)
- **Frontend:** Run `npm install` inside `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`
- Install any missing system dependencies if needed
5. **Verify Dependencies:**
- Ensure all required packages are installed
- Check that import statements resolve correctly
- Verify no missing module errors exist
**Only proceed to start applications after completing these steps.**
#### Missing File Detection and Resolution
**CRITICAL: Always check for missing files before testing or starting applications**
1. **Common Missing Files to Check:**
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js` - Often referenced in React apps but missing
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/setupTests.js` - Testing setup files
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/index.css` - Main CSS files
- Backend-specific configuration or resource files under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`
2. **Detection Commands:**
```bash
# Check project structure
tree -L 2
# Check for specific missing files
find /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ -name "*.js" -o -name "*.ts" -o -name "*.css" | head -20
```
3. **Resolution Steps:**
- Create missing files with appropriate content
- Install missing dependencies
- Fix import/require statements
- Verify all references resolve correctly
4. **Example: Creating Missing reportWebVitals.js:**
```bash
# If /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js is missing, create it:
cat > /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js << 'EOF'
const reportWebVitals = (onPerfEntry) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
EOF
```
5. **Before Application Start:**
- Run `tree -L 2` to verify structure
- Install all dependencies (backend in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`, frontend in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`)
- Check for any missing file errors
- Only proceed when all files and dependencies are present
#### Implementation Workflow
For each subtask you implement:
1. **Start Subtask:** Update "Currently Working On" to the current subtask
2. **Implement Code:** Create all necessary code files for the subtask
3. **Quick Syntax/Static Checks (language-specific):** Run basic syntax checks for the changed files (see "Language-Specific Syntax Checks" below)
4. **Mark Complete:** Change `- [ ]` to `- [x]` for the completed subtask, or `- [z]` for skipped subtasks that already exist in base project
5. **Move to Next:** Update "Currently Working On" to the next subtask
6. **Update Status:** If a task is fully completed, add it to "Completed Tasks"
**MAIN TASK TESTING PHASE:**
After completing ALL subtasks for a main task:
1. **Verify File Structure:** Run `tree -L 2` to check for any missing files
2. **Create Missing Files:** If any files are missing (e.g., `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js`), create them with proper content
3. **Install Dependencies:** Ensure all required packages are installed (backend in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`, frontend in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`)
4. **Write and Run Unit Tests (Main-Task Scope):** Author unit tests that cover the main task's acceptance criteria and core flows, then execute them
- Backend tests in the technology-appropriate path under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`
- Frontend tests under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/__tests__/` or `tests/`
5. **Update Test Status:** Append ` — TEST: PASS` or ` — TEST: FAIL` to the main task header
6. **Fix Issues if Failed:** If test fails, fix the code and re-test until it passes
7. **Mark Main Task Complete:** Only mark the main task as complete after testing passes
#### Main Task Verification & Logging (Required)
For each main task (after all its subtasks are complete):
- **Author Main-Task Tests:** Create or update unit tests that validate the main task's acceptance criteria and error paths (backend under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`, frontend under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/__tests__/` or `tests/`).
- **Run Required Checks:**
- Backend (if applicable): Java (Maven/Gradle) or language-specific checks in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`.
- Frontend (if applicable): `npm install` in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`; if TS present: `npx -y tsc --noEmit || true`; if ESLint present: `npx -y eslint . || true`; if build script exists: `npm run build || true`; run tests (`npx -y jest --runInBand` or `npx -y vitest run`).
- **Log Result:** Append a concise entry to `.sureai/dev_test_log.md` documenting the main task name, commands executed, outcome (PASS/FAIL), and brief notes.
- **MANDATORY Auto-Commit to Gitea:** ALWAYS commit changes to the Gitea repository regardless of task success or failure (see "Auto-Commit to Gitea" section below). This is MANDATORY even if tests fail. Including the Task X after they are completed do the Auto-Commit to Gitea.
- **Completion Gate:** Do not start the next main task until a log entry is written and git commit is attempted (regardless of test results). And after Task X are completed do the commit.
#### Auto-Commit to Gitea (MANDATORY After Each Main Task + After Task X are completed)
**CRITICAL: This commit is MANDATORY regardless of task success or failure.** Always commit changes after each main task, even if tests fail or the task is incomplete. This ensures progress is saved and can be reviewed.
1. **Extract Project Name from io8 MCP Response:**
- Read `.sureai/io8_mcp/responses/create_project.out` (JSON format)
- Extract `projectResp.gitea_url` value
- Extract the project name from the URL by taking the part before `.git`
- Example: If `gitea_url` is `http://157.66.191.31:3000/risadmin_prod/calculator_app_10_053520.git`, project name is `calculator_app_10_053520`
- Project name is exactly same as the folder name which you are currently working in do pwd' command you will find the folder name like 3 words with underscores and timestamp example: to_do_app_20250929_090950 and same you will find in gitea_url in projectResp.gitea_url.
2. **Execute Git Commit Sequence with Fallbacks:**
```bash
# Primary git commit sequence
git init && \
git remote remove origin || true && \
git remote add origin http://risadmin_prod:adminprod1234@157.66.191.31:3000/risadmin_prod/${projectName}.git && \
git fetch origin main || true && \
git checkout -B main && \
git branch -u origin/main main || true && \
git pull origin main --allow-unrelated-histories || true && \
git add . && \
(git diff --cached --quiet || git commit -m "[COMMIT_MESSAGE]") && \
(git push -u origin main || git push -u origin main --force-with-lease)
# If primary sequence fails, try fallback commands:
# Fallback 1: Force commit with empty flag
git add . && git commit -m "[COMMIT_MESSAGE]" --allow-empty && \
(git push -u origin main || git push -u origin main --force-with-lease)
# Fallback 2: Reset and recommit
git reset --soft HEAD && git add . && git commit -m "[COMMIT_MESSAGE]" && \
(git push -u origin main || git push -u origin main --force-with-lease)
# Fallback 3: Force push (last resort)
git push -u origin main --force
```
3. **Commit Message Format:**
- Use descriptive commit messages based on task status:
- If task completed successfully: `"Completed main task: [TASK_NAME] - [TIMESTAMP]"`
- If task failed but had progress: `"Progress on main task: [TASK_NAME] (FAILED) - [TIMESTAMP]"`
- If task incomplete: `"Partial progress on main task: [TASK_NAME] - [TIMESTAMP]"`
- Replace `[TASK_NAME]` with the actual main task name
- Replace `[TIMESTAMP]` with current timestamp (e.g., `2025-01-15_14-30-25`)
4. **Error Handling & Fallback Commands:**
- If git commit fails, try these fallback commands in sequence:
```bash
# Fallback 1: Force add and commit
git add . && git commit -m "[COMMIT_MESSAGE]" --allow-empty
# Fallback 2: Reset and force commit
git reset --soft HEAD && git add . && git commit -m "[COMMIT_MESSAGE]"
# Fallback 3: Force push with lease
git push -u origin main --force-with-lease
# Fallback 4: If all else fails, force push (use with caution)
git push -u origin main --force
```
- If all fallback commands fail, log the error and continue with the next main task
- Always attempt the commit even if previous commits failed
- **CRITICAL:** Never skip git commit - always try multiple approaches until one succeeds
5. **Logging:**
- Log successful commits to `.sureai/dev_test_log.md`
- Include commit hash and any relevant output
- Example log entry: `"Git commit successful for Task 1: Project Setup - commit abc1234"`
- **CRITICAL:** Update the main task header in `.sureai/tasks_list.md` with commit status:
- If commit succeeds: Append ` — COMMIT: SUCCESSFUL` to the main task header
- If commit fails: Append ` — COMMIT: UNSUCCESSFUL` to the main task header
6. **Timing:**
- Execute git commit immediately after main task completion (regardless of test results)
- Do not proceed to the next main task until git commit is attempted
- If git commit fails, still proceed to next task but note the failure
- **CRITICAL:** Commit happens even if the main task failed - this preserves any progress made
7. **Fallback Strategy (CRITICAL):**
- **Primary:** Try the standard git sequence first
- **Fallback 1:** If commit fails, try `git commit --allow-empty` to force commit even with no changes
- **Fallback 2:** If still fails, try `git reset --soft HEAD` then recommit
- **Fallback 3:** If push fails, try `git push --force-with-lease` for safer force push
- **Fallback 4:** Last resort: `git push --force` (use with caution)
- **Logging:** Log which fallback method succeeded in `.sureai/dev_test_log.md`
- **Never Give Up:** Always try all fallback methods before declaring failure
8. **Main Task Header Status + Task X Examples:**
- **Successful task with successful commit:** `## Task 1: Project Setup — TEST: PASS — COMMIT: SUCCESSFUL`
- **Failed task with successful commit:** `## Task 2: Backend Setup — TEST: FAIL — COMMIT: SUCCESSFUL`
- **Successful task with failed commit:** `## Task 3: Frontend Setup — TEST: PASS — COMMIT: UNSUCCESSFUL`
- **Failed task with failed commit:** `## Task 4: Database Setup — TEST: FAIL — COMMIT: UNSUCCESSFUL`
- **Successful task with successful commit** `## Task X : Run server - Commit: SUCCESSFUL`
- **Failed task with failed commit** `## Task X : Run server - Commit: UNSUCCESSFUL`
### Code Implementation Phase
Based on the provided documents, create working code files using Gemini CLI:
1. **Use Gemini CLI to create files directly:**
```bash
# Example: Create a file within the dynamic frontend folder
mkdir -p /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src
cat > /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/example.js << 'EOF'
export const example = () => 'ok';
EOF
```
2. **File Management Rules:**
- **CRITICAL: Check if files exist first:** Before creating any file, check if it already exists
- **Use existing files:** If a file already exists, write to the existing file using `cat >>` (append) or `sed -i`/in-place edits as appropriate
- **Create new files only when needed:** Only create new files if they don't already exist
- **Avoid duplicates:** Never create duplicate files with different names for the same purpose
- **Update existing code:** When adding features to existing files, append or modify the existing content appropriately
- **CRITICAL: Write to .sureai/ folder:** All agent documents (tasks_list.md, etc.) must be written to the `.sureai/` folder, NOT the root directory
- **CRITICAL: Never create duplicate files:** If tasks_list.md exists in `.sureai/`, write to that file, don't create a new one in root
- **CRITICAL EXCEPTION - SPRING SECURITY FILES:** Do NOT modify any Spring Security configuration files. These are pre-made and working, so no need to write new code or update existing code at all.
- **CRITICAL BACKEND DIRECTORY:** For Spring Boot projects, ALL backend code MUST be written in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet` directory. No backend code should be written anywhere else. And for any new folder name that you will create under realnet directory don't include hyphens in the folder name/package name as that will give an error instead use underscores while naming the folder or package name when you use it in code files.
3. **Create all necessary files:**
- Backend application files under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet` (Java/Spring Boot, etc.) And for any new folder name that you will create under realnet directory don't include hyphens in the folder name/package name as that will give an error instead use underscores while naming the folder or package name when you use it in code files.
- Frontend files under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/` (Angular/React/etc.)
- Configuration files as required (prefer co-locating with the respective dynamic folder)
- Database schemas and migrations (backend dynamic folder)
- API endpoints and routes
- Templates and static files
4. **Folder Organization Rules:**
- **Backend code ONLY in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet`**
- **Frontend code ONLY in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`**
- **Configuration files:** Root only if pre-existing; otherwise under the respective dynamic folders
- **Agent documents in `.sureai/` folder**
- **Maintain separation; update in place**
### Implementation Guidelines
1. **Follow Architecture:** Implement according to architecture document and technology stack
2. **Code Quality:** Write clean, readable code with proper error handling
3. **File Organization:**
- Backend code in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/src/main/java/com/realnet`
- Frontend code in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`
- Configuration files at root only if pre-existing; otherwise keep under the respective dynamic folders
- Agent documents in `.sureai/` folder
4. **Follow Standards and UI/UX:** If available, follow `.sureai/coding-standard.md` and `.sureai/ui-ux.md`.
5. **Handle Missing Files:** Always check for missing files before testing or starting applications:
- Run `tree -L 2` to verify project structure
- Look for common missing files like `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/reportWebVitals.js`
- Create missing files with appropriate content
- Install all dependencies before proceeding
6. **Lombok Usage:** Use Lombok's @.io8project/project_metadata.json annotation instead of manually creating getters, setters, and constructors
### Language-Specific Unit Test Commands
- **Java (JUnit via Maven/Gradle):**
- Maven (in backend folder): `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/ && mvn -q -DskipITs test)`
- Gradle: `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/ && ./gradlew test)`
- **TypeScript/JavaScript (Jest or Vitest):**
- Create tests under `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/__tests__/` or `tests/`
- Run (Jest): `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ && npx -y jest --runInBand)`
- Run (Vitest): `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ && npx -y vitest run)`
- **Python (if applicable):**
- Create tests under backend path inside `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`
- Run: `pytest -q`
### Language-Specific Syntax Checks
After writing code for a subtask (and before marking it complete), run quick syntax/static checks based on the language(s) you modified:
- **TypeScript:** If `tsconfig.json` exists in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/`: `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ && npx -y tsc --noEmit)`
- **JavaScript (Node):** If ESLint configured: `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ && npx -y eslint . || true)`
- **Java:** Compile changed sources with Maven/Gradle in `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/`
- **Bash/Shell:** `bash -n <script.sh>`
Only run the checks relevant to the languages present in the project.
### Application Execution Commands (for Smoke Test)
- **Java/Spring Boot:** `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/ && mvn spring-boot:run)` or Gradle equivalent
- **Node/React/Angular Frontend:** `(cd /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ && npm start)`
**CRITICAL:** If the application fails to start, diagnose, fix, and retry until it runs successfully.
### Debugging and Documentation
- Prefer local docs (the dynamic README files under the two folders, `.sureai/*` docs) to keep context aligned with the current codebase.
### Output Requirements
**Update the existing `.sureai/tasks_list.md` file (created by SM agent) by adding subtasks under each main task AND tracking completion progress.**
- **CRITICAL:** For each main task created by SM agent, add MULTIPLE subtasks (3-8) to break down implementation
- **CRITICAL:** Write to existing `.sureai/tasks_list.md` created by SM agent, NOT create new files in root
- **CRITICAL:** Mark completed subtasks with `- [x]` and skipped subtasks with `- [z]` (for CRUD operations already in base project)
- **CRITICAL:** Focus on development subtasks only - NO testing tasks (handled by Tester agent)
- Create all necessary code files under the two dynamic folders as required
### Task Completion Tracking Rules
1. **Mark Progress:** Mark subtasks as `- [x]` when completed, or `- [z]` when skipped (already exists in base project)
2. **Update Current Task:** Change "Currently Working On" to next subtask
3. **Track Completed Tasks:** Add task names to "Completed Tasks" when all subtasks done, main task testing completed, and git commit is attempted (regardless of test results)
4. **CRITICAL:** Write to existing `.sureai/tasks_list.md` created by SM agent, never create new files
5. **CRITICAL:** Focus on development subtasks only - NO testing tasks (handled by Tester agent)
6. **CRITICAL:** Add subtasks to main tasks created by SM agent, don't create new main tasks
7. **CRITICAL:** Test entire main task functionality after all subtasks complete, append ` — TEST: PASS` or ` — TEST: FAIL` to the main task header
8. **CRITICAL:** MANDATORY auto-commit to Gitea after each main task completion - this happens regardless of task success or failure
### Important Notes
- **CRITICAL:** Use the existing dynamic folders `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/` and `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/`. Do NOT create new `backend/` or `frontend/` folders.
- **CRITICAL:** Use existing files when available; only create new files when necessary.
- **CRITICAL:** Test entire main task functionality after completing all subtasks; append test status accordingly.
- **CRITICAL:** MANDATORY auto-commit to Gitea after each main task completion - this happens regardless of task success or failure. Extract project name from `.sureai/io8_mcp/responses/create_project.out` and use the same git command sequence as the frontend button.
- **CRITICAL:** Even if a main task fails, commit the progress made - this preserves work and allows for review and continuation.
- Complete all subtasks sequentially without stopping, then test the main task as a whole, then MANDATORY commit to Gitea for the main tasks and task X.
### Anti-Blank Screen File Validation (CRITICAL)
**CRITICAL: Before completing any frontend subtask, validate that all frontend files contain actual content.**
#### Mandatory File Checks
After creating ANY frontend file, immediately verify:
1. **Check for Empty Files:**
```bash
# Check for completely empty files
find /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ -type f -empty
# Check for files smaller than minimum sizes
find /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ -name "*.html" -size -100c
find /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ -name "*.js" -size -50c
find /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/ -name "*.css" -size -20c
```
2. **Validate Critical Files:**
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/index.html:` Must contain DOCTYPE, head, body, and `<div id="root"></div>`
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/main.ts:` Must contain Angular bootstrapping code.
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/app/app.component.ts:` Must contain functional component that renders visible content
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/styles.scss:` Must contain basic styling
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/package.json:` Must contain valid JSON with dependencies
3. **Quick Validation Commands:**
```bash
# Verify file content exists
cat /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/index.html
cat /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/main.ts
cat /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/app/app.component.ts
# Check file sizes
wc -c /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/index.html /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/main.ts /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/app/app.component.ts
# Verify key content
grep -q "<clr-main-container>" /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/index.html && echo "✓ Clarity root element found" || echo "✗ Missing Clarity root element"
grep -q "platformBrowserDynamic().bootstrapModule(AppModule)" /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/main.ts && echo "✓ Angular bootstrapping found" || echo "✗ Missing Angular bootstrapping"
grep -q "selector: 'app-root'" /tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/app/app.component.ts && echo "✓ App component found" || echo "✗ Missing App component"
```
#### Blank Screen Prevention Checklist
**After all frontend subtask complete, verify:**
- [ ] All frontend files have content (not empty)
- [ ] `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/index.html` contains complete HTML with root element
- [ ] `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/main.ts` contains Angular rendering code
- [ ] `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/app/app.component.ts` contains functional component
- [ ] `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/src/styles.scss` contains basic styling
- [ ] `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/package.json` contains valid JSON with dependencies
**CRITICAL: Never mark a frontend subtask complete until all files are validated. Empty files cause blank screens.**

View File

@ -0,0 +1,210 @@
# Detailed Project Directory Structure (tree -a -L 3 --dirsfirst output)
.
├── .git
│   ├── branches
│   ├── hooks
│   │   ├── applypatch-msg.sample
│   │   ├── commit-msg.sample
│   │   ├── fsmonitor-watchman.sample
│   │   ├── post-update.sample
│   │   ├── pre-applypatch.sample
│   │   ├── pre-commit.sample
│   │   ├── pre-merge-commit.sample
│   │   ├── pre-push.sample
│   │   ├── pre-rebase.sample
│   │   ├── pre-receive.sample
│   │   ├── prepare-commit-msg.sample
│   │   ├── push-to-checkout.sample
│   │   ├── sendemail-validate.sample
│   │   └── update.sample
│   ├── info
│   │   └── exclude
│   ├── logs
│   │   ├── refs
│   │   └── HEAD
│   ├── objects
│   │   ├── 02
│   │   ├── 03
│   │   ├── 04
│   │   ├── 06
│   │   ├── 08
│   │   ├── 09
│   │   ├── 0c
│   │   ├── 0d
│   │   ├── 0e
│   │   ├── 11
│   │   ├── 18
│   │   ├── 1a
│   │   ├── 1b
│   │   ├── 1d
│   │   ├── 1e
│   │   ├── 20
│   │   ├── 21
│   │   ├── 22
│   │   ├── 26
│   │   ├── 2d
│   │   ├── 30
│   │   ├── 31
│   │   ├── 32
│   │   ├── 33
│   │   ├── 34
│   │   ├── 35
│   │   ├── 36
│   │   ├── 37
│   │   ├── 38
│   │   ├── 3b
│   │   ├── 3c
│   │   ├── 3d
│   │   ├── 3e
│   │   ├── 40
│   │   ├── 44
│   │   ├── 45
│   │   ├── 46
│   │   ├── 48
│   │   ├── 4a
│   │   ├── 4b
│   │   ├── 4e
│   │   ├── 4f
│   │   ├── 51
│   │   ├── 52
│   │   ├── 54
│   │   ├── 55
│   │   ├── 58
│   │   ├── 5a
│   │   ├── 5b
│   │   ├── 60
│   │   ├── 62
│   │   ├── 65
│   │   ├── 69
│   │   ├── 6b
│   │   ├── 6f
│   │   ├── 71
│   │   ├── 72
│   │   ├── 73
│   │   ├── 74
│   │   ├── 77
│   │   ├── 79
│   │   ├── 7b
│   │   ├── 7c
│   │   ├── 7e
│   │   ├── 83
│   │   ├── 85
│   │   ├── 86
│   │   ├── 87
│   │   ├── 8b
│   │   ├── 8e
│   │   ├── 91
│   │   ├── 92
│   │   ├── 94
│   │   ├── 95
│   │   ├── 97
│   │   ├── 98
│   │   ├── 99
│   │   ├── 9a
│   │   ├── 9d
│   │   ├── a0
│   │   ├── a1
│   │   ├── a3
│   │   ├── a6
│   │   ├── a7
│   │   ├── a8
│   │   ├── a9
│   │   ├── ae
│   │   ├── af
│   │   ├── b2
│   │   ├── b4
│   │   ├── b6
│   │   ├── b9
│   │   ├── ba
│   │   ├── bd
│   │   ├── be
│   │   ├── bf
│   │   ├── c0
│   │   ├── c1
│   │   ├── c3
│   │   ├── c5
│   │   ├── c7
│   │   ├── cb
│   │   ├── cd
│   │   ├── ce
│   │   ├── cf
│   │   ├── d2
│   │   ├── d3
│   │   ├── d7
│   │   ├── d9
│   │   ├── da
│   │   ├── db
│   │   ├── de
│   │   ├── e1
│   │   ├── e3
│   │   ├── e4
│   │   ├── e5
│   │   ├── e8
│   │   ├── e9
│   │   ├── ea
│   │   ├── ec
│   │   ├── ed
│   │   ├── f1
│   │   ├── f2
│   │   ├── f4
│   │   ├── f6
│   │   ├── f7
│   │   ├── fd
│   │   ├── fe
│   │   ├── info
│   │   └── pack
│   ├── refs
│   │   ├── heads
│   │   ├── remotes
│   │   └── tags
│   ├── COMMIT_EDITMSG
│   ├── FETCH_HEAD
│   ├── HEAD
│   ├── ORIG_HEAD
│   ├── config
│   ├── description
│   └── index
├── .io8project
│   ├── .state.json
│   └── project_metadata.json
├── .sureai
│   ├── io8_mcp
│   │   └── responses
│   ├── uploads
│   ├── .code_tree.txt
│   ├── .developer_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .directory_structure.txt
│   ├── .directory_structure_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8analyst_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8architect_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8codermaster_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8pm_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── .io8project_builder_messaging_app_20251010_040350.md
│   ├── .sm_agent_messaging_app_messaging_app_20251010_040350.md
│   ├── sprint_plan.md
│   └── tasks_list.md
├── messaging_app_20251010_040350-messaging_app_20251010_040350-b-b
│   └── authsec_springboot
│   ├── backend
│   └── .gitignore
├── messaging_app_20251010_040350-messaging_app_20251010_040350-d-d
│   └── authsec_mysql
│   └── mysql
├── messaging_app_20251010_040350-messaging_app_20251010_040350-f-f
│   └── authsec_angular
│   └── frontend
├── sureops
│   ├── messaging_app_20251010_040350-messaging_app_20251010_040350-b-b
│   │   └── deployment
│   ├── messaging_app_20251010_040350-messaging_app_20251010_040350-d-d
│   │   └── deployment
│   └── messaging_app_20251010_040350-messaging_app_20251010_040350-f-f
│   └── deployment
├── Dockerfile.backend
├── Dockerfile.frontend
├── deployment_config.yml
├── docker-compose.yml
└── nginx.conf
163 directories, 43 files

View File

@ -0,0 +1,93 @@
# Role: Scrum Master Agent - Messaging App Project
## Persona
- **Role:** Agile Process Facilitator & Team Coach for the Messaging App Project
- **Style:** Servant-leader, observant, facilitative, communicative, supportive, and proactive.
## Critical Instructions for Tasks List Creation
### Scope and Ownership
- The Scrum Master creates high-level development tasks only for the Messaging App project.
- **Do NOT include DevOps/deployment/infra tasks** in `tasks_list.md`. All such tasks are owned by the DevOps agent.
### Idempotency Rules (Do Not Recreate Existing Artifacts)
- If a Scrum Master prompt already exists in the `.sureai/` directory, do not create a new prompt file. Reuse the existing prompt. Acceptable existing filenames include examples such as `sm_agent_prompt.md` or `scrum_master_prompt.md` (any existing SM prompt in `.sureai/`).
- If the tasks file `.sureai/tasks_list.md` already exists, do not recreate or duplicate it. Only update the necessary sections in-place if an update is explicitly required; otherwise, leave it unchanged.
### Tasks List Template Structure
When creating the `.sureai/tasks_list.md` file, you MUST follow this exact template structure:
**CRITICAL FILE PATH REQUIREMENTS:**
- **MUST create this file in the `.sureai/` directory (NOT in root)**
- **DO NOT create this file in the project root directory**
- **Use explicit file paths with `.sureai/` prefix**
```markdown
# Project Tasks List
## Task 1: [Task Name]
[Main task description - NO SUBTASKS HERE]
## Task 2: [Task Name]
[Main task description - NO SUBTASKS HERE]
## Task 3: [Task Name]
[Main task description - NO SUBTASKS HERE]
## Current Task Status
**Currently Working On:** Task 1 - [Task Name]
**Next Task:** Task 2 - [Task Name]
**Completed Tasks:** None
```
### Reference Inputs (Frontend/Backend Feature Inventory)
- You MUST reference ONLY the following two README files to understand what already exists in the codebase for the Messaging App. Do not scan the entire repository.
- The folder names are derived from the user prompt and timestamp. Use the exact dynamic folders below and read their README.txt files:
- Frontend feature inventory:
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/README.txt`
- Backend feature inventory:
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-b-b/authsec_springboot/backend/README.txt`
- Do not guess file contents; open and read these two README files and base your understanding of existing features solely on them.
### Additional Planning Inputs (PRD & Project Plan)
- Also read the PM outputs stored under the dynamic frontend folder:
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/.sureai/prd_document.md`
- `/tmp/bmad_output/messaging_app_20251010_040350/messaging_app_20251010_040350-messaging_app_20251010_040350-f-f/authsec_angular/frontend/angular-clarity-master/.sureai/project_plan.md`
- Use these to understand scope and priorities before drafting tasks.
### Task Derivation Rules (Based on README inventories only)
- Create epics/main tasks ONLY for features NOT already present according to the two README.txt files listed above.
- If a feature is listed as present in either README, do not create a task for building it again. Instead, create integration or enhancement tasks if applicable.
- **CRITICAL: Do NOT create tasks for CRUD operations that are already documented in README.txt files.** Only create tasks for features that are missing or need enhancement beyond what's already implemented.
- Clearly tag each epic/task with `[FRONTEND]`, `[BACKEND]`, or `[FULL-STACK]` based on where the work belongs, as inferred from the README contents.
### Customized Scrum Master Workflow for Messaging App Project
#### 1. Project Understanding & Scope Definition
- **Review PM Documents:** Thoroughly read `prd_document.md` and `project_plan.md` to grasp the overall vision, goals, and high-level requirements for the messaging app.
- **Analyze Existing Features:** Read the provided `README.txt` files for both frontend and backend to identify already implemented functionalities. This is crucial to avoid duplicating work and to focus on missing features or enhancements.
#### 2. Task Planning Methodology
- **Feature-Driven Tasks:** Break down the messaging app requirements into high-level, independent features. Each feature will correspond to a "Task" in `tasks_list.md`.
- **No Subtasks:** Each task in `tasks_list.md` should be a single, concise statement of a major feature. Detailed subtasks will be handled by the Developer agent.
- **Tagging:** Each task will be tagged with `[FRONTEND]`, `[BACKEND]`, or `[FULL-STACK]` to indicate the primary area of development.
- **Prioritization:** Tasks will be implicitly prioritized based on their order in `tasks_list.md`, with the first task being the highest priority.
#### 3. Sprint Planning Approach
- **Iterative Development:** The project will follow an iterative approach, with tasks being picked up sequentially from `tasks_list.md`.
- **Focus on "Currently Working On":** The "Currently Working On" section in `tasks_list.md` will always reflect the task currently being addressed by the development team.
- **"Next Task" Identification:** The "Next Task" will be the subsequent task in the `tasks_list.md` that is not yet completed.
#### 4. Task Breakdown Framework
- **High-Level Epics:** The tasks in `tasks_list.md` serve as high-level epics for the messaging app.
- **Developer's Responsibility:** The Developer agent will be responsible for breaking down these high-level tasks into smaller, actionable subtasks, coding, and testing.
#### 5. Agile Methodology Considerations
- **Transparency:** The `tasks_list.md` will serve as a transparent backlog for the project.
- **Adaptability:** The task list can be re-prioritized or updated based on new information or changing project requirements.
- **Continuous Improvement:** Feedback from completed tasks will inform future planning and execution.
### Output and Handover
- Produce the `tasks_list.md` with only development tasks for the Messaging App.
- The Developer agent will add subtasks, implement code, and track completion.
- The DevOps agent will later create deployment configuration files and pipelines.

94
.sureai/sprint_plan.md Normal file
View File

@ -0,0 +1,94 @@
# Sprint Plan - Messaging App Project
This sprint plan outlines the phased approach for the Messaging App project, aligning with the Product Requirements Document (PRD) and focusing on iterative development.
## Phase 1: Discovery & Architecture (Completed)
**Goal:** Establish foundational project understanding and technical blueprints.
**Deliverables:** `analysis_document.md`, `architecture_document.md`, `tech_stack_document.md`, `prd_document.md`.
## Phase 2: Core Messaging MVP Development (Target: 8-10 weeks)
**Goal:** Deliver a fully functional 1:1 messaging system with secure authentication and message persistence.
### Sprint 1: Foundational Services & Authentication (Weeks 1-3)
**Focus:** Backend user authentication, profile management, and initial frontend integration.
**Tasks:**
- **Task 1: Implement Backend User Authentication & Profile Management [BACKEND]**
- Develop FastAPI services for user registration, login, profile CRUD, and user search.
- Implement JWT issuance/validation, secure password hashing (bcrypt).
- Define and implement initial PostgreSQL schema for Users.
- Implement API rate limiting on auth/registration endpoints.
- **Task 2: Develop Frontend User Authentication & Profile Integration [FRONTEND]**
- Integrate Angular Auth Module with Clarity UI for user registration/login.
- Implement secure JWT handling (storage, refresh mechanism).
- Develop basic User Profile view and update functionality.
- Implement Content Security Policy (CSP) for the frontend.
### Sprint 2: Real-time 1:1 Messaging & Persistence (Weeks 4-7)
**Focus:** Core one-to-one real-time messaging functionality.
**Tasks:**
- **Task 3: Build Full-Stack One-to-One Real-time Messaging (MVP) [FULL-STACK]**
- **Backend:** Develop Message Service (persistence in PostgreSQL), WebSocket Service (real-time delivery via FastAPI/Starlette).
- **Backend:** Integrate Redis for Pub/Sub and user presence management.
- **Backend:** Implement message buffering for offline users (Redis Streams/Lists).
- **Frontend:** Develop Angular Chat Module (1:1 chat UI, message input, real-time sending/receiving messages).
- **Frontend:** Implement display of paginated message history.
- **Frontend:** Integrate user presence display in the UI.
### Sprint 3: MVP Integration, QA & Local Deployment (Weeks 8-10)
**Focus:** End-to-end integration, testing, and local development setup.
**Tasks:**
- Full end-to-end integration of frontend and backend components.
- Implement unit and integration tests (Jest/Pytest) for all MVP features.
- Conduct initial performance testing for message latency and concurrent users.
- Configure `docker-compose.yml` for consistent local development across all services (Frontend, Backend API, WebSocket, Redis, PostgreSQL).
- Set up basic monitoring for the local development environment.
## Phase 3: Feature Expansion & Quality Assurance (Target: 6-8 weeks, starting after MVP)
**Goal:** Implement advanced messaging features and ensure high quality.
### Sprint 4: Group Chat & UI Enhancements (Weeks 1-3)
**Focus:** Group chat capabilities.
**Tasks:**
- **Task 4: Implement Full-Stack Group Chat Capabilities [FULL-STACK]**
- **Backend:** Extend Conversation Service for Group Chat management (creation, member add/remove).
- **Backend:** Extend Message Service for group messaging.
- **Frontend:** Develop UI for creating and managing group chats.
- **Frontend:** Enhance conversation list to differentiate 1:1 and group chats.
- **Frontend:** Develop an enhanced chat interface for group messaging.
### Sprint 5: Notifications & Media Sharing (Weeks 3-5)
**Focus:** Notifications and media sharing.
**Tasks:**
- **Task 5: Develop Full-Stack Enhanced Communication Features [FULL-STACK]**
- **Backend:** Develop Notification Service.
- **Backend:** Integrate with object storage (AWS S3/GCS) for File Storage Service.
- **Backend:** Implement background task queue (Celery/Redis) for media processing.
- **Frontend:** Implement in-app notification display.
- **Frontend:** Implement functionality for uploading and displaying various media types within chat conversations.
### Sprint 6: Comprehensive Testing & Optimization (Weeks 5-8)
**Focus:** Quality assurance, performance, and security.
**Tasks:**
- Conduct full E2E testing (Cypress/Playwright) for all features.
- Perform security audits and advanced load testing.
- Comprehensive performance optimization across all features.
- Extensive bug fixing.
- Refine monitoring dashboards (Grafana) and logging queries (Loki/ELK).
## Phase 4: Deployment Readiness & Operations (Target: 2-3 weeks, after Feature Expansion)
**Goal:** Prepare for production deployment and establish operational excellence.
### Sprint 7: CI/CD & Production Infrastructure Setup (Weeks 1-2)
**Focus:** Automation and production environment configuration.
**Tasks:**
- Set up robust CI/CD pipelines (GitHub Actions/GitLab CI) for automated linting, testing, container image building, vulnerability scanning, and deployment to staging environments.
- Configure production-grade infrastructure on cloud (e.g., Kubernetes/ECS, PostgreSQL with read replicas, Redis Cluster, Nginx load balancer).
- Establish secure environment variable management.
### Sprint 8: Monitoring, Logging & Production Deployment (Weeks 2-3)
**Focus:** Operational readiness and final deployment.
**Tasks:**
- Implement comprehensive monitoring (Prometheus/Grafana), centralized logging (Loki/ELK), and error tracking (Sentry) for production.
- Configure alerts for critical issues.
- Automate database backups.
- Final deployment of the application to the production environment, followed by post-deployment verification and continuous operational support.

60
.sureai/tasks_list.md Normal file
View File

@ -0,0 +1,60 @@
## Task 1: Implement Backend User Authentication & Profile Management [BACKEND]
Develop the Python FastAPI backend services for user registration, secure login (JWT-based), user profile management (view and edit), and user search functionality. This includes implementing secure password hashing (bcrypt), API rate limiting on authentication and registration endpoints, and defining the initial PostgreSQL database schema for users.
### 1.1 Database Schema for Users
- [x] Define and implement the PostgreSQL schema for users.
### 1.2 User Entity and Repository
- [x] Create the User entity and Spring Data JPA repository.
### 1.3 Authentication Service (Registration & Login)
- [x] Implement user registration with password hashing (bcrypt) and JWT-based login.
### 1.4 User Profile Service
- [x] Define UserProfile DTO for request and response.
- [x] Implement service method to retrieve user profile by ID.
- [x] Implement service method to update user profile.
- [x] Create REST controller endpoints for user profile management.
### 1.5 User Search Service
- [x] 1.5.1 Create UserSearchDTO for search results.
- [z] 1.5.2 Add search method to UserRepository.
- [ ] 1.5.3 Implement search logic in UserService.
- [ ] 1.5.4 Create REST endpoint for user search.
### 1.6 JWT Utility and Security Configuration
- [ ] Implement JWT token generation, validation, and integrate with Spring Security.
### 1.7 API Rate Limiting
- [ ] Implement rate limiting for authentication and registration endpoints.
## Task 2: Develop Frontend User Authentication & Profile Integration [FRONTEND]
Integrate the existing Angular Clarity frontend components for user authentication and profile management with the new FastAPI backend. This involves adapting the login, registration, and profile UI to consume the new backend APIs, implementing secure JWT handling (e.g., HttpOnly cookies, token refresh), developing new UI for user search, and displaying user online/offline presence. Also, implement a strict Content Security Policy (CSP) for the frontend.
## Task 3: Build Full-Stack One-to-One Real-time Messaging (MVP) [FULL-STACK]
Implement the core one-to-one real-time messaging functionality. This includes:
- **Backend:** Developing FastAPI/Starlette WebSocket services for real-time message delivery, implementing message persistence in PostgreSQL, utilizing Redis for Pub/Sub to scale WebSocket services, and using Redis Streams/Lists for guaranteed message delivery to offline users.
- **Frontend:** Developing Angular UI components for displaying a list of active conversations, an interactive chat window for sending and receiving messages in real-time, and efficiently loading and displaying historical messages.
## Task 4: Implement Full-Stack Group Chat Capabilities [FULL-STACK]
Extend the messaging application to support group conversations. This task involves:
- **Backend:** Developing APIs and WebSocket logic for creating new group chats, managing group members (add/remove), and handling message sending/receiving within groups.
- **Frontend:** Developing UI for creating and managing group chats, displaying group conversation lists, and an enhanced chat interface for group messaging.
## Task 5: Develop Full-Stack Enhanced Communication Features [FULL-STACK]
Introduce advanced communication features to enrich the user experience. This includes:
- **Backend:** Developing services for real-time new message notifications, user status notifications, and integrating with object storage for media sharing (upload/storage).
- **Frontend:** Implementing UI for displaying in-app notifications, visual indicators for user status, and functionality for uploading and displaying various media types within chat conversations.
## Current Task Status
**Currently Working On:** Task 1.5.2 - Add search method to UserRepository
**Next Task:** Task 2 - Develop Frontend User Authentication & Profile Integration [FRONTEND]
**Completed Tasks:** Task 1.4 - User Profile Service
## Task Completion Guidelines
- Use `- [x]` to mark completed subtasks (to be added by Developer)
- Use `- [ ]` for pending subtasks (to be added by Developer)
- Update "Currently Working On" when starting a new subtask (to be managed by Developer)
- Update "Completed Tasks" when finishing a task (to be managed by Developer)
- Always maintain the hierarchical structure (Task → Subtask → Subtask items)
- **IMPORTANT: Do NOT add subtasks here. Only create main tasks. Subtasks will be added by the Developer agent.

View File

@ -0,0 +1,11 @@
package com.realnet.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public class UserNotFoundException extends RuntimeException {
public UserNotFoundException(String message) {
super(message);
}
}

View File

@ -0,0 +1,18 @@
package com.realnet.userDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserSearchDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String username;
private String email;
}

View File

@ -0,0 +1,34 @@
package com.realnet.user_profile.controller;
import com.realnet.exceptions.UserNotFoundException;
import com.realnet.user_profile.entity.UserProfileDTO;
import com.realnet.user_profile.service.UserProfileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/user-profiles")
public class UserProfileController {
@Autowired
private UserProfileService userProfileService;
@GetMapping("/{id}")
public ResponseEntity<UserProfileDTO> getUserProfile(@PathVariable Long id) {
UserProfileDTO userProfile = userProfileService.getUserProfileById(id);
return ResponseEntity.ok(userProfile);
}
@PutMapping("/{id}")
public ResponseEntity<UserProfileDTO> updateUserProfile(@PathVariable Long id, @RequestBody UserProfileDTO userProfileDTO) {
UserProfileDTO updatedProfile = userProfileService.updateUserProfile(id, userProfileDTO);
return ResponseEntity.ok(updatedProfile);
}
@ExceptionHandler(UserNotFoundException.class)
public ResponseEntity<String> handleUserNotFoundException(UserNotFoundException ex) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.getMessage());
}
}

View File

@ -0,0 +1,17 @@
package com.realnet.user_profile.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserProfileDTO {
private Long id;
private String username;
private String email;
private String firstName;
private String lastName;
// Add other profile fields as needed
}

View File

@ -0,0 +1,53 @@
package com.realnet.user_profile.service;
import com.realnet.exceptions.UserNotFoundException;
import com.realnet.user_profile.entity.UserProfileDTO;
import com.realnet.users.entity.User;
import com.realnet.users.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Optional;
@Service
public class UserProfileService {
@Autowired
private UserRepository userRepository;
public UserProfileDTO getUserProfileById(Long id) {
User user = userRepository.findById(id)
.orElseThrow(() -> new UserNotFoundException("User not found with id: " + id));
return mapUserToUserProfileDTO(user);
}
public UserProfileDTO updateUserProfile(Long id, UserProfileDTO userProfileDTO) {
User user = userRepository.findById(id)
.orElseThrow(() -> new UserNotFoundException("User not found with id: " + id));
// Update user fields from DTO
user.setUsername(userProfileDTO.getUsername());
user.setEmail(userProfileDTO.getEmail());
// Assuming firstName and lastName are not directly in User entity,
// if they were, you would update them here.
// For now, only updating fields that exist in the User entity.
// If profilePictureUrl or status are part of UserProfileDTO, update them here.
user.setUpdatedAt(LocalDateTime.now());
User updatedUser = userRepository.save(user);
return mapUserToUserProfileDTO(updatedUser);
}
private UserProfileDTO mapUserToUserProfileDTO(User user) {
UserProfileDTO dto = new UserProfileDTO();
dto.setId(user.getId());
dto.setUsername(user.getUsername());
dto.setEmail(user.getEmail());
// Map other fields if they exist in User entity and UserProfileDTO
// For example, if User had getFirstName() and getLastName()
// dto.setFirstName(user.getFirstName());
// dto.setLastName(user.getLastName());
return dto;
}
}

View File

@ -0,0 +1,40 @@
package com.realnet.users.controller;
import com.realnet.users.entity.User;
import com.realnet.users.model.JwtResponse;
import com.realnet.users.model.LoginRequest;
import com.realnet.users.model.RegisterRequest;
import com.realnet.users.service.AuthService;
import com.realnet.users.util.JwtUtil; // Assuming this will be created in 1.6
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; // Assuming javax.validation is available
@RestController
@RequestMapping("/api/v1/auth")
public class AuthController {
@Autowired
private AuthService authService;
@Autowired
private JwtUtil jwtUtil; // Assuming this will be created in 1.6
@PostMapping("/register")
public ResponseEntity<?> registerUser(@Valid @RequestBody RegisterRequest registerRequest) {
User registeredUser = authService.registerUser(registerRequest);
return ResponseEntity.ok("User registered successfully!");
}
@PostMapping("/login")
public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) {
String jwt = authService.authenticateUserAndGenerateJwt(loginRequest);
// In a real application, you would fetch user details to populate JwtResponse
// For simplicity, let's assume we can get username from loginRequest for now
// and ID/email would be fetched from DB after authentication
// This part needs refinement with actual UserDetails implementation
return ResponseEntity.ok(new JwtResponse(jwt, null, loginRequest.getUsername(), null));
}
}

View File

@ -0,0 +1,60 @@
package com.realnet.users.controller;
import com.realnet.users.entity.User;
import com.realnet.users.model.UserProfileUpdateRequest;
import com.realnet.users.service.UserProfileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping("/api/v1/users")
public class UserProfileController {
@Autowired
private UserProfileService userProfileService;
// Helper method to get current authenticated user's ID
private Long getCurrentUserId() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// This assumes the principal is a User object or has an ID field
// In a real app, you'd likely have a custom UserDetails implementation
// For now, we'll assume the username is the ID for simplicity or fetch from DB
// This needs to be properly integrated with Spring Security's UserDetails
// For demonstration, let's return a dummy ID or throw an exception
throw new UnsupportedOperationException("User ID retrieval not yet implemented for current principal.");
}
@GetMapping("/me")
public ResponseEntity<User> getMyProfile() {
// This needs to be replaced with actual user ID from authenticated principal
// For now, using a placeholder or assuming ID is passed
Long userId = getCurrentUserId(); // Replace with actual logic to get authenticated user's ID
Optional<User> user = userProfileService.getUserProfile(userId);
return user.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
@PutMapping("/me")
public ResponseEntity<User> updateMyProfile(@Valid @RequestBody UserProfileUpdateRequest updateRequest) {
Long userId = getCurrentUserId(); // Replace with actual logic to get authenticated user's ID
try {
User updatedUser = userProfileService.updateUserProfile(userId, updateRequest);
return ResponseEntity.ok(updatedUser);
} catch (RuntimeException e) {
return ResponseEntity.badRequest().body(null); // Or more specific error handling
}
}
@GetMapping("/search")
public ResponseEntity<List<User>> searchUsers(@RequestParam String query) {
List<User> users = userProfileService.searchUsers(query);
return ResponseEntity.ok(users);
}
}

View File

@ -0,0 +1,47 @@
package com.realnet.users.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "users") // Map to the 'users' table in PostgreSQL
@Data
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) // SERIAL in PostgreSQL
private Long id;
@Column(unique = true, nullable = false, length = 50)
private String username;
@Column(unique = true, nullable = false, length = 100)
private String email;
@Column(name = "password_hash", nullable = false, length = 255)
private String passwordHash;
@Column(name = "profile_picture_url", length = 255)
private String profilePictureUrl;
@Column(length = 20)
private String status; // e.g., "online", "offline", "away"
@Column(name = "created_at", updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
}

View File

@ -0,0 +1,23 @@
package com.realnet.users.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JwtResponse {
private String token;
private String type = "Bearer";
private Long id;
private String username;
private String email;
public JwtResponse(String accessToken, Long id, String username, String email) {
this.token = accessToken;
this.id = id;
this.username = username;
this.email = email;
}
}

View File

@ -0,0 +1,9 @@
package com.realnet.users.model;
import lombok.Data;
@Data
public class LoginRequest {
private String username;
private String password;
}

View File

@ -0,0 +1,10 @@
package com.realnet.users.model;
import lombok.Data;
@Data
public class RegisterRequest {
private String username;
private String email;
private String password;
}

View File

@ -0,0 +1,10 @@
package com.realnet.users.model;
import lombok.Data;
@Data
public class UserProfileUpdateRequest {
private String email;
private String profilePictureUrl;
private String status;
}

View File

@ -0,0 +1,16 @@
package com.realnet.users.repository;
import com.realnet.users.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findByUsername(String username);
Optional<User> findByEmail(String email);
boolean existsByUsername(String username);
boolean existsByEmail(String email);
List<User> findByUsernameContainingIgnoreCaseOrEmailContainingIgnoreCase(String username, String email);
}

View File

@ -0,0 +1,63 @@
package com.realnet.users.service;
import com.realnet.users.entity.User;
import com.realnet.users.model.LoginRequest;
import com.realnet.users.model.RegisterRequest;
import com.realnet.users.repository.UserRepository;
import com.realnet.users.util.JwtUtil; // Assuming this will be created in 1.6
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
public class AuthService {
@Autowired
private UserRepository userRepository;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private AuthenticationManager authenticationManager; // Assuming this is configured by Spring Security
@Autowired
private JwtUtil jwtUtil; // Assuming this will be created in 1.6
public User registerUser(RegisterRequest registerRequest) {
if (userRepository.existsByUsername(registerRequest.getUsername())) {
throw new RuntimeException("Error: Username is already taken!");
}
if (userRepository.existsByEmail(registerRequest.getEmail())) {
throw new RuntimeException("Error: Email is already in use!");
}
User user = new User();
user.setUsername(registerRequest.getUsername());
user.setEmail(registerRequest.getEmail());
user.setPasswordHash(passwordEncoder.encode(registerRequest.getPassword()));
user.setStatus("offline"); // Default status
user.setCreatedAt(LocalDateTime.now());
user.setUpdatedAt(LocalDateTime.now());
return userRepository.save(user);
}
public String authenticateUserAndGenerateJwt(LoginRequest loginRequest) {
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));
SecurityContextHolder.getContext().setAuthentication(authentication);
// Assuming UserDetailsImpl is returned by UserDetailsService
// User userDetails = (User) authentication.getPrincipal(); // This might need casting to a custom UserDetails implementation
// For now, just use the username from the request
return jwtUtil.generateToken(loginRequest.getUsername()); // Generate token using username
}
}

View File

@ -0,0 +1,43 @@
package com.realnet.users.service;
import com.realnet.users.entity.User;
import com.realnet.users.model.UserProfileUpdateRequest;
import com.realnet.users.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
@Service
public class UserProfileService {
@Autowired
private UserRepository userRepository;
public Optional<User> getUserProfile(Long userId) {
return userRepository.findById(userId);
}
public User updateUserProfile(Long userId, UserProfileUpdateRequest updateRequest) {
return userRepository.findById(userId).map(user -> {
if (updateRequest.getEmail() != null && !updateRequest.getEmail().isEmpty()) {
user.setEmail(updateRequest.getEmail());
}
if (updateRequest.getProfilePictureUrl() != null && !updateRequest.getProfilePictureUrl().isEmpty()) {
user.setProfilePictureUrl(updateRequest.getProfilePictureUrl());
}
if (updateRequest.getStatus() != null && !updateRequest.getStatus().isEmpty()) {
user.setStatus(updateRequest.getStatus());
}
user.setUpdatedAt(LocalDateTime.now());
return userRepository.save(user);
}).orElseThrow(() -> new RuntimeException("User not found with id " + userId));
}
public List<User> searchUsers(String query) {
// This will search by username or email
return userRepository.findByUsernameContainingIgnoreCaseOrEmailContainingIgnoreCase(query, query);
}
}

View File

@ -301,3 +301,16 @@ CREATE TABLE logging_event_exception (
trace_line VARCHAR(256) NOT NULL,
PRIMARY KEY(event_id, i),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)); */
-- Table: users (Messaging App Users)
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
profile_picture_url TEXT,
status VARCHAR(20) DEFAULT 'offline',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);