A comprehensive React-based dashboard for analyzing customer behavior and sales data from an online jewelry store (Jouete). This dashboard provides deep insights into customer buying patterns, product performance, store operations, employee performance, and segmentation strategies to help increase sales.
- Overview
- Features
- Technologies
- Installation
- Data Structure
- Dashboard Components
- Analysis Capabilities
- Project Structure
- Usage
This dashboard is designed to answer key business questions:
- Customer Behavior: How do customers buy? What patterns can we identify?
- Product Performance: Which products drive revenue? What are the trends?
- Store Performance: How do different stores compare? Online vs brick-and-mortar?
- Employee Performance: Which employees drive the most sales? What products do they sell?
- Customer Segmentation: How can we segment customers for targeted marketing?
- Birthday Correlation: Is there a correlation between birthdays and sales?
- Temporal Patterns: When do customers buy? What days are busiest?
- KPI Cards: Total revenue, transactions, average order value, and active customers
- Tab-Based Navigation: Five main analysis sections:
- Customers (Who): Customer segmentation and behavior analysis
- Product (What): Product and collection performance with store breakdowns
- Stores (Where): Store performance with product breakdowns
- Employees: Employee sales performance with product breakdowns, filtering, and pagination
- Time (When): Temporal patterns, birthday correlations, and trends
- Build-Time Precomputation: All analysis data is precomputed at build time for lightning-fast load times
- Trend Analysis: Revenue, transactions, and customer trends over time
- Product Performance: Top 25 products/collections with store breakdowns (stacked bar charts)
- Product Trends: Top 25 products/collections trends over time
- Store Performance: Top 25 stores with product breakdowns (stacked bar charts)
- Store Trends: Top 25 stores trends over time
- Employee Performance: All employees with product breakdowns (stacked bar charts)
- Filter by store
- Pagination (10 employees per page)
- Top 10 products per employee, with "Others" category for remaining products
-
Advanced Customer Segmentation: Multiple segmentation dimensions:
- RFM Analysis: Recency, Frequency, Monetary segmentation (9 segments: Champions, Potential Loyalists, Loyal Customers, New Customers, At Risk, Cannot Lose Them, About to Sleep, Lost, Hibernating)
- Purchase Frequency: Very Frequent (10+), Frequent (5-9), Regular (2-4), One-Time
- Recency: Active (0-30 days), Recent (31-90), At Risk (91-180), Inactive (180+)
- Channel Preference: Online Only, Mixed (Online & Store), Store Only
- Average Order Value (AOV): High (>ยฅ15,000), Medium (ยฅ8,000-15,000), Low (<ยฅ8,000)
- Lifetime Value: VIP (>ยฅ100,000), High Value (ยฅ50,000-100,000), Regular (ยฅ20,000-50,000), Occasional (<ยฅ20,000)
-
Day of Week Analysis: Sales patterns across different days with revenue, transactions, and customer metrics
- Color/Material Trends: Top 8 colors or materials over time with trend lines
- Product Attributes: Track popularity of product attributes over time
- Birthday Correlation Heat Map: Visualize the relationship between customer birthdays (or important person birthdays) and sales
- Toggle between customer's own birthday and important person's birthday
- View by sales count, revenue, or transactions
- Color gradient from blue (cold/low sales) to red (hot/high sales)
- Analyzes sales within ยฑ30 days of birthdays
- React 19: Frontend framework
- TypeScript: Type-safe JavaScript
- Vite: Build tool and dev server
- Tailwind CSS 4: Utility-first CSS framework
- Recharts: React charting library for data visualization
- PapaParse: CSV parsing (used at build time)
- tsx: TypeScript execution for build scripts
-
Clone or navigate to the project directory
-
Install dependencies:
npm install
-
Ensure data files are in place:
public/data/sales_jouete_1y.csv- Sales transaction datapublic/data/member_jouete.csv- Customer/member data
-
Precompute analysis data (required before first run):
npm run precompute
This generates
public/data/precomputed.jsonwith all analysis results for fast loading. -
Start the development server:
npm run dev
-
Open your browser to the URL shown in the terminal (typically
http://localhost:5173) -
Build for production:
npm run build
Note: The build process automatically runs precomputation before building.
Contains one year of sales transaction data with the following key fields:
joueteไผๅก็ชๅท(Member ID)่ณผๅ ฅๆฅไป(Purchase Date)ๅๅผ้็ช(Transaction Number)ๅๅๅ(Product Name)ๅๅใณใผใ(Product Code)ๆฐ้(Quantity)้้ก(Amount)ๅบ่ๅ(Store Name)ๅบ่ใณใผใ(Store Code)ๆ ๅฝ่ ๅ(Staff Name)ๆ ๅฝ่ ใณใผใ(Staff Code)ๅๅๅ้กๅ(Product Category Name)ใขใคใใ ๅ(Item Name) - e.g., ใชใณใฐ (Ring), ใใใฏใฌใน (Necklace)็ด ๆๅ(Material Name)ใซใฉใผๅ(Color Name)ๅๅผๅ(Transaction Type) - ๅฃฒไธ (Sale) or ใญใฃใณใปใซ (Cancel)
Contains customer/member information:
joueteไผๅก็ชๅท(Member ID)็ๅนดๆๆฅ(Birth Date)ๆงๅฅ(Gender)้่ฆไบบ็ฉใฎ็ๅนดๆๆฅ(Important Person Birthday)่จๅฟตๆฅ(Anniversary)ใๆฐใซๅ ฅใๅบ่(Favorite Store)ๅๅ็ป้ฒๅบ่(First Registered Store)
Note: Data parsing automatically transforms Japanese headers to English property names.
Dashboard.tsx: Main orchestrator component managing state and data flowKPIs.tsx: Displays key performance indicator cards
CustomersTab.tsx: Customer segmentation and behavior analysisProductTab.tsx: Product and collection performance with trendsStoresTab.tsx: Store performance with trendsEmployeesTab.tsx: Employee sales performance with filtering and paginationTemporalTab.tsx: Time-based analysis including birthday correlations
TrendChart.tsx: Time series trends (revenue, transactions, customers)BirthdayHeatMap.tsx: Heat map visualization of birthday-sales correlationProductPerformance.tsx: Stacked horizontal bar chart of top 25 products/collections by storeProductTrendsChart.tsx: Line chart showing top 25 products/collections trends over timeStorePerformance.tsx: Stacked horizontal bar chart of top 25 stores by productStoreTrendsChart.tsx: Line chart showing top 25 stores trends over timeEmployeePerformanceChart.tsx: Stacked horizontal bar chart of all employees with product breakdownsAttributeTrends.tsx: Line chart showing color/material trends over timeAdvancedCustomerSegmentation.tsx: Comprehensive customer segmentation with multiple dimensionsDayOfWeekAnalysis.tsx: Bar chart showing sales patterns by day of week
KPICard.tsx: Reusable KPI display card
-
KPIs:
calculateKPIs(): Calculates total revenue, transactions, AOV, and active customers
-
Time Series Analysis:
getTrendsByGranularity(): Aggregates data by daily, 3-day, weekly, monthly, or quarterly periodsgetCategorySalesOverTime(): Sales volume by category over time
-
Product Analysis:
getTopProducts(): Top products by revenue, quantity, or transactionsgetProductTrends(): Product trends over timegetProductPerformanceWithStores(): Product performance broken down by storegetCollectionTrends(): Collection trends over timegetCollectionPerformanceWithStores(): Collection performance broken down by storegetAttributeTrends(): Trends for product attributes (color/material) over time
-
Store Analysis:
getStorePerformance(): Store comparison metrics (revenue, transactions, customers, AOV)getStoreTrends(): Store trends over timegetStorePerformanceWithProducts(): Store performance broken down by product
-
Employee Analysis:
getEmployeePerformance(): Employee sales performance with product breakdowns and store associations- Returns all employees (no limit)
- Includes store information for each employee
- Tracks top products sold by each employee
-
Customer Segmentation:
getCustomerDetails(): Comprehensive customer profile with purchase historygetRFMSegments(): RFM (Recency, Frequency, Monetary) analysisgetFrequencySegments(): Segments by purchase frequencygetRecencySegments(): Segments by days since last purchasegetChannelSegments(): Segments by shopping channel preferencegetAOVSegments(): Segments by average order valuegetCustomerSegments(): Segments by lifetime value
-
Temporal Analysis:
getDayOfWeekAnalysis(): Sales patterns by day of week
-
Birthday Analysis:
getBirthdaySalesCorrelation(): Analyzes sales correlation with birthdays- Handles year boundaries for accurate day-from-birthday calculations
- Supports both customer's own birthday and important person's birthday
-
Data Filtering:
filterSalesData(): Filters sales data by date range, categories, and stores
-
Precomputed Data Loader (
src/utils/precomputedDataLoader.ts):loadPrecomputedData(): Loads precomputed analysis results from JSON file- Caches data in memory for subsequent calls
- Validates data structure on load
-
Data Parser (
src/utils/dataParser.ts) - Used at build time:parseSalesCSV(): Parses sales CSV and transforms Japanese headers to EnglishparseMemberCSV(): Parses member CSV and transforms headers- Handles empty lines and validates required fields
-
Build Scripts (
scripts/precomputeData.ts):- Precomputes all analysis results at build time
- Generates
public/data/precomputed.jsonwith all calculated metrics - Processes 249,000+ sales records and 121,000+ member records
sales/
โโโ public/
โ โโโ data/
โ โโโ sales_jouete_1y.csv # Sales transaction data
โ โโโ member_jouete.csv # Customer/member data
โ โโโ precomputed.json # Precomputed analysis results (generated)
โโโ scripts/
โ โโโ precomputeData.ts # Build-time data precomputation script
โโโ src/
โ โโโ components/ # React components
โ โ โโโ CustomersTab.tsx # Customer analysis tab
โ โ โโโ ProductTab.tsx # Product analysis tab
โ โ โโโ StoresTab.tsx # Store analysis tab
โ โ โโโ EmployeesTab.tsx # Employee analysis tab
โ โ โโโ TemporalTab.tsx # Time analysis tab
โ โ โโโ AdvancedCustomerSegmentation.tsx
โ โ โโโ AttributeTrends.tsx
โ โ โโโ BirthdayHeatMap.tsx
โ โ โโโ Dashboard.tsx
โ โ โโโ DayOfWeekAnalysis.tsx
โ โ โโโ EmployeePerformanceChart.tsx
โ โ โโโ KPICard.tsx
โ โ โโโ KPIs.tsx
โ โ โโโ ProductPerformance.tsx
โ โ โโโ ProductTrendsChart.tsx
โ โ โโโ StorePerformance.tsx
โ โ โโโ StoreTrendsChart.tsx
โ โ โโโ TrendChart.tsx
โ โโโ utils/
โ โ โโโ dataAnalysis.ts # All analysis functions
โ โ โโโ dataParser.ts # CSV parsing utilities (build-time)
โ โ โโโ precomputedDataLoader.ts # Precomputed data loader
โ โโโ types.ts # TypeScript type definitions
โ โโโ App.tsx # Root component
โ โโโ main.tsx # Application entry point
โ โโโ index.css # Global styles (Tailwind)
โโโ package.json
โโโ tsconfig.json
โโโ vite.config.ts
โโโ README.md
- Default Date Range: Starts from Q3 2024 (July 1, 2024) due to data availability
- Default Granularity: Monthly
- Default Birthday Type: Important Person's Birthday
- Date Range: Select start and end dates to filter transactions
- Categories: Multi-select product categories (e.g., ใชใณใฐ, ใใใฏใฌใน)
- Stores: Multi-select store locations
- Clear Filters: Reset to default date range (Q3 2024)
Use the granularity selector to view data at different time intervals:
- Daily: Day-by-day breakdown
- 3-Day: 3-day aggregated periods
- Weekly: Weekly periods (ISO weeks)
- Monthly: Monthly aggregation
- Quarterly: Quarterly aggregation
The Advanced Customer Segmentation component allows you to switch between different segmentation dimensions:
- Click on any segmentation type button
- View pie chart for distribution
- View bar chart for revenue comparison
- Review detailed metrics in the segment cards below
- Toggle between "Customer's Own Birthday" and "Important Person's Birthday"
- Switch metrics: Sales Count, Revenue, or Transactions
- Hover over cells to see exact values
- Colors indicate intensity: Blue (cold/low) โ Red (hot/high)
- Product Performance: View top 25 products/collections with store breakdowns (stacked bars)
- Toggle between Product and Collection views
- Hover over bars to see detailed store breakdown in sidebar
- View trends over time for selected view type
- Store Performance: View top 25 stores with product breakdowns (stacked bars)
- Hover over bars to see detailed product breakdown in sidebar
- View store trends over time
- Attribute Trends: Switch between Color and Material views to see attribute popularity over time
- Employee Performance: View all employees with product breakdowns (stacked bars)
- Filter employees by store using the dropdown selector
- Paginate through employees (10 per page)
- Each employee shows top 10 products individually, with remaining products grouped as "Others"
- Hover over bars to see detailed product breakdown in sidebar
- All revenue is captured (top 10 products + Others = total revenue)
- Customer Lifetime Value: Identify VIP customers and high-value segments
- At-Risk Customers: Customers who haven't purchased recently but were valuable
- Product Winners: Top-performing products to focus marketing efforts
- Store Performance: Identify best-performing locations and opportunities
- Employee Performance: Identify top-performing sales staff and their product expertise
- Temporal Patterns: Understand when customers are most active
- Channel Preferences: Optimize online vs. brick-and-mortar strategies
- Birthday Marketing: Identify optimal timing for birthday promotions
- Product Trends: Track popularity of colors and materials over time
- Only transactions with
transactionType === "ๅฃฒไธ"(sales) are counted - Negative amounts are filtered out (refunds/cancellations)
- Store names are normalized (trimmed) to handle variations
- Default date filtering: Q3 2024 onwards (July 1, 2024)
- All monetary values are in Japanese Yen (ยฅ)
- Number formatting uses Japanese locale (
ja-JP) - All analysis is precomputed at build time for optimal performance
- Build-Time Precomputation: All analysis is performed at build time, not at runtime
- The precomputed JSON file contains all calculated metrics for instant loading
- CSV files are only processed during the build/precompute step
- The application loads precomputed data from
public/data/precomputed.json - If precomputed data is missing, the app will show a clear error message
- Run
npm run precomputeto regenerate analysis data after CSV updates - The build process automatically runs precomputation via the
prebuildhook
The dashboard uses Tailwind CSS with:
- Dark mode support
- Responsive grid layouts
- Consistent color scheme
- Interactive hover states
- Modern card-based design
Private project - All rights reserved
Built with โค๏ธ for understanding customer behavior and driving sales growth