# Developer Agent Instructions for Notes App Project

## Project Context
This document outlines the development and implementation strategy for the "Notes App" project. The project involves building a full-stack application with a Spring Boot backend and an Angular Clarity frontend. The primary goal is to enable users to create, read, update, and delete notes.

## Development Methodology
The development will follow an agile and iterative approach, with a strong emphasis on document-driven development. All implementation will strictly adhere to the requirements, architecture, and tech stack documents provided in the `.sureai/` directory, as well as the tasks defined in `tasks_list.md` and `sprint_plan.md`.

## Code Implementation Approach
The core of this project involves implementing CRUD (Create, Read, Update, Delete) operations for notes.

### Backend (Spring Boot)
- **API Design:** Develop RESTful APIs for managing notes, including endpoints for creating a new note, retrieving all notes, retrieving a single note by ID, updating an existing note, and deleting a note.
- **Data Model:** Define a `Note` entity with appropriate fields (e.g., `id`, `title`, `content`, `creationDate`, `lastModifiedDate`).
- **Persistence:** Utilize Spring Data JPA for database interactions, creating a `NoteRepository` interface.
- **Business Logic:** Implement `NoteService` to encapsulate business logic related to notes.
- **Controllers:** Create `NoteController` to expose the REST endpoints.
- **Error Handling:** Implement robust error handling for API endpoints.
- **Existing Conventions:** Adhere to the existing package structure and coding conventions found in `/tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-b-b/src/main/java/com/realnet/`.

### Frontend (Angular Clarity)
- **UI Components:** Develop Angular components for:
    - `NoteListComponent`: Displays a list of all notes.
    - `NoteDetailComponent`: Shows the details of a single note.
    - `NoteFormComponent`: Allows users to create new notes or edit existing ones.
- **Routing:** Configure Angular routing to navigate between different note-related views.
- **Services:** Create an `NoteService` to handle communication with the backend API.
- **Data Binding:** Implement two-way data binding for forms and display note data.
- **Clarity Design System:** Leverage Clarity components (e.g., `clr-datagrid`, `clr-forms`, `clr-modal`) for a consistent and modern UI.
- **Existing Conventions:** Adhere to the existing Angular project structure and coding conventions found in `/tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master/src/app/`.

## Technology Stack Implementation Strategy

### Backend
- **Framework:** Spring Boot
- **Language:** Java
- **Build Tool:** Maven (based on `pom.xml` in `notes_app_20251002_055810-notes_app_20251002_055810-b-b/authsec_springboot/backend/`)
- **Database:** MySQL (as indicated by `dump.sql` and `schema.sql` in the backend directory)
- **Dependencies:** Ensure all necessary Spring Boot starters (Web, Data JPA, MySQL Connector) are included in `pom.xml`.

### Frontend
- **Framework:** Angular
- **UI Library:** Clarity Design System
- **Language:** TypeScript
- **Build Tool:** npm/Angular CLI (based on `package.json` in `notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master/`)
- **Dependencies:** Ensure all required Angular and Clarity packages are installed.

## Code Organization and Structure Framework

### Backend (`notes_app_20251002_055810-notes_app_20251002_055810-b-b/authsec_springboot/backend/src/main/java/com/realnet/`)
- **`com.realnet.notes.entity`**: Contains the `Note` entity class.
- **`com.realnet.notes.repository`**: Contains the `NoteRepository` interface.
- **`com.realnet.notes.service`**: Contains the `NoteService` interface and its implementation.
- **`com.realnet.notes.controller`**: Contains the `NoteController` class.

### Frontend (`notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master/src/app/`)
- **`notes/`**: A new Angular module for all note-related features.
    - **`notes/components/`**: Contains `NoteListComponent`, `NoteDetailComponent`, `NoteFormComponent`.
    - **`notes/services/`**: Contains `note.service.ts` for API interaction.
    - **`notes/models/`**: Contains `note.model.ts` for the Note data structure.
    - **`notes/notes-routing.module.ts`**: Defines routes for the notes module.
    - **`notes/notes.module.ts`**: Declares and exports note-related components, services, and modules.

## Customized Development Workflow

1.  **Document Analysis:**
    - Read and understand `architecture_document.md`, `tech_stack_document.md`, `tasks_list.md`, and `sprint_plan.md` from the `.sureai/` directory.
    - Extract key requirements, architectural decisions, and task breakdowns.

2.  **Task Management and Implementation:**
    - **Update `tasks_list.md`:** For each main task defined by the SM agent, add 3-8 detailed subtasks.
    - **Mark Progress:** Use `- [x]` for completed subtasks and `- [z]` for skipped subtasks (e.g., existing CRUD operations in `README.txt`).
    - **Update Status:** Continuously update "Currently Working On" and "Completed Tasks" sections in `tasks_list.md`.
    - **Code Implementation:** Create and modify files directly using `write_file` or `replace` commands.
        - Backend code will reside in `/tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-b-b/`.
        - Frontend code will reside in `/tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-f-f/`.
    - **File Existence Check:** Always check if a file exists before creating it. If it exists, modify it in place; otherwise, create a new file.
    - **Frontend File Validation (Anti-Blank Screen):** Before marking any frontend subtask complete, ensure all created/modified frontend files contain actual content and are not empty. Verify critical files like `index.html`, `main.ts`, `app.component.ts`, and `package.json` for essential content.

3.  **Main Task Verification & Logging:**
    - After completing all subtasks for a main task:
        - **Verify File Structure:** Run `tree -L 2` to check for any missing files (e.g., `reportWebVitals.js`). Create them if missing.
        - **Install Dependencies:** Run `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-b-b/authsec_springboot/backend && mvn clean install)` for backend and `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master && npm install)` for frontend.
        - **Run Unit Tests:**
            - Backend: `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-b-b/authsec_springboot/backend && mvn -q -DskipITs test)`
            - Frontend: `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master && npx -y jest --runInBand)` (assuming Jest is configured, otherwise use `ng test` or similar).
        - **Syntax/Static Checks:**
            - Frontend (TypeScript): `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master && npx -y tsc --noEmit)`
        - **Log Results:** Append test results (`— TEST: PASS` or `— TEST: FAIL`) to the main task header in `tasks_list.md` and log to `.sureai/dev_test_log.md`.
        - **Fix and Re-test:** If tests fail, diagnose, fix the code, and re-run tests until they pass.

4.  **Auto-Commit to Gitea:**
    - After successful main task testing, automatically commit changes to the Gitea repository.
    - Extract the project name from `.sureai/io8_mcp/responses/create_project.out`.
    - Use the following git command sequence:
      ```bash
      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 "Completed main task: [TASK_NAME] - [TIMESTAMP]") && \
      (git push -u origin main || git push -u origin main --force-with-lease)
      ```
    - Log the commit status to `.sureai/dev_test_log.md`.

5.  **Application Smoke Test (Final Task):**
    - After all other main tasks are completed and committed:
        - Add `Task X: Application Smoke Test` to `tasks_list.md`.
        - Subtasks:
            - Check project file structure (`tree -L 2`).
            - Create any missing files (e.g., `reportWebVitals.js`).
            - Install missing backend dependencies (`mvn clean install`).
            - Install missing frontend dependencies (`npm install`).
            - Start backend server: `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-b-b/authsec_springboot/backend && mvn spring-boot:run)`
            - Start frontend server: `(cd /tmp/bmad_output/notes_app_20251002_055810/notes_app_20251002_055810-notes_app_20251002_055810-f-f/authsec_angular/frontend/angular-clarity-master && npm start)`
            - Verify both processes start without crashing. Fix any errors and re-run until successful.
        - Mark `— TEST: PASS` or `— TEST: FAIL` for the smoke test.
        - Log the smoke test results.
        - Auto-commit the final changes.