Skip to content

feat: nDPI traffic category per conversation#56

Merged
NotYuSheng merged 5 commits intomainfrom
feature/ndpi-traffic-category
Mar 28, 2026
Merged

feat: nDPI traffic category per conversation#56
NotYuSheng merged 5 commits intomainfrom
feature/ndpi-traffic-category

Conversation

@NotYuSheng
Copy link
Copy Markdown
Owner

Closes #42

Summary

  • V6 migration: adds category VARCHAR(50) column to conversations
  • NdpiService: parses [cat: Name/ID] field from ndpiReader -v 2 output (e.g. Download, Web, VoIP) in the same single pass that extracts app names and risk flags
  • Backend propagation: ConversationEntity, ConversationResponse, ConversationDetailResponse all expose category; AnalysisSummaryResponse gains a CategoryStat inner class and a categoryDistribution list (packet count, bytes, percentage per category, sorted by packet count)
  • Frontend: new CategoryStat type and categoryDistribution field on AnalysisSummary; Conversation gains optional category; new CategoryBreakdownChart (pie + table) rendered in the Overview tab alongside the existing protocol chart; ConversationList table shows a Category column when any category data is present

Test plan

  • Upload a PCAP and confirm category is stored per conversation in the DB
  • Overview tab shows Category Distribution chart with correct categories (e.g. Download, Web)
  • Conversations table shows Category column with correct badges
  • ftp.pcap sample should show Download category for FTP flows and Web for the HTTP flow

🤖 Generated with Claude Code

- V6 migration: add category VARCHAR(50) to conversations
- NdpiService: parse [cat: Name/ID] from ndpiReader -v 2 output
- Propagate category through ConversationEntity, ConversationResponse,
  ConversationDetailResponse
- AnalysisSummaryResponse: add CategoryStat inner class and
  categoryDistribution field (aggregated packet/byte counts per category,
  sorted by packet count descending)
- AnalysisService: persist category, build categoryDistribution in
  getAnalysisSummary, propagate in getConversations/getConversationDetail/
  getSecurityAlerts
- Frontend: CategoryStat type, categoryDistribution in AnalysisSummary,
  category field in Conversation type
- CategoryBreakdownChart component (pie + table, mirrors ProtocolBreakdown)
  rendered in AnalysisOverview alongside protocol chart
- Category column in ConversationList table (shown only when data present)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces traffic category extraction and visualization, updating the backend to parse categories from nDPI output, store them in the database, and aggregate statistics for the analysis summary. The frontend is enhanced with a new category breakdown chart and a category column in the conversation list. Key feedback includes refactoring the aggregation logic in AnalysisService to replace magic indices with a more readable structure, centralizing the COLORS array and formatBytes utility in the frontend to reduce duplication, and applying dynamic coloring to category badges for better visual distinction.

Comment thread backend/src/main/java/com/tracepcap/analysis/service/AnalysisService.java Outdated
Comment thread frontend/src/components/analysis/CategoryBreakdown/CategoryBreakdownChart.tsx Outdated
Comment thread frontend/src/components/analysis/CategoryBreakdown/CategoryBreakdownChart.tsx Outdated
Comment thread frontend/src/components/conversation/ConversationList/ConversationList.tsx Outdated
NotYuSheng and others added 4 commits March 28, 2026 09:31
The backend changed detectedApplications from List<String> to
List<DetectedApplication>, but containers built from older code still
return plain strings. Coerce string items to {name, packetCount:0, bytes:0}
in the service layer so the UI never crashes accessing .packetCount.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- StoryService: add ## Traffic Category Breakdown section to LLM prompt
  (aggregated packet counts per nDPI category, sorted alphabetically)
- StoryService: inline [CAT: Name] label per conversation line alongside
  existing [app] and [RISKS: ...] labels
- StoryPage: replace generic subtitle with bullet list explaining how
  stories are generated and their limitations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- AnalysisService: replace long[] with named CategoryAggregate class and
  use Comparator.comparingLong().reversed() for sort
- CategoryBreakdownChart: use getAppColor() instead of local COLORS array;
  import formatBytes from @/utils/formatters instead of local definition
- ConversationList: style category badges with getAppColor() matching app badge pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NotYuSheng NotYuSheng merged commit e0e7862 into main Mar 28, 2026
@NotYuSheng NotYuSheng deleted the feature/ndpi-traffic-category branch March 28, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: nDPI traffic category per conversation

1 participant