InfraForge Docs

InfraNotes CORE · v1.35.9

Welcome

Select a document from the sidebar to read it.

InfraNotes Frontend Implementation Order

Next.js + TypeScript Implementation Guide

Overview

This document outlines the complete frontend implementation order for InfraNotes, a comprehensive financial management system. The implementation is structured in logical phases that build upon each other, ensuring dependencies are satisfied and core business value is delivered early.


Phase 1: Invoice System

Priority: Immediate revenue-generating feature
Status: Implements core business functionality

1.1 Invoice Core Operations

API Endpoints:

  • GET /api/invoices - List invoices with filtering
  • POST /api/invoices - Create invoice
  • GET /api/invoices/{id} - Get invoice details
  • PUT /api/invoices/{id} - Update invoice
  • DELETE /api/invoices/{id} - Delete invoice
  • POST /api/invoices/{id}/status - Update invoice status

Components to Build:

// types/invoice.ts
export interface Invoice {
  id: string;
  invoice_number: string;
  client_id: string;
  status: 'draft' | 'sent' | 'paid' | 'partial' | 'overdue' | 'canceled';
  issue_date: string;
  due_date: string;
  subtotal: number;
  tax_amount: number;
  total_amount: number;
  items: InvoiceItem[];
}

// app/invoices/page.tsx - Invoice list page
// app/invoices/[id]/page.tsx - Invoice detail page
// app/invoices/new/page.tsx - Create invoice page
// components/invoices/InvoiceForm.tsx
// components/invoices/InvoiceList.tsx
// components/invoices/InvoiceStatusBadge.tsx

Key Features:

  • Invoice list with status filtering, pagination
  • Invoice creation form with line items
  • Invoice status management workflow
  • Basic invoice validation

1.2 Invoice Items & Advanced Features

API Endpoints:

  • POST /api/invoices/{id}/items - Add invoice item
  • PUT /api/invoices/{id}/items/{item_id} - Update invoice item
  • DELETE /api/invoices/{id}/items/{item_id} - Delete invoice item

Components to Build:

// components/invoices/InvoiceItemForm.tsx
// components/invoices/LineItemsTable.tsx
// components/invoices/InvoiceCalculations.tsx

Key Features:

  • Dynamic line item management
  • Tax and discount calculations
  • Invoice totals automation
  • Form validation with Zod

Phase 2: Client Management System

Priority: Required dependency for invoices
Status: Enables full invoice workflow

2.1 Client Core Operations (Week 3)

API Endpoints:

  • GET /api/clients - List clients with filtering
  • POST /api/clients - Create client
  • GET /api/clients/{id} - Get client details
  • PUT /api/clients/{id} - Update client
  • DELETE /api/clients/{id} - Delete client

Components to Build:

// types/client.ts
export interface Client {
  id: string;
  type: 'client' | 'vendor';
  category: 'individual' | 'organization';
  name: string;
  contact_name: string;
  email: string;
  phone: string;
  address: string;
  custom_fields: Record<string, any>;
  contacts: ContactPerson[];
}

// app/clients/page.tsx
// app/clients/[id]/page.tsx
// app/clients/new/page.tsx
// components/clients/ClientForm.tsx
// components/clients/ClientList.tsx
// components/clients/ClientCard.tsx

Key Features:

  • Client list with search and filtering
  • Support for both individual and organization clients
  • Client detail views with complete information
  • Client creation/editing forms

2.2 Contact Person Management

API Endpoints:

  • POST /api/clients/{id}/contacts - Add contact person
  • PUT /api/clients/{id}/contacts/{contact_id} - Update contact
  • DELETE /api/clients/{id}/contacts/{contact_id} - Delete contact
  • PUT /api/clients/{id}/contacts/{contact_id}/primary - Set primary contact

Components to Build:

// components/clients/ContactPersonForm.tsx
// components/clients/ContactPersonList.tsx
// components/clients/ContactPersonCard.tsx

Key Features:

  • Multiple contact persons per client
  • Primary contact designation
  • Contact person management within client details

Integration Points:

  • Update invoice forms to include client selection
  • Client dropdown in invoice creation

Phase 3: Financial Analytics Module

Priority: Core competitive advantage with AI/ML capabilities
Status: Replaces static dashboard with dynamic analytics

3.1 Document Management & Processing

API Endpoints:

  • POST /api/documents - Upload financial documents
  • GET /api/documents - List documents with status
  • GET /api/documents/{id} - Get document details
  • GET /api/documents/{id}/transactions - Get extracted transactions
  • DELETE /api/documents/{id} - Delete document

Components to Build:

// types/analytics.ts
export interface FinancialDocument {
  id: string;
  fileName: string;
  contentType: string;
  processStatus: 'pending' | 'processing' | 'completed' | 'failed';
  dataSource: 'personal_banking' | 'business_banking' | 'credit_card';
  transactionCount?: number;
}

// app/analytics/documents/page.tsx
// components/analytics/DocumentUpload.tsx
// components/analytics/DocumentList.tsx
// components/analytics/ProcessingStatus.tsx

Key Features:

  • Drag & drop file upload (PDF, CSV, XLSX)
  • Real-time processing status updates
  • Document list with processing history
  • Error handling for failed processing

3.2 Transaction Analytics Dashboard

API Endpoints:

  • GET /api/analytics/summary - Get analytics summary
  • GET /api/analytics/trends - Get trend analysis
  • GET /api/analytics/recurring - Get recurring transactions

Components to Build:

// Replace current static dashboard with dynamic data
// app/dashboard/page.tsx (enhance existing)
// components/analytics/AnalyticsSummary.tsx
// components/analytics/TrendChart.tsx
// components/analytics/CategoryChart.tsx
// components/analytics/RecurringTransactions.tsx

Key Features:

  • Replace static dashboard data with real analytics
  • Interactive trend charts
  • Expense categorization insights
  • Recurring transaction detection

3.3 Cash Flow Management & Predictions

API Endpoints:

  • GET /api/cashflow/predictions - Get cash flow predictions
  • GET /api/cashflow/alerts - Get financial alerts
  • GET /api/cashflow/snapshot/latest - Get current cash flow snapshot
  • GET /api/cashflow/ui/balance-projection - Get balance projection chart data

Components to Build:

// app/analytics/cashflow/page.tsx
// components/analytics/CashFlowPredictions.tsx
// components/analytics/FinancialAlerts.tsx
// components/analytics/BalanceProjection.tsx
// components/analytics/HealthIndicator.tsx

Key Features:

  • ML-based cash flow predictions
  • Financial health scoring
  • Smart alerts for potential issues
  • Interactive balance projection charts

Phase 4: Budget Management with Analytics Integration

Priority: Links expenses with planning and analytics
Status: Builds on transaction data from analytics

4.1 Budget Core Operations

API Endpoints:

  • GET /api/planning/budgets - List budgets
  • POST /api/planning/budgets - Create budget
  • GET /api/planning/budgets/{id} - Get budget details
  • GET /api/planning/budgets/{id}/progress - Get budget progress
  • PUT /api/planning/budgets/{id} - Update budget

Components to Build:

// types/budget.ts
export interface Budget {
  id: string;
  name: string;
  totalAmount: string;
  period: 'weekly' | 'monthly' | 'quarterly' | 'yearly';
  startDate: string;
  endDate: string;
  isActive: boolean;
  categories: BudgetCategory[];
}

// app/budgets/page.tsx
// app/budgets/[id]/page.tsx
// app/budgets/new/page.tsx
// components/budgets/BudgetForm.tsx
// components/budgets/BudgetProgress.tsx

Key Features:

  • Budget creation with category allocation
  • Real-time progress tracking
  • Budget vs actual spending visualization
  • Multi-period budget support

4.2 Budget-Expense Integration

API Endpoints:

  • GET /api/budgets/{id}/expenses - Get budget expenses
  • POST /api/budgets/{id}/expenses - Allocate expense to budget
  • POST /api/budgets/{id}/expenses/batch - Batch allocate expenses
  • POST /api/budgets/{id}/auto-allocate - Auto-allocate expenses

Components to Build:

// components/budgets/ExpenseAllocation.tsx
// components/budgets/AutoAllocation.tsx
// components/budgets/BudgetExpenseList.tsx
// components/budgets/AllocationHistory.tsx

Key Features:

  • Manual expense allocation to budgets
  • Batch allocation operations
  • Auto-allocation based on categories and dates
  • Allocation history tracking

Integration Points:

  • Connect with transaction analytics for smart allocation
  • Budget alerts based on spending patterns

Phase 5: Approval Workflows

Priority: Enterprise feature for multi-user environments
Status: Adds governance layer to invoices and expenses

5.1 Workflow Management

API Endpoints:

  • GET /api/approval/workflows - List workflows
  • POST /api/approval/workflows - Create workflow
  • GET /api/approval/workflows/{id} - Get workflow details
  • POST /api/approval/workflows/{id}/steps - Add workflow step
  • PUT /api/approval/workflows/{id}/default - Set default workflow

Components to Build:

// types/approval.ts
export interface ApprovalWorkflow {
  id: string;
  name: string;
  description: string;
  entity_type: 'invoice' | 'expense';
  min_amount_threshold: number;
  max_amount_threshold: number;
  steps: ApprovalStep[];
}

// app/workflows/page.tsx
// app/workflows/[id]/page.tsx
// app/workflows/new/page.tsx
// components/workflows/WorkflowBuilder.tsx
// components/workflows/StepConfiguration.tsx

Key Features:

  • Visual workflow builder
  • Multi-step approval chains
  • Amount-based threshold configuration
  • Approver assignment (users, roles, teams)

5.2 Approval Operations

API Endpoints:

  • GET /api/approval/instances - List approval instances
  • POST /api/approval/instances/{id}/approve - Approve item
  • POST /api/approval/instances/{id}/reject - Reject item
  • POST /api/approval/instances/{id}/delegate - Delegate approval

Components to Build:

// app/approvals/page.tsx
// components/approvals/PendingApprovals.tsx
// components/approvals/ApprovalActions.tsx
// components/approvals/ApprovalHistory.tsx
// components/approvals/DelegationManager.tsx

Key Features:

  • Pending approvals dashboard
  • Approve/reject/delegate actions
  • Approval history and audit trail
  • Delegation management

Integration Points:

  • Integrate with invoice creation (approval status)
  • Add approval workflow triggers to expense forms

Phase 6: Financial Goals & Planning

Priority: Advanced financial planning features
Status: Leverages analytics for goal tracking

6.1 Goal Management

API Endpoints:

  • GET /api/v1/goals - List financial goals
  • POST /api/v1/goals - Create goal
  • GET /api/v1/goals/{id}/analysis/progress - Get goal analysis
  • POST /api/v1/goals/{id}/contributions - Add contribution

Components to Build:

// app/goals/page.tsx
// app/goals/[id]/page.tsx
// app/goals/new/page.tsx
// components/goals/GoalForm.tsx
// components/goals/GoalProgress.tsx
// components/goals/ContributionForm.tsx

Key Features:

  • Financial goal creation and tracking
  • Progress visualization
  • Contribution management
  • Goal analysis with projections

6.2 Scenario Planning

API Endpoints:

  • GET /api/planning/scenarios - List scenarios
  • POST /api/planning/scenarios - Create scenario
  • POST /api/planning/scenarios/{id}/calculate - Calculate scenario
  • POST /api/planning/scenarios/compare - Compare scenarios

Components to Build:

// app/planning/scenarios/page.tsx
// components/planning/ScenarioBuilder.tsx
// components/planning/ScenarioComparison.tsx
// components/planning/ScenarioResults.tsx

Key Features:

  • What-if scenario modeling
  • Scenario comparison tools
  • Financial projections
  • Investment decision support

Phase 7: Enhanced Analytics & Reporting

Priority: Advanced reporting and insights
Status: Builds comprehensive reporting layer

7.1 Advanced Reports

API Endpoints:

  • GET /api/reports/financial-summary - Comprehensive financial reports
  • GET /api/reports/cash-flow - Detailed cash flow reports
  • GET /api/reports/budget-variance - Budget vs actual reports

Components to Build:

// app/reports/page.tsx
// components/reports/ReportBuilder.tsx
// components/reports/ExportOptions.tsx
// components/reports/ReportVisualization.tsx

Key Features:

  • Custom report generation
  • Multiple export formats (PDF, Excel, CSV)
  • Interactive report visualization
  • Scheduled report delivery

7.2 Performance Optimization & Polish

Technical Improvements:

  • Implement lazy loading for large datasets
  • Add skeleton loaders and optimistic updates
  • Enhance error boundaries and error handling
  • Mobile responsiveness improvements
  • Performance monitoring and optimization

Implementation Guidelines

State Management Strategy

// stores/useInvoiceStore.ts - Zustand for local state
// hooks/useInvoices.ts - React Query for server state
// lib/api.ts - Centralized API client configuration

API Integration Pattern

// lib/api.ts
export const apiClient = axios.create({
  baseURL: process.env.NEXT_PUBLIC_API_BASE_URL,
  timeout: 30000,
});

// Add request/response interceptors for auth and error handling

Component Structure

components/
├── ui/ (shared UI components)
├── invoices/ (invoice-specific components)
├── clients/ (client-specific components)
├── analytics/ (analytics components)
├── budgets/ (budget components)
├── workflows/ (workflow components)
└── reports/ (reporting components)

Dependencies Map

  • Invoices → Requires Clients for customer selection
  • Analytics → Independent, enhances Dashboard
  • Budgets → Benefits from Analytics data for smart allocation
  • Workflows → Integrates with Invoices and Expenses
  • Goals → Leverages Analytics for progress tracking
  • Reports → Requires all previous phases for comprehensive reporting

Testing Strategy

  • Unit tests for utility functions and hooks
  • Integration tests for API endpoints
  • E2E tests for critical user workflows (invoice creation, approval process)
  • Component testing with React Testing Library

This implementation order ensures that:

  1. Core business functionality (invoices) is delivered first
  2. Dependencies are satisfied in logical order
  3. Each phase builds value incrementally
  4. Advanced features enhance rather than block basic functionality
  5. The analytics capabilities are properly integrated throughout the system