Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
**/dist
**/tmp
**/out-tsc
**/bazel-out

# Node
**/node_modules
**/npm-debug.log
**/yarn-error.log

# Miscellaneous
**/.sass-cache/
**/connect.lock
**/coverage
**/libpeerconnection.log
**/testem.log
**/typings

# System files
**/.DS_Store
**/Thumbs.db

**/HELP.md
**/.gradle
**/build/
!**/gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
**/.idea
**/*.iws
**/*.iml
**/*.ipr
**/out/
!**/src/main/**/out/
!**/src/test/**/out/

### VS Code ###
**/.vscode/

# React specific
**/build/
**/.eslintcache
**/node_modules/
24 changes: 24 additions & 0 deletions sales analytics_UI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
12 changes: 12 additions & 0 deletions sales analytics_UI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
33 changes: 33 additions & 0 deletions sales analytics_UI/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'

export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...js.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
]
112 changes: 112 additions & 0 deletions sales analytics_UI/generateSyntheticEcommerceData.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Give this file the name 'generateSyntheticEcommerceData.js'
/**
* Generates a large CSV file with random e-commerce orders for testing data-intensive applications.
* Usage (from terminal): node generateSyntheticEcommerceData.js
*/

const fs = require("fs");
const { v4: uuidv4 } = require("uuid");

// Define some sample products, user pools, and geolocations
const products = [
{ product_id: 1001, name: "Wireless Mouse", base_price: 19.99 },
{ product_id: 1002, name: "Bluetooth Headphones", base_price: 49.99 },
{ product_id: 1003, name: "Mechanical Keyboard", base_price: 89.99 },
{ product_id: 1004, name: "USB-C Cable", base_price: 9.99 },
{ product_id: 1005, name: "Webcam", base_price: 39.99 },
{ product_id: 1006, name: "Laptop Stand", base_price: 25.99 },
{ product_id: 1007, name: "4K Monitor", base_price: 229.99 },
{ product_id: 1008, name: "Portable SSD", base_price: 79.99 },
{ product_id: 1009, name: "Smartphone Case", base_price: 15.99 },
{ product_id: 1010, name: "Wireless Charger", base_price: 29.99 },
];

const countries = ["USA", "Canada", "UK", "Germany", "France", "Australia", "Japan", "Brazil", "India", "Mexico"];

const cities = {
USA: ["New York", "Los Angeles", "Chicago", "Houston", "Seattle"],
Canada: ["Toronto", "Vancouver", "Montreal", "Ottawa"],
UK: ["London", "Manchester", "Bristol", "Birmingham"],
Germany: ["Berlin", "Munich", "Hamburg", "Frankfurt"],
France: ["Paris", "Lyon", "Marseille", "Toulouse"],
Australia: ["Sydney", "Melbourne", "Brisbane", "Perth"],
Japan: ["Tokyo", "Osaka", "Yokohama", "Nagoya"],
Brazil: ["Sao Paulo", "Rio de Janeiro", "Brasilia", "Salvador"],
India: ["Mumbai", "Delhi", "Bangalore", "Hyderabad"],
Mexico: ["Mexico City", "Guadalajara", "Monterrey", "Puebla"],
};

function generateSyntheticEcommerceData(outputCsv = "synthetic_orders.csv", numRecords = 1_000_000) {
// Determine date range (last 365 days up to today)
const now = new Date();
const startDate = new Date(now.getTime() - 365 * 24 * 60 * 60 * 1000); // 365 days ago

// Create a writable stream for CSV
const writeStream = fs.createWriteStream(outputCsv, { encoding: "utf-8" });

// Write header row
writeStream.write([
"order_id",
"order_date",
"user_id",
"product_id",
"quantity",
"price",
"total_amount",
"country",
"city"
].join(",") + "\n");

for (let i = 0; i < numRecords; i++) {
const orderId = uuidv4();

// Generate a random date within the last 365 days
const randomDays = Math.floor(Math.random() * 365);
const orderDate = new Date(startDate.getTime() + randomDays * 24 * 60 * 60 * 1000);
const orderDateStr = orderDate.toISOString().split("T")[0]; // YYYY-MM-DD

// Random user ID
const userId = Math.floor(Math.random() * 900_000) + 100_000; // 100000-999999

// Random product
const product = products[Math.floor(Math.random() * products.length)];
const productId = product.product_id;
const basePrice = product.base_price;

// Random quantity and slight price variation
const quantity = Math.floor(Math.random() * 5) + 1; // 1-5
const finalPrice = +(basePrice * (0.9 + Math.random() * 0.2)).toFixed(2); // +/- 10%
const totalAmount = +(finalPrice * quantity).toFixed(2);

// Random country and city
const country = countries[Math.floor(Math.random() * countries.length)];
const cityList = cities[country];
const city = cityList[Math.floor(Math.random() * cityList.length)];

// Write one CSV record
writeStream.write([
orderId,
orderDateStr,
userId,
productId,
quantity,
finalPrice,
totalAmount,
country,
city
].join(",") + "\n");
}

// End the stream
writeStream.end(() => {
console.log(`Successfully generated ${numRecords} synthetic records in '${outputCsv}'.`);
});
}

// Run the script if called directly (e.g., `node generateSyntheticEcommerceData.js`)
if (require.main === module) {
generateSyntheticEcommerceData("synthetic_orders.csv", 100000);
}

// Otherwise, you can export the function for use in other modules:
// module.exports = { generateSyntheticEcommerceData };
13 changes: 13 additions & 0 deletions sales analytics_UI/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading