# Narasi Ahli Implementation Checklist

## Database Schema Implementation

### ✅ Phase 1A: Update Users Entity
- [ ] Modify `app/database/entity/users/users.entity.go`
  - Add `Degree` field
  - Add `WhatsappNumber` field  
  - Add `LastJobTitle` field

### ✅ Phase 1B: Create New Entities

#### Education History Entity
- [ ] Create `app/database/entity/education_history.entity.go`
- [ ] Fields: ID, UserID, SchoolName, Major, EducationLevel, GraduationYear, CertificateImage

#### Work History Entity  
- [ ] Create `app/database/entity/work_history.entity.go`
- [ ] Fields: ID, UserID, JobTitle, CompanyName, StartDate, EndDate

#### Research Journals Entity
- [ ] Create `app/database/entity/research_journals.entity.go`
- [ ] Fields: ID, UserID, JournalTitle, Publisher, JournalURL, PublishedDate

#### Communication Entities
- [ ] Create `app/database/entity/conversations.entity.go`
- [ ] Create `app/database/entity/chat_messages.entity.go`
- [ ] Support for text, image, file, audio message types

#### AI Chat Entities
- [ ] Create `app/database/entity/ai_chat_sessions.entity.go`
- [ ] Create `app/database/entity/ai_chat_messages.entity.go`
- [ ] Create `app/database/entity/ai_chat_logs.entity.go`

## Module Implementation

### ✅ Phase 2A: Education History Module (`app/module/education_history/`)

#### Files to Create:
- [ ] `education_history.module.go` - FX dependency injection setup
- [ ] `controller/controller.go` - Main controller struct
- [ ] `controller/education_history.controller.go` - HTTP handlers
- [ ] `service/education_history.service.go` - Business logic
- [ ] `repository/education_history.repository.go` - Data access
- [ ] `request/education_history.request.go` - Input DTOs
- [ ] `response/education_history.response.go` - Output DTOs
- [ ] `mapper/education_history.mapper.go` - Entity ↔ DTO conversion

#### API Endpoints:
- [ ] `GET /education-history` - List with pagination
- [ ] `GET /education-history/:id` - Get by ID
- [ ] `POST /education-history` - Create new
- [ ] `PUT /education-history/:id` - Update existing
- [ ] `DELETE /education-history/:id` - Delete
- [ ] `POST /education-history/:id/certificate` - Upload certificate

### ✅ Phase 2B: Work History Module (`app/module/work_history/`)

#### Files to Create:
- [ ] `work_history.module.go`
- [ ] `controller/controller.go`
- [ ] `controller/work_history.controller.go`
- [ ] `service/work_history.service.go`
- [ ] `repository/work_history.repository.go`
- [ ] `request/work_history.request.go`
- [ ] `response/work_history.response.go`
- [ ] `mapper/work_history.mapper.go`

#### API Endpoints:
- [ ] `GET /work-history` - List with pagination
- [ ] `GET /work-history/:id` - Get by ID
- [ ] `POST /work-history` - Create new
- [ ] `PUT /work-history/:id` - Update existing
- [ ] `DELETE /work-history/:id` - Delete

### ✅ Phase 2C: Research Journals Module (`app/module/research_journals/`)

#### Files to Create:
- [ ] `research_journals.module.go`
- [ ] `controller/controller.go`
- [ ] `controller/research_journals.controller.go`
- [ ] `service/research_journals.service.go`
- [ ] `repository/research_journals.repository.go`
- [ ] `request/research_journals.request.go`
- [ ] `response/research_journals.response.go`
- [ ] `mapper/research_journals.mapper.go`

#### API Endpoints:
- [ ] `GET /research-journals` - List with pagination
- [ ] `GET /research-journals/:id` - Get by ID
- [ ] `POST /research-journals` - Create new
- [ ] `PUT /research-journals/:id` - Update existing
- [ ] `DELETE /research-journals/:id` - Delete

### ✅ Phase 2D: Communications Module (`app/module/communications/`)

#### Files to Create:
- [ ] `communications.module.go`
- [ ] `controller/controller.go`
- [ ] `controller/conversations.controller.go`
- [ ] `controller/chat_messages.controller.go`
- [ ] `service/conversations.service.go`
- [ ] `service/chat_messages.service.go`
- [ ] `service/file_upload.service.go`
- [ ] `repository/conversations.repository.go`
- [ ] `repository/chat_messages.repository.go`
- [ ] `request/conversations.request.go`
- [ ] `request/chat_messages.request.go`
- [ ] `response/conversations.response.go`
- [ ] `response/chat_messages.response.go`
- [ ] `mapper/conversations.mapper.go`
- [ ] `mapper/chat_messages.mapper.go`

#### API Endpoints:
- [ ] `GET /conversations` - List user conversations
- [ ] `GET /conversations/:id` - Get conversation details
- [ ] `POST /conversations` - Start new conversation
- [ ] `GET /conversations/:id/messages` - Get messages with pagination
- [ ] `POST /conversations/:id/messages` - Send text message
- [ ] `POST /conversations/:id/messages/file` - Send file message
- [ ] `PUT /conversations/:id/messages/:messageId/read` - Mark as read

### ✅ Phase 2E: AI Chat Module (`app/module/ai_chat/`)

#### Files to Create:
- [ ] `ai_chat.module.go`
- [ ] `controller/controller.go`
- [ ] `controller/ai_chat_sessions.controller.go`
- [ ] `controller/ai_chat_messages.controller.go`
- [ ] `service/ai_chat_sessions.service.go`
- [ ] `service/ai_chat_messages.service.go`
- [ ] `service/ai_integration.service.go`
- [ ] `repository/ai_chat_sessions.repository.go`
- [ ] `repository/ai_chat_messages.repository.go`
- [ ] `request/ai_chat_sessions.request.go`
- [ ] `request/ai_chat_messages.request.go`
- [ ] `response/ai_chat_sessions.response.go`
- [ ] `response/ai_chat_messages.response.go`
- [ ] `mapper/ai_chat_sessions.mapper.go`
- [ ] `mapper/ai_chat_messages.mapper.go`

#### API Endpoints:
- [ ] `GET /ai-chat/sessions` - List user sessions
- [ ] `POST /ai-chat/sessions` - Create new session
- [ ] `GET /ai-chat/sessions/:id` - Get session details
- [ ] `PUT /ai-chat/sessions/:id` - Update session (title, status)
- [ ] `DELETE /ai-chat/sessions/:id` - Delete session
- [ ] `GET /ai-chat/sessions/:id/messages` - Get messages
- [ ] `POST /ai-chat/sessions/:id/messages` - Send message to AI

### ✅ Phase 2F: AI Chat Logs Module (`app/module/ai_chat_logs/`)

#### Files to Create:
- [ ] `ai_chat_logs.module.go`
- [ ] `controller/controller.go`
- [ ] `controller/ai_chat_logs.controller.go`
- [ ] `service/ai_chat_logs.service.go`
- [ ] `repository/ai_chat_logs.repository.go`
- [ ] `request/ai_chat_logs.request.go`
- [ ] `response/ai_chat_logs.response.go`
- [ ] `mapper/ai_chat_logs.mapper.go`

#### API Endpoints:
- [ ] `GET /ai-chat-logs` - List logs with filters
- [ ] `GET /ai-chat-logs/:id` - Get specific log
- [ ] `POST /ai-chat-logs` - Create log entry
- [ ] `PUT /ai-chat-logs/:id` - Update log (end session)

## Integration Updates

### ✅ Phase 3A: Database Registration
- [ ] Update `app/database/index.database.go`
  - Add all new entities to `Models()` function
  - Ensure proper migration order

### ✅ Phase 3B: Router Registration  
- [ ] Update `app/router/api.go`
  - Add new router structs
  - Add constructor parameters
  - Add router registrations in `Register()` method

### ✅ Phase 3C: Main Application Updates
- [ ] Update `main.go`
  - Add new module imports
  - Add module providers to FX

### ✅ Phase 3D: Users Module Enhancement
- [ ] Update `app/module/users/request/users.request.go`
  - Add new fields to request DTOs
- [ ] Update `app/module/users/response/users.response.go`
  - Add new fields to response DTOs
- [ ] Update `app/module/users/mapper/users.mapper.go`
  - Handle new field mappings

## File Upload & Storage

### ✅ Phase 4A: File Upload Service
- [ ] Create `utils/service/file_upload.service.go`
- [ ] Support certificate images (education)
- [ ] Support chat attachments (photos, files, audio)
- [ ] Integration with existing MinIO setup

### ✅ Phase 4B: File Validation
- [ ] Implement file type validation
- [ ] Implement file size limits
- [ ] Implement security scanning

## Real-time Features (Optional)

### ✅ Phase 5A: WebSocket Support
- [ ] Add WebSocket handler for real-time chat
- [ ] Message broadcasting system
- [ ] Connection management

### ✅ Phase 5B: Push Notifications
- [ ] New message notifications
- [ ] AI response notifications

## Testing Implementation

### ✅ Phase 6A: Unit Tests
- [ ] Service layer tests for each module
- [ ] Repository layer tests
- [ ] Mapper tests

### ✅ Phase 6B: Integration Tests
- [ ] API endpoint tests
- [ ] Database integration tests
- [ ] File upload tests

## Documentation

### ✅ Phase 7A: API Documentation
- [ ] Update Swagger documentation for all endpoints
- [ ] Request/response examples
- [ ] Error response documentation

### ✅ Phase 7B: Database Documentation
- [ ] ERD diagram
- [ ] Table relationships
- [ ] Migration scripts

## Deployment Preparation

### ✅ Phase 8A: Configuration
- [ ] Environment variables for AI service
- [ ] MinIO bucket configuration
- [ ] Database migration scripts

### ✅ Phase 8B: Performance Optimization
- [ ] Database indexing
- [ ] Query optimization
- [ ] Caching strategy

## Quality Assurance

### ✅ Phase 9A: Code Review
- [ ] Follow existing code patterns
- [ ] Error handling consistency
- [ ] Security review

### ✅ Phase 9B: Performance Testing
- [ ] Load testing for chat features
- [ ] File upload performance
- [ ] Database query performance

---

## Implementation Notes

1. **Follow Existing Patterns**: Each module should follow the exact same structure as existing modules
2. **Database Constraints**: Add proper foreign key constraints and indexes
3. **Error Handling**: Use consistent error response format
4. **Authentication**: Ensure all endpoints properly validate user tokens
5. **Authorization**: Users can only access their own data
6. **Pagination**: Implement pagination for all list endpoints
7. **File Security**: Validate file uploads and implement virus scanning
8. **API Versioning**: Consider version compatibility for future updates

## Priority Order

1. **High Priority**: Users profile updates, Education History, Work History
2. **Medium Priority**: Research Journals, Basic Communication
3. **Low Priority**: AI Chat, Real-time features, Advanced communication features

This checklist ensures systematic implementation while maintaining code quality and consistency with the existing architecture.
