Skip to main content

Overview

This page documents all TypeScript types used throughout the Argument Analysis Tool. These types define the structure of argument nodes, tweets, analysis results, and stored documents.

ArgumentNode

Represents a single node in an argument graph. Each node can be a thesis, claim, counterclaim, or evidence.
export type ArgumentNode = {
  id: string;
  parentId: string | null;
  type: 'thesis' | 'claim' | 'counterclaim' | 'evidence';
  side: 'for' | 'against';
  content: string;
  sourceText: string;
  source: string;
  fallacies: string[];
  logicalRole: string;
};

Fields

id
string
required
Unique identifier for the argument node.
parentId
string | null
required
The ID of the parent node in the argument tree. Set to null for root nodes (thesis statements).
type
'thesis' | 'claim' | 'counterclaim' | 'evidence'
required
The type of argument node:
  • thesis - The main proposition or statement being analyzed
  • claim - A supporting argument or assertion
  • counterclaim - An opposing argument or rebuttal
  • evidence - Supporting data, facts, or examples
side
'for' | 'against'
required
Which side of the argument this node supports:
  • for - Supports the thesis or parent claim
  • against - Opposes the thesis or parent claim
content
string
required
The main text content of the argument node. This is the synthesized or extracted argument statement.
sourceText
string
required
The original text from which this argument was extracted or derived. Used for traceability and verification.
source
string
required
The source URL or reference where this argument was found.Examples:
  • "https://example.com/article"
  • "User input"
  • "https://twitter.com/user/status/123"
fallacies
string[]
required
An array of logical fallacies detected in this argument node.Examples:
  • ["ad hominem", "straw man"]
  • [] (empty array if no fallacies detected)
logicalRole
string
required
A description of the logical role this node plays in the argument structure.Examples:
  • "Provides statistical evidence"
  • "Challenges the underlying assumption"
  • "Offers an alternative explanation"

ArgumentTree

Represents a hierarchical tree structure of arguments, where each node can have multiple children.
export type ArgumentTree = ArgumentNode & {
  children: ArgumentTree[];
};

Fields

...ArgumentNode
ArgumentNode
required
All fields from ArgumentNode are included.
children
ArgumentTree[]
required
An array of child argument trees. Each child is itself an ArgumentTree with its own potential children, forming a recursive structure.Empty array: [] for leaf nodes with no children

Example Structure

const exampleTree: ArgumentTree = {
  id: '1',
  parentId: null,
  type: 'thesis',
  side: 'for',
  content: 'Climate change requires immediate action',
  sourceText: '...',
  source: 'https://example.com',
  fallacies: [],
  logicalRole: 'Main thesis',
  children: [
    {
      id: '2',
      parentId: '1',
      type: 'claim',
      side: 'for',
      content: 'Global temperatures are rising',
      sourceText: '...',
      source: 'https://example.com',
      fallacies: [],
      logicalRole: 'Supporting claim',
      children: [
        {
          id: '3',
          parentId: '2',
          type: 'evidence',
          side: 'for',
          content: 'NASA data shows 1.5°C increase since 1880',
          sourceText: '...',
          source: 'https://climate.nasa.gov',
          fallacies: [],
          logicalRole: 'Statistical evidence',
          children: []
        }
      ]
    }
  ]
};

Tweet

Represents a tweet retrieved from X (Twitter) API v2.
export type Tweet = {
  id: string;
  text: string;
  author: {
    name: string;
    username: string;
    profile_image_url: string;
  };
  public_metrics: {
    retweet_count: number;
    reply_count: number;
    like_count: number;
    impression_count: number;
  };
  created_at: string;
};

Fields

id
string
required
The unique identifier for the tweet on X/Twitter.
text
string
required
The full text content of the tweet.
author
object
required
Information about the tweet’s author.
public_metrics
object
required
Engagement metrics for the tweet.
created_at
string
required
ISO 8601 timestamp of when the tweet was created.Format: "YYYY-MM-DDTHH:mm:ss.sssZ"Example: "2024-01-15T10:30:00.000Z"

AnalysisResult

Represents the complete result of an argument analysis operation.
export type AnalysisResult = {
  blueprint: ArgumentNode[];
  summary: string;
  analysis: string;
  socialPulse: string;
  tweets: Tweet[];
};

Fields

blueprint
ArgumentNode[]
required
A flat array of all argument nodes extracted from the analysis. These nodes can be reconstructed into an ArgumentTree structure using their id and parentId relationships.
summary
string
required
A concise summary of the argument and its main points. Provides a high-level overview of the analysis.
analysis
string
required
A detailed analysis of the argument structure, including:
  • Logical relationships between claims
  • Strength of evidence
  • Identified fallacies
  • Overall argument quality
  • Gaps in reasoning
socialPulse
string
required
An analysis of the social media discourse surrounding the topic, based on tweets retrieved during analysis. Describes:
  • Public sentiment
  • Common perspectives
  • Trending viewpoints
  • Social context
tweets
Tweet[]
required
An array of tweets collected during the analysis, representing public discourse on the topic.

ArgumentMapDocument

Represents a saved argument map document stored in Firestore.
export type ArgumentMapDocument = {
  id: string;
  userId: string;
  name: string;
  creationDate: Timestamp;
  jsonData: string; // This will be a JSON string of AnalysisResult
};

Fields

id
string
required
The unique document ID in Firestore.
userId
string
required
The ID of the user who created this argument map. Used for access control and ownership.
name
string
required
A user-provided name or title for the argument map.Examples:
  • "Climate Change Analysis - Jan 2024"
  • "Universal Basic Income Arguments"
creationDate
Timestamp
required
A Firestore Timestamp object representing when this document was created.Type: firebase/firestore/Timestamp
jsonData
string
required
A JSON-stringified representation of the AnalysisResult object. This field stores the complete analysis data including the argument blueprint, summary, analysis text, social pulse, and tweets.Usage: Parse this string to retrieve the AnalysisResult:
const analysisResult: AnalysisResult = JSON.parse(document.jsonData);

Source Code Location

src/lib/types.ts

Usage Examples

Working with ArgumentNodes

import type { ArgumentNode, ArgumentTree } from '@/lib/types';

// Create a flat list of nodes
const nodes: ArgumentNode[] = [
  {
    id: '1',
    parentId: null,
    type: 'thesis',
    side: 'for',
    content: 'Main argument',
    sourceText: 'Original text',
    source: 'https://example.com',
    fallacies: [],
    logicalRole: 'Thesis'
  },
  {
    id: '2',
    parentId: '1',
    type: 'claim',
    side: 'for',
    content: 'Supporting claim',
    sourceText: 'Evidence text',
    source: 'https://example.com',
    fallacies: [],
    logicalRole: 'Support'
  }
];

// Convert flat nodes to tree structure
function buildTree(nodes: ArgumentNode[]): ArgumentTree[] {
  const nodeMap = new Map<string, ArgumentTree>();
  const roots: ArgumentTree[] = [];
  
  // Initialize all nodes with empty children
  nodes.forEach(node => {
    nodeMap.set(node.id, { ...node, children: [] });
  });
  
  // Build parent-child relationships
  nodes.forEach(node => {
    const treeNode = nodeMap.get(node.id)!;
    if (node.parentId === null) {
      roots.push(treeNode);
    } else {
      const parent = nodeMap.get(node.parentId);
      if (parent) {
        parent.children.push(treeNode);
      }
    }
  });
  
  return roots;
}

Saving and Loading Analysis Results

import type { AnalysisResult, ArgumentMapDocument } from '@/lib/types';
import { Timestamp } from 'firebase/firestore';

// Prepare analysis result for storage
const analysisResult: AnalysisResult = {
  blueprint: [/* ... */],
  summary: 'Analysis summary',
  analysis: 'Detailed analysis',
  socialPulse: 'Social media insights',
  tweets: [/* ... */]
};

const document: ArgumentMapDocument = {
  id: 'doc123',
  userId: 'user456',
  name: 'My Analysis',
  creationDate: Timestamp.now(),
  jsonData: JSON.stringify(analysisResult)
};

// Later: retrieve and parse
const retrieved: ArgumentMapDocument = /* fetch from Firestore */;
const parsed: AnalysisResult = JSON.parse(retrieved.jsonData);

Build docs developers (and LLMs) love