# jakerains/clientcall architecture

> Architecture diagram of the GitHub repository jakerains/clientcall, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jakerains/clientcall
- Repository: https://github.com/jakerains/clientcall

## Overview

##### Main Components

Frontend Layer:
- Next.js Application (App Router)
- React Components
- Client-side Context Providers
- UI Components Library

Backend Layer:
- Next.js API Routes
- Server-Side Event (SSE) Handler
- Document Processing Service
- External Service Integrators

Data Layer:
- DynamoDB
- File Storage (for PDFs)

External Services:
- Bland AI Integration
- Amazon Bedrock
- AWS Services

**[Client Layer]**
- ↕
**[Application Layer]**
- ↕
**[Data Layer]**
- ↕
**[External Services]**

##### Component Relationships

Frontend → Backend:
- API routes connections (/api/appointments, /api/process-document)
- SSE connection for real-time updates
- Webhook endpoints

Backend → Data:
- DynamoDB interactions
- PDF document storage and retrieval

Backend → External Services:
- Bland AI API calls
- Amazon Bedrock integration
- AWS service connections

##### Specific Implementation Details

Following elements:

a) Frontend Components:
**[Next.js App Router]**
- ↓
**[React Components]**
- AppointmentCaller
- AppointmentsTable
- ClientDetailsSheet
- UploadSection
- ↓
**[Context Providers]**
- Appointments Context

b) Backend Services:
**[API Routes]**
- Appointments CRUD
- Document Processing
- Bland Webhook
- ↓
**[Service Layer]**
- Document Parser
- Bedrock Integration
- Bland API Service

c) Data Layer:
**[DynamoDB]**
- Appointments Table
- PK: APPOINTMENT#${id}
- SK: CLIENT#${clientName}
- GSI1: DATE#${appointmentDate}

##### Technical Stack Indicators

- Next.js 13+
- TypeScript
- DynamoDB
- Bland AI
- Amazon Bedrock
- TailwindCSS

##### Additional Notes

- Error handling paths
- Scaling considerations
- Stateful vs stateless components
- Deployment boundaries

- The AI-powered document processing workflow
- Real-time call management system
- Integration with external AI services
- Data flow between different system components

Remember to use standardized UML or C4 model notation where appropriate, but prioritize clarity and understanding over strict adherence to any particular notation system.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Start with User Interface
    User(("User")) --> NextApp
    
    subgraph Client["User Interface"]
        NextApp["Next.js App Router"]
        ReactComps["React Components"]
        UILib["UI Components Library"]
        Context["Context Providers"]
    end

    subgraph Components["User Interactions"]
        AppCaller["Appointment Caller"]
        AppTable["Appointments Table"]
        ClientSheet["Client Details Sheet"]
        UploadComp["Upload Section"]
    end

    subgraph Backend
        APIRoutes["API Routes"]
        SSEHandler["SSE Handler"]
        DocProcessor["Document Processing Service"]
    end

    subgraph Services
        BedrockInt["Bedrock Integration"]
        BlandService["Bland AI Service"]
        DocParser["Document Parser"]
        DynamoInt["DynamoDB Integration"]
    end

    subgraph DataLayer
        DynamoDB[(DynamoDB)]
        FileStorage[(File Storage)]
    end

    subgraph ExternalServices
        BlandAI["Bland AI"]
        Bedrock["Amazon Bedrock"]
        AWS["AWS Services"]
    end

    %% User Flow Relationships
    User --> AppCaller & AppTable & ClientSheet & UploadComp
    NextApp --> ReactComps
    ReactComps --> AppCaller & AppTable & ClientSheet & UploadComp
    ReactComps --> UILib
    ReactComps --> Context
    
    AppCaller & AppTable & ClientSheet & UploadComp --> APIRoutes
    APIRoutes --> SSEHandler
    APIRoutes --> DocProcessor
    APIRoutes --> Services
    
    DocProcessor --> DocParser
    DocProcessor --> BedrockInt
    
    Services --> DynamoDB
    Services --> FileStorage
    
    BedrockInt --> Bedrock
    BlandService --> BlandAI
    DynamoInt --> AWS

    %% Styling
    classDef frontend fill:#3b82f6,color:#fff
    classDef backend fill:#22c55e,color:#fff
    classDef data fill:#eab308,color:#000
    classDef external fill:#a855f7,color:#fff
    classDef user fill:#ff6b6b,color:#fff
    
    class User user
    class NextApp,ReactComps,UILib,Context,AppCaller,AppTable,ClientSheet,UploadComp frontend
    class APIRoutes,SSEHandler,DocProcessor,BedrockInt,BlandService,DocParser,DynamoInt backend
    class DynamoDB,FileStorage data
    class BlandAI,Bedrock,AWS external

    %% Click Events
    click NextApp "https://github.com/jakerains/clientcall/tree/master/app"
    click APIRoutes "https://github.com/jakerains/clientcall/tree/master/app/api"
    click AppCaller "https://github.com/jakerains/clientcall/blob/master/components/appointment-caller.tsx"
    click AppTable "https://github.com/jakerains/clientcall/blob/master/components/appointments-table.tsx"
    click ClientSheet "https://github.com/jakerains/clientcall/blob/master/components/client-details-sheet.tsx"
    click UploadComp "https://github.com/jakerains/clientcall/blob/master/components/upload-section.tsx"
    click Context "https://github.com/jakerains/clientcall/blob/master/contexts/appointments.tsx"
    click UILib "https://github.com/jakerains/clientcall/tree/master/components/ui"
    click BedrockInt "https://github.com/jakerains/clientcall/blob/master/lib/bedrock.ts"
    click BlandService "https://github.com/jakerains/clientcall/blob/master/lib/blandApi.ts"
    click DocParser "https://github.com/jakerains/clientcall/blob/master/lib/documentParser.ts"
    click DynamoInt "https://github.com/jakerains/clientcall/blob/master/lib/dynamodb.ts"
```
