How pustur/whatsapp-chat-parser-website works
This project is a client-side web application built with React and TypeScript that allows users to upload and parse WhatsApp chat logs (in TXT or ZIP formats). The primary goal is to process an uploaded chat, extract text and media content (when available), and then display the chat in a user-friendly manner. The project uses several libraries (such as JSZip for handling ZIP files, the npm package “whatsapp-chat-parser” for parsing, and Styled Components for CSS styling) and a simple state management solution (using Jotai via custom store files).
Main Components
• UI/Frontend Layer:
• index.html & public/manifest.json: The static hosting and initial HTML file.
• React Components (located under src/components) including:
▪ Dropzone: For file upload.
▪ MessageViewer & Message: To display parsed chat messages.
▪ Filter components and ActiveUserSelector: To interact with filtered data.
▪ Credits, Poll, and Sidebar: Additional UI/UX elements.
• State Management:
• Stores (src/stores/global.ts and src/stores/filters.ts): Manage global and filter-specific states using Jotai.
• Utility & Parsing Layer:
• Integration with external libraries: whatsapp-chat-parser and JSZip.
• Build & Configuration:
• Vite configuration (vite.config.ts, tsconfig.json) and build scripts (npm start, npm run build).
• Linting and Prettier configuration files (.eslintrc, .prettierrc, etc.).
• Assets:
• Static assets (images, example chat ZIP in src/assets) that support UI display and testing.
Relationships and Interactions
• The user initiates the process by uploading a file using the Dropzone component.
• The file is then processed: if it is a ZIP file, JSZip is invoked to extract the contents.
• The extracted chat content is fed into the “whatsapp-chat-parser” library to convert it into a structured format.
• Parsed data is stored in state (using Jotai-managed stores) and then passed to various display components (MessageViewer, Message, etc.).
• Supporting components (e.g., FilterMessageDatesForm, FilterMessageLimitsForm, FilterModeSelector) interact with the state to provide filtering and user customization features.
• The UI updates dynamically based on state changes, giving the user immediate feedback.
Important Architectural Patterns and Design Principles
• Component-based architecture: The project is modular, with clearly separated components for upload, parsing, state management, and UI rendering.
• Unidirectional data flow: User actions (upload, filter changes) update global state, which then propagates to presentation components.
• Separation of concerns: Parsing logic is separated from the UI code; utilities and styling are modular.
• Reusability: Many React components (e.g., for displaying messages, polls, or filtering options) are designed to be reused across the application.
Final Recommendations
• Make it clear through labels and annotations why each component exists and how they interact, ensuring that any observer (especially someone familiar with system design) quickly understands the overall architecture.