A React + Vite analytics dashboard with an Express + SQLite backend for exploring food sales data, tracking KPIs, generating AI-style insights, and answering natural-language business questions.
- Frontend: React 19 + Vite
- Backend: Express + SQLite
- Data: bundled demo SQLite database plus CSV seed files
- Use case: KPI tracking, operational signals, AI-style analysis, forecasting, and drill-down analytics
- Shows core KPIs:
- Total Sales
- Orders
- Average Order Value
- Shows dashboard status context for:
- Backend availability
- Active filters
- Last AI request context
- Supports dashboard filters for:
- Time period
- Product
- Channel
- Customer
- Warehouse
- Includes AI-style features:
- Ask AI question box
- On-demand analytics overview charts
- Root cause analysis
- Sales forecasting
- Auto insight cards
- Side-by-side comparisons
- Lightweight AI memory/context awareness
- Forecast and chart panels that appear only when requested
- Editorial dashboard-style landing section with system status and context summary
- Control surface for time, product, channel, customer, and warehouse filtering
- KPI cards with animated value transitions
- AI workspace with prompt suggestions and structured response panels
- Signal area for automated insight cards and anomaly alerts
- Forecast and chart views that appear only when requested
- Responsive layout with extra handling for long numbers and text overflow
- Frontend:
- React 19
- Vite
- Chart.js
- react-chartjs-2
- Backend:
- Express
- SQLite3
food-ai-dashboard/
|- src/ # React app
|- public/ # Static assets
|- backend/ # Express + SQLite backend
| |- server.js
| |- database.js
| |- data/
| `- database.db
|- package.json # Frontend scripts
`- README.md
npm installcd backend
npm install
cd ..Root .env values for the Vite app:
VITE_API_BASE_URL=Backend backend/.env values:
PORT=5000
CORS_ORIGIN=http://localhost:5173Leave VITE_API_BASE_URL empty for local development with the built-in Vite proxy.
From the project root:
npm run serverThe backend runs on:
http://localhost:5000
npm run devThe frontend runs on Vite's local dev server, typically:
http://localhost:5173
npm run dev:allFrom the project root:
npm run lint
npm run build
npm run smokeFrom the backend folder:
npm run test:api
npm run test:datesnpm run dev
npm run dev:all
npm run dev:client
npm run server
npm run smoke
npm run build
npm run preview
npm run lintFrom the project root:
npm run backend:install
npm run smoke
npm run seed:sales
npm run seed:enrichedOr from the backend folder:
npm install
npm start
npm run smoke
npm run test:api
npm run test:dates
npm run seed:sales
npm run seed:enriched
npm run reset:demo-dataThe Ask AI section can answer questions such as:
Give me an analytics overviewWhat is the average order value?Compare average order value by channelCompare channel performanceCompare customer performanceCompare warehouse performanceWhich product sells the most?Which product sells the least?Why did sales drop?What is tomorrow's sales forecast?Show sales trendShow warehouse distributionShow customer distribution
The backend uses rule-based intent detection plus filtered SQL/data aggregation to return structured responses for:
- summaries
- trends
- forecasts
- root cause analysis
- comparisons
- chart requests
- Some AI answers depend on the quality and shape of the SQLite data already loaded into the backend.
backend/database.dbis included so the dashboard works immediately after cloning.backend/database.dbis treated as bundled demo data for this repo. If you want to rebuild it from the CSV sources, runnpm run reset:demo-data --prefix backend.- The backend loads
backend/.envquietly, so local startup stays clean unless there is a real error. - CORS is open by default for local development. Set
CORS_ORIGINinbackend/.envto a comma-separated allowlist when you want stricter browser access. - Large generated folders like
node_modulesand local.envfiles are ignored for GitHub uploads. - The backend currently uses lightweight in-memory AI memory for context awareness, so memory resets when the server restarts.
- If you change backend logic, restart
node backend/server.jsto pick up the update. - A lightweight health endpoint is available at
http://localhost:5000/api/health. - Run
npm run smokewhile the backend is running to smoke-test the key API routes before a demo or submission. - Run
npm run test:api --prefix backendfor a small end-to-end API regression check. - Run
npm run test:dates --prefix backendto verify the relative date windows used by KPI and insight filters.
- This folder is not currently initialized as a Git repository, so if you plan to push from the terminal you will need to run
git initfirst. - Do not upload
node_modules,dist,.env, orbackend/.env. The current.gitignorealready covers those. - If you upload through the GitHub website instead of using
git, make sure you excludenode_modulesanddistmanually. - Keeping
backend/database.dbin the repository is intentional here because it acts as bundled demo data.
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin <your-repo-url>
git push -u origin main- KPI cards with count-up animation
- Warm editorial dashboard theme with status and context framing
- Forecast panel with 7-day moving-average projection
- Auto insight cards for drop, growth, and warehouse signals
- Clear filters button to return to the combined base view
- Smarter Ask AI responses with better intent handling
- On-demand analytics canvas and forecast cards
- Frontend error boundary for safer demos
- UI layout hardening for long numbers and text visibility