# Royal Enfield Workflow Portal - Project Setup Guide

## 📁 Frontend Folder Structure (React.js)

```
re-workflow-portal-frontend/
├── public/
│   ├── assets/
│   │   ├── images/
│   │   ├── icons/
│   │   └── fonts/
│   └── favicon.ico
├── src/
│   ├── pages/
│   │   ├── auth/
│   │   │   ├── Login.jsx
│   │   │   └── Register.jsx
│   │   ├── dashboard/
│   │   │   └── Dashboard.jsx
│   │   ├── dealer-onboarding/
│   │   │   ├── DealerOnboarding.jsx
│   │   │   ├── applications/
│   │   │   │   └── Applications.jsx
│   │   │   ├── evaluation/
│   │   │   │   └── Evaluation.jsx
│   │   │   └── details/
│   │   │       └── DealerDetails.jsx
│   │   ├── dealer-offboarding/
│   │   │   ├── DealerOffboarding.jsx
│   │   │   ├── resignation/
│   │   │   │   ├── ResignationForm.jsx
│   │   │   │   ├── ResignationTracking.jsx
│   │   │   │   └── ResignationApproval.jsx
│   │   │   ├── termination/
│   │   │   │   ├── TerminationForm.jsx
│   │   │   │   ├── TerminationProcess.jsx
│   │   │   │   └── TerminationApproval.jsx
│   │   │   ├── full-final/
│   │   │   │   ├── FFTracking.jsx
│   │   │   │   ├── FFSettlement.jsx
│   │   │   │   └── FFStakeholderTracking.jsx
│   │   │   └── documents/
│   │   │       ├── ResignationLetter.jsx
│   │   │       ├── TerminationNotice.jsx
│   │   │       └── DocumentGeneration.jsx
│   │   ├── field-visit/
│   │   │   ├── FieldVisit.jsx
│   │   │   ├── planning/
│   │   │   │   └── Planning.jsx
│   │   │   ├── execution/
│   │   │   │   └── Execution.jsx
│   │   │   └── mom/
│   │   │       └── MOM.jsx
│   │   ├── dealer-claim/
│   │   │   ├── DealerClaim.jsx
│   │   │   ├── requests/
│   │   │   │   └── Requests.jsx
│   │   │   ├── proposals/
│   │   │   │   └── Proposals.jsx
│   │   │   └── approvals/
│   │   │       └── Approvals.jsx
│   │   ├── reports/
│   │   │   └── Reports.jsx
│   │   ├── masters/
│   │   │   ├── Masters.jsx
│   │   │   ├── towns/
│   │   │   │   └── Towns.jsx
│   │   │   ├── dealer-codes/
│   │   │   │   └── DealerCodes.jsx
│   │   │   ├── evaluation-criteria/
│   │   │   │   └── EvaluationCriteria.jsx
│   │   │   └── workflow-templates/
│   │   │       └── WorkflowTemplates.jsx
│   │   ├── workflow-engine/
│   │   │   ├── WorkflowEngine.jsx
│   │   │   ├── templatized/
│   │   │   │   └── TemplatizedWorkflow.jsx
│   │   │   ├── non-templatized/
│   │   │   │   └── NonTemplatizedWorkflow.jsx
│   │   │   └── template-builder/
│   │   │       └── TemplateBuilder.jsx
│   │   ├── user-management/
│   │   │   ├── UserManagement.jsx
│   │   │   ├── roles/
│   │   │   │   └── Roles.jsx
│   │   │   ├── permissions/
│   │   │   │   └── Permissions.jsx
│   │   │   └── regional-scoping/
│   │   │       └── RegionalScoping.jsx
│   │   └── NotFound.jsx
│   ├── components/
│   │   ├── common/
│   │   │   ├── Button/
│   │   │   │   └── Button.jsx
│   │   │   ├── Input/
│   │   │   │   └── Input.jsx
│   │   │   ├── Modal/
│   │   │   │   └── Modal.jsx
│   │   │   ├── Table/
│   │   │   │   └── Table.jsx
│   │   │   ├── Loader/
│   │   │   │   └── Loader.jsx
│   │   │   └── Notification/
│   │   │       └── Notification.jsx
│   │   ├── layout/
│   │   │   ├── Header/
│   │   │   │   └── Header.jsx
│   │   │   ├── Sidebar/
│   │   │   │   └── Sidebar.jsx
│   │   │   ├── Footer/
│   │   │   │   └── Footer.jsx
│   │   │   └── Breadcrumb/
│   │   │       └── Breadcrumb.jsx
│   │   ├── forms/
│   │   │   ├── DealerApplicationForm/
│   │   │   │   └── DealerApplicationForm.jsx
│   │   │   ├── QuestionnaireForm/
│   │   │   │   └── QuestionnaireForm.jsx
│   │   │   ├── EvaluationForm/
│   │   │   │   └── EvaluationForm.jsx
│   │   │   ├── ClaimForm/
│   │   │   │   └── ClaimForm.jsx
│   │   │   ├── ResignationForm/
│   │   │   │   └── ResignationForm.jsx
│   │   │   ├── TerminationForm/
│   │   │   │   └── TerminationForm.jsx
│   │   │   └── FFSettlementForm/
│   │   │       └── FFSettlementForm.jsx
│   │   ├── workflow/
│   │   │   ├── WorkflowViewer/
│   │   │   │   └── WorkflowViewer.jsx
│   │   │   ├── ApprovalFlow/
│   │   │   │   └── ApprovalFlow.jsx
│   │   │   ├── StatusTracker/
│   │   │   │   └── StatusTracker.jsx
│   │   │   ├── TemplateBuilder/
│   │   │   │   └── TemplateBuilder.jsx
│   │   │   ├── WorkflowEngine/
│   │   │   │   └── WorkflowEngine.jsx
│   │   │   ├── DynamicWorkflow/
│   │   │   │   └── DynamicWorkflow.jsx
│   │   │   ├── OCRProcessor/
│   │   │   │   └── OCRProcessor.jsx
│   │   │   └── DigitalSignature/
│   │   │       └── DigitalSignature.jsx
│   │   ├── user-management/
│   │   │   ├── RoleManager/
│   │   │   │   └── RoleManager.jsx
│   │   │   ├── PermissionMatrix/
│   │   │   │   └── PermissionMatrix.jsx
│   │   │   ├── RegionalScoping/
│   │   │   │   └── RegionalScoping.jsx
│   │   │   └── UserProfile/
│   │   │       └── UserProfile.jsx
│   │   ├── masters/
│   │   │   ├── MasterDataManager/
│   │   │   │   └── MasterDataManager.jsx
│   │   │   ├── TownManager/
│   │   │   │   └── TownManager.jsx
│   │   │   ├── DealerCodeManager/
│   │   │   │   └── DealerCodeManager.jsx
│   │   │   └── EvaluationCriteriaManager/
│   │   │       └── EvaluationCriteriaManager.jsx
│   │   ├── offboarding/
│   │   │   ├── ResignationManager/
│   │   │   │   └── ResignationManager.jsx
│   │   │   ├── TerminationManager/
│   │   │   │   └── TerminationManager.jsx
│   │   │   ├── FFSettlementManager/
│   │   │   │   └── FFSettlementManager.jsx
│   │   │   ├── DocumentGenerator/
│   │   │   │   └── DocumentGenerator.jsx
│   │   │   └── StakeholderTracker/
│   │   │       └── StakeholderTracker.jsx
│   │   └── dashboard/
│   │       ├── StatCard/
│   │       │   └── StatCard.jsx
│   │       ├── ChartWidget/
│   │       │   └── ChartWidget.jsx
│   │       └── RecentActivity/
│   │           └── RecentActivity.jsx
│   ├── hooks/
│   │   ├── useAuth.js
│   │   ├── useWorkflow.js
│   │   ├── useDealer.js
│   │   ├── useNotification.js
│   │   ├── useTemplate.js
│   │   ├── useOCR.js
│   │   ├── useDigitalSignature.js
│   │   ├── useUserManagement.js
│   │   ├── useMasterData.js
│   │   ├── useOffboarding.js
│   │   ├── useResignation.js
│   │   ├── useTermination.js
│   │   └── useFFSettlement.js
│   ├── lib/
│   │   ├── api/
│   │   │   ├── axios-config.js
│   │   │   ├── endpoints.js
│   │   │   └── interceptors.js
│   │   ├── utils/
│   │   │   ├── validation.js
│   │   │   ├── formatters.js
│   │   │   └── helpers.js
│   │   └── constants/
│   │       ├── roles.js
│   │       ├── status.js
│   │       └── routes.js
│   ├── services/
│   │   ├── auth.service.js
│   │   ├── dealer.service.js
│   │   ├── workflow.service.js
│   │   ├── field-visit.service.js
│   │   ├── claim.service.js
│   │   ├── report.service.js
│   │   ├── template.service.js
│   │   ├── ocr.service.js
│   │   ├── digital-signature.service.js
│   │   ├── user-management.service.js
│   │   ├── master-data.service.js
│   │   ├── sms.service.js
│   │   ├── push-notification.service.js
│   │   ├── offboarding.service.js
│   │   ├── resignation.service.js
│   │   ├── termination.service.js
│   │   └── ff-settlement.service.js
│   ├── store/
│   │   ├── slices/
│   │   │   ├── authSlice.js
│   │   │   ├── dealerSlice.js
│   │   │   ├── workflowSlice.js
│   │   │   ├── templateSlice.js
│   │   │   ├── userManagementSlice.js
│   │   │   ├── masterDataSlice.js
│   │   │   ├── notificationSlice.js
│   │   │   ├── offboardingSlice.js
│   │   │   ├── resignationSlice.js
│   │   │   ├── terminationSlice.js
│   │   │   └── ffSettlementSlice.js
│   │   └── index.js
│   ├── types/
│   │   ├── auth.types.js
│   │   ├── dealer.types.js
│   │   ├── workflow.types.js
│   │   ├── template.types.js
│   │   ├── user-management.types.js
│   │   ├── master-data.types.js
│   │   ├── notification.types.js
│   │   ├── offboarding.types.js
│   │   ├── resignation.types.js
│   │   ├── termination.types.js
│   │   ├── ff-settlement.types.js
│   │   └── common.types.js
│   ├── App.js
│   ├── index.js
│   └── setupTests.js
├── .env.local
├── .env.development
├── .env.production
├── webpack.config.js
├── tailwind.config.js
├── babel.config.js
├── package.json
├── package-lock.json
└── README.md
```

## 📁 Backend Folder Structure (Node.js)

```
re-workflow-portal-backend/
├── src/
│   ├── config/
│   │   ├── database.config.ts
│   │   ├── app.config.ts
│   │   ├── camunda.config.ts
│   │   ├── email.config.ts
│   │   └── ad.config.ts
│   ├── controllers/
│   │   ├── auth.controller.ts
│   │   ├── dealer.controller.ts
│   │   ├── workflow.controller.ts
│   │   ├── field-visit.controller.ts
│   │   ├── claim.controller.ts
│   │   ├── report.controller.ts
│   │   ├── master.controller.ts
│   │   ├── template.controller.ts
│   │   ├── ocr.controller.ts
│   │   ├── digital-signature.controller.ts
│   │   ├── user-management.controller.ts
│   │   └── notification.controller.ts
│   ├── services/
│   │   ├── auth/
│   │   │   ├── auth.service.ts
│   │   │   ├── ad.service.ts
│   │   │   └── jwt.service.ts
│   │   ├── dealer/
│   │   │   ├── dealer.service.ts
│   │   │   ├── onboarding.service.ts
│   │   │   ├── offboarding.service.ts
│   │   │   └── evaluation.service.ts
│   │   ├── workflow/
│   │   │   ├── camunda.service.ts
│   │   │   ├── approval.service.ts
│   │   │   └── notification.service.ts
│   │   ├── field-visit/
│   │   │   └── field-visit.service.ts
│   │   ├── claim/
│   │   │   └── claim.service.ts
│   │   ├── email/
│   │   │   ├── email.service.ts
│   │   │   └── template.service.ts
│   │   ├── report/
│   │   │   └── report.service.ts
│   │   └── integration/
│   │       ├── sap.service.ts
│   │       ├── dms.service.ts
│   │       ├── website-integration.service.ts
│   │       └── third-party-auditor.service.ts
│   │   ├── workflow/
│   │   │   ├── templatized-workflow.service.ts
│   │   │   ├── non-templatized-workflow.service.ts
│   │   │   └── template-builder.service.ts
│   │   ├── ocr/
│   │   │   └── ocr.service.ts
│   │   ├── digital-signature/
│   │   │   └── digital-signature.service.ts
│   │   ├── user-management/
│   │   │   ├── user-management.service.ts
│   │   │   ├── role-management.service.ts
│   │   │   └── regional-scoping.service.ts
│   │   ├── master-data/
│   │   │   └── master-data.service.ts
│   │   └── notification/
│   │       ├── sms.service.ts
│   │       └── push-notification.service.ts
│   ├── models/
│   │   ├── user.model.ts
│   │   ├── dealer.model.ts
│   │   ├── application.model.ts
│   │   ├── workflow.model.ts
│   │   ├── approval.model.ts
│   │   ├── field-visit.model.ts
│   │   ├── claim.model.ts
│   │   ├── document.model.ts
│   │   ├── master.model.ts
│   │   ├── template.model.ts
│   │   ├── workflow-template.model.ts
│   │   ├── ocr-result.model.ts
│   │   ├── digital-signature.model.ts
│   │   ├── role.model.ts
│   │   ├── permission.model.ts
│   │   ├── regional-scope.model.ts
│   │   └── notification.model.ts
│   ├── routes/
│   │   ├── auth.routes.ts
│   │   ├── dealer.routes.ts
│   │   ├── workflow.routes.ts
│   │   ├── field-visit.routes.ts
│   │   ├── claim.routes.ts
│   │   ├── report.routes.ts
│   │   ├── master.routes.ts
│   │   ├── template.routes.ts
│   │   ├── ocr.routes.ts
│   │   ├── digital-signature.routes.ts
│   │   ├── user-management.routes.ts
│   │   └── notification.routes.ts
│   ├── middleware/
│   │   ├── auth.middleware.ts
│   │   ├── role.middleware.ts
│   │   ├── validation.middleware.ts
│   │   ├── error.middleware.ts
│   │   └── logging.middleware.ts
│   ├── validators/
│   │   ├── dealer.validator.ts
│   │   ├── workflow.validator.ts
│   │   ├── claim.validator.ts
│   │   └── common.validator.ts
│   ├── utils/
│   │   ├── logger.ts
│   │   ├── response.ts
│   │   ├── error-handler.ts
│   │   ├── file-upload.ts
│   │   └── date-helper.ts
│   ├── jobs/
│   │   ├── email-reminder.job.ts
│   │   ├── application-expiry.job.ts
│   │   └── ff-notification.job.ts
│   ├── types/
│   │   ├── express.d.ts
│   │   └── custom.types.ts
│   └── app.ts
├── bpmn/
│   ├── dealer-onboarding.bpmn
│   ├── dealer-offboarding.bpmn
│   ├── field-visit.bpmn
│   └── claim-settlement.bpmn
├── tests/
│   ├── unit/
│   ├── integration/
│   └── e2e/
├── scripts/
│   ├── seed-data.ts
│   └── deploy-bpmn.ts
├── .env
├── .env.development
├── .env.production
├── tsconfig.json
├── package.json
└── README.md
```

## 🗂️ Database Structure (PostgreSQL)

**Note:** Updated from MongoDB to PostgreSQL for better ACID compliance, complex queries, and enterprise integration requirements.

```
Tables:
├── users
├── roles
├── permissions
├── regional_scopes
├── dealers
├── applications
├── questionnaires
├── evaluations
├── approvals
├── workflows
├── workflow_templates
├── template_instances
├── field_visits
├── claims
├── documents
├── ocr_results
├── digital_signatures
├── notifications
├── audit_logs
├── masters
│   ├── towns
│   ├── dealer_codes
│   ├── evaluation_criteria
│   └── workflow_definitions
├── reports_cache
├── sms_logs
├── push_notifications
└── website_integrations
```

## 📅 Sprint-wise Breakdown (16-18 Weeks)

### **Sprint 0: Setup & Infrastructure (1 Week)**
**Duration:** Week 1

**Frontend Tasks:**
- [ ] Initialize React.js project with Create React App or Vite
- [ ] Setup Tailwind CSS
- [ ] Configure folder structure
- [ ] Setup Redux Toolkit for state management
- [ ] Configure Axios interceptors
- [ ] Setup React Router DOM for routing
- [ ] Configure authentication scaffolding

**Backend Tasks:**
- [ ] Initialize Node.js/Express project
- [ ] Setup PostgreSQL connection with Prisma ORM
- [ ] Configure Camunda/Newgen integration
- [ ] Setup JWT authentication
- [ ] Configure email service (SMTP)
- [ ] Setup logging middleware
- [ ] Configure CORS and security headers

**DevOps:**
- [ ] Setup Git repository
- [ ] Configure CI/CD pipeline
- [ ] Setup development environment

---

### **Sprint 1: Authentication & User Management (2 Weeks)**
**Duration:** Week 2-3

**Frontend Tasks:**
- [ ] Login page with AD integration using React Router
- [ ] User registration form with React Hook Form
- [ ] Role management UI with Material-UI components
- [ ] User profile page with responsive design
- [ ] Dashboard layout with sidebar/header navigation

**Backend Tasks:**
- [ ] Implement AD authentication
- [ ] JWT token generation and validation
- [ ] User CRUD operations
- [ ] Role-based access control (RBAC)
- [ ] User profile management APIs

**Integration Points:**
- Login API → Frontend auth flow
- User registration → Email notification
- Role assignment → Permission matrix

**Deliverable:** Fully functional authentication system

---

### **Sprint 2: Master Data Management (1 Week)**
**Duration:** Week 4

**Frontend Tasks:**
- [ ] Master data management UI (towns, dealer codes, evaluation criteria, workflow definitions)
- [ ] CRUD forms for masters with validation
- [ ] Data tables with advanced filters and search
- [ ] Bulk upload functionality with progress tracking
- [ ] Master data versioning and audit trail

**Backend Tasks:**
- [ ] Master data APIs (CRUD with proper validation)
- [ ] Data validation and business rules
- [ ] Bulk upload processing with error handling
- [ ] Master data synchronization with external systems
- [ ] Audit logging for all master data changes

**Integration Points:**
- Master data APIs → Frontend forms
- File upload → Backend processing with validation
- External system sync → Master data updates

---

### **Sprint 2.5: Custom Workflow Engine (1 Week)**
**Duration:** Week 4.5

**Frontend Tasks:**
- [ ] Templatized workflow builder UI
- [ ] Non-templatized workflow creation interface
- [ ] Template selection and configuration
- [ ] Dynamic role assignment interface
- [ ] Workflow visualization and monitoring
- [ ] Exception handling and escalation UI

**Backend Tasks:**
- [ ] Templatized workflow engine implementation
- [ ] Non-templatized workflow engine implementation
- [ ] Template builder service with validation
- [ ] Dynamic role assignment logic
- [ ] Exception handling and escalation matrix
- [ ] Workflow state management and persistence

**Integration Points:**
- Workflow templates → Business process automation
- Dynamic workflows → Ad-hoc process handling
- Template builder → Workflow configuration

**Deliverable:** Fully functional custom workflow engine supporting both templatized and non-templatized workflows

---

### **Sprint 3-5: Dealer Onboarding Module (Phase 1) (3 Weeks)**
**Duration:** Week 5-7

#### **Sprint 3: Application Capture**

**Frontend Tasks:**
- [ ] "Become a Dealer" form integration
- [ ] Application listing with filters
- [ ] Application detail view
- [ ] Questionnaire web form

**Backend Tasks:**
- [ ] Website form integration API ("Become a Dealer" form capture)
- [ ] Real-time/hourly data synchronization from RE website
- [ ] Application capture and storage with validation
- [ ] Auto-acknowledgment email with template engine
- [ ] Opportunity/Non-opportunity email logic with vacancy checking
- [ ] Questionnaire generation and scoring with weighted ranking
- [ ] D+2 and D+5 reminder emails (cron job with configurable TAT)
- [ ] Third-party FDD auditor integration with OTP-protected links

**Integration:**
- Form submission → Backend processing → Email trigger
- Questionnaire link → Form submission → Scoring

#### **Sprint 4: Evaluation & Assignment**

**Frontend Tasks:**
- [ ] Shortlisting interface for DD team
- [ ] Evaluation form for ZM-DD
- [ ] Assignment workflow UI
- [ ] Approval tracking dashboard

**Backend Tasks:**
- [ ] Ranking algorithm implementation
- [ ] Assignment workflow (DD → ZM-DD → RBM → DDL)
- [ ] Approval logic with rejection handling
- [ ] Camunda workflow integration

**Integration:**
- Assignment actions → Workflow engine → Email notifications
- Status updates → Real-time dashboard refresh

#### **Sprint 5: Financial & Legal Approvals**

**Frontend Tasks:**
- [ ] FDD report upload interface
- [ ] NBH approval UI
- [ ] Document management interface

**Backend Tasks:**
- [ ] OTP-protected link generation
- [ ] FDD report processing
- [ ] NBH approval workflow
- [ ] Document storage (DMS integration)

---

### **Sprint 5.5: OCR & Digital Signature Integration (1 Week)**
**Duration:** Week 7.5

**Frontend Tasks:**
- [ ] Document upload interface with OCR preview
- [ ] Digital signature capture and validation UI
- [ ] OCR result display and verification
- [ ] Document comparison and validation interface
- [ ] Signature verification and audit trail

**Backend Tasks:**
- [ ] OCR service integration (third-party API)
- [ ] Document processing and text extraction
- [ ] Digital signature validation and storage
- [ ] Document verification and comparison logic
- [ ] Audit trail for all document operations
- [ ] Secure document storage with encryption

**Integration Points:**
- Document upload → OCR processing → Validation
- Digital signatures → Secure storage → Audit trail
- Document verification → Workflow automation

**Deliverable:** Complete OCR and digital signature functionality for document processing workflows

---

### **Sprint 6-7: Dealer Onboarding (Phase 2) (2 Weeks)**
**Duration:** Week 8-9

**Frontend Tasks:**
- [ ] LOI/LOA generation UI
- [ ] EOR audit scheduling interface
- [ ] Dealer information capture form
- [ ] Onboarding completion dashboard

**Backend Tasks:**
- [ ] LOI/LOA auto-generation
- [ ] Email automation with CC
- [ ] EOR audit workflow
- [ ] Dealer code assignment
- [ ] Integration with SAP (dealer creation)

**Integration:**
- Document generation → Email → Storage
- SAP API integration → Dealer code sync

---

### **Sprint 8-9: Dealer Offboarding (2 Weeks)**
**Duration:** Week 10-11

**Frontend Tasks:**
- [ ] Resignation submission form
- [ ] Termination process UI
- [ ] F&F tracking dashboard
- [ ] Multi-level approval interface

**Backend Tasks:**
- [ ] Resignation workflow (ZBH → DD Lead → NBH)
- [ ] Termination workflow (ZBH → DD Lead → NBH → CCO → CEO)
- [ ] Resignation acceptance letter generation
- [ ] Termination notice generation
- [ ] F&F process tracking
- [ ] Stakeholder notification system
- [ ] Dealer blocking logic

**Integration:**
- Resignation/Termination → Approval workflow → F&F initiation
- F&F tracking → Email reminders → Status updates

---

### **Sprint 10-11: Field Visit Report Module (2 Weeks)**
**Duration:** Week 12-13

**Frontend Tasks:**
- [ ] FJC planning interface
- [ ] Visit execution forms
- [ ] Discussion management UI
- [ ] MOM creation and tracking
- [ ] Document sharing interface

**Backend Tasks:**
- [ ] FJC planning APIs
- [ ] Visit scheduling and re-planning logic
- [ ] Discussion capture and storage
- [ ] MOM generation
- [ ] Approval workflow
- [ ] Document archiving

**Integration:**
- Planning → Execution → MOM → Approval → Archive

---

### **Sprint 12-13: Dealer Claim Settlement Module (2 Weeks)**
**Duration:** Week 14-15

**Frontend Tasks:**
- [ ] Activity request form
- [ ] Proposal submission interface
- [ ] Evaluation and approval UI
- [ ] Claim approval workflow
- [ ] Budget tracking dashboard

**Backend Tasks:**
- [ ] Request initiation workflow
- [ ] Proposal evaluation logic
- [ ] Multi-level approval (Requestor → Dept Lead)
- [ ] Budget blocking (IO integration)
- [ ] Activity creation automation
- [ ] Claim approval logic
- [ ] E-invoice and credit note generation

**Integration:**
- Request → Proposal → Approval → Budget → Activity → Claim

---

### **Sprint 14: Reports & Analytics (1 Week)**
**Duration:** Week 16

**Frontend Tasks:**
- [ ] Report listing with advanced filters and search
- [ ] Interactive dashboard widgets with real-time updates
- [ ] Excel/PDF export functionality with custom formatting
- [ ] Real-time metrics display with WebSocket integration
- [ ] Report scheduling and automated delivery
- [ ] Custom report builder interface

**Backend Tasks:**
- [ ] **Dealer-wise Report API** - Comprehensive dealer performance and status reports
- [ ] **MIS Report API** - Management Information System reports with KPIs
- [ ] **Pending Request Report API** - All pending requests with aging analysis
- [ ] **F&F Tracking Report API** - Full & Final settlement tracking by stakeholder
- [ ] **Application Summary Report API** - Application pipeline and conversion metrics
- [ ] Dashboard metrics API with real-time data
- [ ] Excel/PDF generation logic with custom templates
- [ ] Report caching and performance optimization

---

### **Sprint 15: Notifications & Cron Jobs (1 Week)**
**Duration:** Week 17

**Frontend Tasks:**
- [ ] Notification preferences management UI
- [ ] Real-time notification display with toast messages
- [ ] Notification history and tracking interface
- [ ] Multi-channel notification configuration

**Backend Tasks:**
- [ ] **Email Notification Service** - Template-based email with delivery tracking
- [ ] **SMS Notification Service** - Bulk SMS with delivery confirmation
- [ ] **Push Notification Service** - Firebase integration for mobile/web push
- [ ] Email reminder cron jobs with configurable schedules
- [ ] Application expiry job with escalation
- [ ] F&F reminder job with stakeholder notifications
- [ ] Approval pending reminder job with aging alerts
- [ ] Multi-channel notification orchestration
- [ ] Notification delivery tracking and analytics

---

### **Sprint 16: Testing & Bug Fixes (1 Week)**
**Duration:** Week 18

**Tasks:**
- [ ] Unit testing
- [ ] Integration testing
- [ ] UAT support
- [ ] Bug fixes
- [ ] Performance optimization

---

## 🔄 Frontend-Backend Integration Strategy

### **Parallel Development Approach**

```
Week 1: Setup (Both teams working on infrastructure)
├── Frontend: Project setup, authentication UI
└── Backend: Project setup, authentication APIs

Week 2-3: Authentication Module
├── Frontend builds login → Backend provides APIs → Integration
└── Daily sync meetings for API contract review

Week 4: Master Data
├── Frontend builds CRUD UI → Backend provides APIs → Integration
└── Mock data used initially, then real API integration

Week 5-7: Dealer Onboarding (Phase 1)
├── Frontend builds forms → Backend builds workflow → Integration
├── Mock APIs used for frontend development
└── Real integration after backend APIs are ready

... (Pattern continues for all sprints)
```

### **Integration Milestones**

1. **End of Sprint 1:** Authentication working end-to-end
2. **End of Sprint 2:** Master data management working
3. **End of Sprint 5:** Dealer onboarding (Phase 1) fully integrated
4. **End of Sprint 7:** Complete onboarding cycle working
5. **End of Sprint 9:** Offboarding workflows integrated
6. **End of Sprint 11:** Field visit module integrated
7. **End of Sprint 13:** Claim settlement module integrated
8. **End of Sprint 14:** All reports working

### **Daily Integration Workflow**

```
Morning Standup (15 mins)
├── Frontend team shares progress
├── Backend team shares API status
└── Identify integration blockers

Mid-day Sync (as needed)
├── API contract review
├── Mock data alignment
└── Quick integration tests

End of Day
├── Code push to develop branch
├── Integration testing on dev environment
└── Bug logging in ZOHO
```

### **API Development Process**

```
1. Backend team creates API documentation (Swagger/Postman)
2. Frontend team reviews and provides feedback
3. Backend implements APIs
4. Frontend uses mock APIs during development
5. Integration happens when backend APIs are ready
6. Testing on dev environment
7. Bug fixes and optimization
```

---

## 🛠️ Technology Stack

### Frontend
- **Framework:** React.js 18+ (Create React App / Vite)
- **Language:** JavaScript (ES6+) - Updated from TypeScript for simplicity
- **Styling:** Tailwind CSS
- **State Management:** Redux Toolkit / Zustand
- **API Client:** Axios
- **Form Handling:** React Hook Form + Yup
- **UI Components:** Material-UI / Ant Design
- **Charts:** Recharts / Chart.js
- **Date Handling:** date-fns
- **Routing:** React Router DOM
- **Build Tool:** Webpack / Vite

### Backend
- **Runtime:** Node.js 20+
- **Framework:** Express.js
- **Language:** TypeScript
- **Database:** PostgreSQL (Updated from MongoDB for better ACID compliance and enterprise integration)
- **ORM:** Prisma (Updated from Mongoose for PostgreSQL compatibility)
- **Authentication:** JWT + Passport.js
- **BPM Platform:** Camunda Zeebe (or Newgen)
- **Email:** Nodemailer
- **Validation:** Joi / Zod
- **Logging:** Winston
- **Cron Jobs:** node-cron

### DevOps
- **Version Control:** Git (GitLab)
- **Project Management:** ZOHO PMS
- **CI/CD:** GitLab CI or Jenkins
- **Hosting:** TBD (AWS/Azure)

---



## 📝 Key Integration Points

1. **Authentication Flow**
   - AD login → JWT token → Protected routes → Role-based access

2. **Website Integration**
   - "Become a Dealer" form → Real-time sync → Application processing

3. **Dealer Onboarding Flow**
   - Form submission → Workflow engine → Multi-level approvals → Multi-channel notifications

4. **Custom Workflow Engine**
   - Template selection → Dynamic role assignment → Process execution → Exception handling

5. **Document Management**
   - File upload → OCR processing → Digital signature → Secure storage → DMS integration

6. **SAP Integration**
   - Dealer creation → Budget blocking → Invoice generation → Code synchronization

7. **Multi-Channel Notifications**
   - Workflow events → Template engine → Email/SMS/Push dispatch → Delivery tracking

8. **Third-Party Integrations**
   - FDD auditor links → OTP validation → Document upload → Processing

9. **Real-time Updates**
   - WebSocket/SSE for dashboard updates → Live notifications → Status tracking

10. **Reporting Integration**
    - Data aggregation → Report generation → Export functionality → Scheduled delivery

---

## ✅ Best Practices

1. **API Versioning:** Use `/api/v1/` prefix
2. **Error Handling:** Consistent error response format
3. **Logging:** Log all API calls and errors
4. **Documentation:** Keep API documentation updated
5. **Code Reviews:** Mandatory for all PRs
6. **Testing:** Minimum 70% code coverage
7. **Security:** Input validation, SQL injection prevention, XSS protection

## 🔒 Enhanced Security & Compliance Features

### **DPDP Act Compliance**
- Data minimization and purpose limitation
- Explicit consent management with audit trails
- Data subject rights (access, portability, deletion)
- Data localization within India
- Breach notification within 72 hours
- Privacy by design implementation

### **Advanced Security Measures**
- WAF (Web Application Firewall) protection
- MFA (Multi-Factor Authentication) for sensitive roles
- JWT token management with secure rotation
- Field-level encryption for sensitive data
- Secure document storage with AES-256 encryption
- Comprehensive audit logging for compliance

### **Access Control & Authorization**
- Role-based access control (RBAC) with granular permissions
- Regional scoping for data access
- Principle of least privilege implementation
- Session management with automatic timeout
- API rate limiting and abuse prevention

---

