Binding and Perform CRUD Operations with Interactive Sales Analytics Using PostgreSQL Data
PostgreSQL Pivot Table Dashboard is a full-stack business intelligence application that seamlessly integrates a React + TypeScript frontend with an ASP.NET Core backend connected to PostgreSQL database.
The application uses Syncfusion DataManager to handle real-time CRUD operations (Create, Read, Update, Delete) on sales data through an interactive pivot table interface:
- React Client (Frontend): Displays an interactive Syncfusion pivot table component that allows users to visualize, analyze, and manipulate sales data without writing SQL
- DataManager: The DataManager component in React communicates with backend API endpoints, automatically sending HTTP requests for fetch, insert, update, and delete operations
- ASP.NET Core Backend: Provides REST API endpoints (
/api/sales) that handle all CRUD operations via the SalesController - PostgreSQL Database: Stores all sales transaction data with proper indexing for optimal query performance using Npgsql provider
The complete workflow: User interacts with pivot table → DataManager sends HTTP request → Backend processes via SalesController → PostgreSQL executes query → Response updates UI instantly.
- Quick Overview
- Key Features & Capabilities
- Technology Stack
- System Architecture
- Installation & Setup
- Configuration
- Getting Started
- Project Structure
- Troubleshooting
- Contributing
- License & support
This application provides an intuitive interface for real-time sales data analysis and manipulation. Instead of complex SQL queries, users interact with an interactive pivot table to:
- Visualize Data: Organize sales data by country, product category, sales personnel, and time periods
- Perform CRUD Operations: Add new records, modify existing data, and delete entries directly through the pivot table interface
- Drill-Through Analysis: Click cells to view detailed records and edit them in-line
- Customize Views: Drag-and-drop fields to reorganize the pivot table layout
- Real-time Sync: All changes are immediately reflected across the application using DataManager
- Type-Safe Frontend: TypeScript ensures fewer bugs in the React application
- Robust Backend: ASP.NET Core 10.0 provides enterprise-grade API performance
- Reliable Database: PostgreSQL offers ACID compliance and advanced querying capabilities
- Professional UI: Syncfusion components deliver production-ready pivot tables
- Seamless Integration: DataManager bridges frontend and backend with automatic HTTP handling
- Interactive Pivot Tables: Organize and summarize sales data by multiple dimensions with drag-and-drop field configuration
- Complete CRUD Operations: Create, read, update, and delete sales records directly from the pivot table editing UI.
- DataManager Integration: Automatic HTTP communication with backend for seamless data synchronization
- Drill-Through Analysis: Click detailed cells to edit individual records with real-time validation
- Sales Dimensions: Analyze data by country, region, product category, sales person, and time periods
- Responsive Design: Works seamlessly on desktop and tablet devices
- Real-time Updates: All changes reflect immediately across the application
- Date/Time Handling: Automatic formatting for temporal fields with calendar picker support
| Technology | Version | Purpose |
|---|---|---|
| React | 19.2.5 | UI framework and component library |
| TypeScript | ~6.0.2 | Type-safe JavaScript development |
| Vite | 8.0.10 | Lightning-fast build tool |
| Syncfusion EJ2 | 33.2.3 | Professional pivot table component |
| React DOM | 19.2.5 | React rendering engine |
| Technology | Version | Purpose |
|---|---|---|
| .NET | 10.0 | Framework for web APIs |
| ASP.NET Core | 10.0 | Web application framework |
| Npgsql.EF Core | 9.0.4 | PostgreSQL data access |
| Syncfusion EJ2 | 32.2.3 | Data management utilities |
| Swashbuckle | 10.1.2 | OpenAPI/Swagger documentation |
| Technology | Purpose |
|---|---|
| PostgreSQL | Primary relational database |
| Npgsql | .NET PostgreSQL provider |
| Tool | Purpose |
|---|---|
| ESLint | Code quality and style enforcement |
| TypeScript Compiler | Type checking and transpilation |
| Node.js | JavaScript runtime for frontend |
| .NET CLI | .NET project management |
┌──────────────────────────────────────────────┐
│ React Frontend (TypeScript/Vite) │
│ ┌──────────────────────────────────────┐ │
│ │ PivotViewComponent + DataManager │ │
│ │ (Syncfusion) │ │
│ └──────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
↓
HTTP/HTTPS REST API
↓
┌──────────────────────────────────────────────┐
│ ASP.NET Core Backend (.NET 10.0) │
│ ┌──────────────────────────────────────┐ │
│ │ SalesController │ │
│ │ /api/sales endpoints (CRUD) │ │
│ └──────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
↓
Npgsql Provider
↓
┌──────────────────────────────────────────────┐
│ PostgreSQL Database (salesdb) │
│ ┌──────────────────────────────────────┐ │
│ │ salesdata table (orders, details) │ │
│ └──────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
- User Interaction: User manipulates pivot table in React (add, edit, delete, reorganize)
- DataManager Request: DataManager automatically detects changes and sends HTTP request to backend
- Backend Processing: SalesController receives request and routes to appropriate CRUD method
- Database Query: Npgsql executes SQL against PostgreSQL using parameterized queries
- Response: Backend returns JSON response with operation result
- UI Synchronization: DataManager updates pivot table with fresh data, user sees changes instantly
| Component | Role | Purpose |
|---|---|---|
| DataManager | Frontend Bridge | Manages HTTP communication, caching, and data synchronization |
| SalesController | Backend API | Handles POST/GET requests and routes to CRUD operations |
| Npgsql | Data Provider | Executes queries against PostgreSQL with connection pooling |
| Syncfusion PivotView | UI Component | Renders interactive pivot table with drill-through editing |
- Backend: .NET 10.0 SDK, PostgreSQL 12+
- Frontend: Node.js 18+, npm/yarn
- System: 4GB RAM, 500MB storage, Ports 5432, 7086, 5173 available
-
Create Database
psql -U postgres CREATE DATABASE salesdb; -
Create Table - Execute the SQL schema to create
salesdatatable with columns: orderid, customername, region, country, productcategory, productname, orderdate, quantity, unitprice, totalamount, salesperson -
(Optional) Seed Sample Data - Insert test records into the table for development
cd PivotTable_PostgreSQL.Serverdotnet restoreEdit appsettings.json with your PostgreSQL credentials:
{
"ConnectionStrings": {
"SalesDb": "Host=localhost;Port=5432;Database=salesdb;Username=postgres;Password=YourPassword;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}appsettings.json with actual credentials to version control. Use environment variables or user secrets in production.
dotnet build# Development mode with file watching
dotnet watch run
# Or standard run
dotnet runBackend will start at: https://localhost:7086
cd pivottable_postgresql.clientnpm installEdit src/App.tsx to match your backend URL:
let oData: DataManager = new DataManager({
url: 'https://localhost:7086/api/Sales',
insertUrl: 'https://localhost:7086/api/Sales/Insert',
updateUrl: 'https://localhost:7086/api/Sales/Update',
removeUrl: 'https://localhost:7086/api/Sales/Remove',
adaptor: new UrlAdaptor
});npm run devFrontend will be available at: http://localhost:5173
npm run build{
"ConnectionStrings": {
"SalesDb": "Host=localhost;Port=5432;Database=salesdb;Username=postgres;Password=YOUR_PASSWORD;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Debug"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://localhost:7086"
},
"Http": {
"Url": "http://localhost:5000"
}
}
}
}Create .env file in backend root:
ASPNETCORE_ENVIRONMENT=Development
ConnectionString__SalesDb=Host=localhost;Port=5432;Database=salesdb;Username=postgres;Password=YOUR_PASSWORD;Current configuration supports React development:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 5173,
proxy: {
'/api': {
target: 'https://localhost:7086',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api')
}
}
}
})Create .env file in frontend root:
VITE_API_URL=https://localhost:7086
VITE_API_TIMEOUT=30000
✅ PostgreSQL running
✅ Database and table created
✅ Backend connection string configured
✅ Node.js installed
Terminal 1 - Start Backend:
cd PivotTable_PostgreSQL.Server
dotnet runTerminal 2 - Start Frontend:
cd pivottable_postgresql.client
npm install # (First time only)
npm run devBrowser:
Open http://localhost:5173
You should see:
- ✅ Pivot table interface loads
- ✅ Sales data displays in the table
- ✅ Field list panel appears on the right
- ✅ You can drag fields to reorganize the pivot table
- ✅ Click a cell to drill into detail records
- Understand the Data Model: Review SalesData Model
- Explore CRUD Operations: Try adding, editing, and deleting records
- Configure Pivot Table: Drag fields to customize the view
- Study the Code: Examine
SalesController.csandApp.tsx - Add Features: Implement filtering, sorting, and export capabilities
PostGreSQL-Sales/
├── README.md # This file
├── microsoft-sql-server-datamanager.md # Reference documentation
├── microsoft-sql-server-grid.md # Reference documentation
├── postgresql-pivot-table-guide.md # Database guide
│
├── pivottable_postgresql.client/ # React Frontend
│ ├── package.json # npm dependencies & scripts
│ ├── tsconfig.json # TypeScript configuration
│ ├── tsconfig.app.json # App-specific TS config
│ ├── tsconfig.node.json # Node-specific TS config
│ ├── vite.config.ts # Vite build configuration
│ ├── eslint.config.js # ESLint rules
│ ├── index.html # HTML entry point
│ │
│ └── src/
│ ├── main.tsx # React root
│ ├── App.tsx # Main component
│ ├── App.css # Component styles
│ ├── index.css # Global styles
│ └── assets/ # Static assets
│
└── PivotTable_PostgreSQL.Server/ # .NET Core Backend
├── Program.cs # Application entry point
├── PivotTable_PostgreSQL.Server.csproj # Project file
├── PivotTable_PostgreSQL.Server.sln # Solution file
├── PivotTable_PostgreSQL.Server.http # HTTP test file
├── appsettings.json # Configuration
├── appsettings.Development.json # Dev configuration
│
├── Controllers/
│ └── SalesController.cs # API endpoints for CRUD
│
├── Properties/
│ └── launchSettings.json # Launch configuration
│
├── bin/ # Compiled output
│ └── Debug/
│ └── net10.0/
│
└── obj/ # Build artifacts
└── Debug/
└── net10.0/
| File | Purpose |
|---|---|
src/App.tsx |
Main React component with PivotView and DataManager configuration |
src/main.tsx |
React application entry point and DOM mounting |
vite.config.ts |
Build tool configuration for development and production |
tsconfig.json |
TypeScript compiler settings |
package.json |
npm dependencies and build scripts |
| File | Purpose |
|---|---|
Program.cs |
Application startup, services configuration, middleware setup |
Controllers/SalesController.cs |
REST API endpoints handling CRUD operations |
appsettings.json |
Database connection string and configuration |
PivotTable_PostgreSQL.Server.csproj |
Project dependencies and build settings |
❌ "Cannot connect to server" error
Error: Failed to fetch from https://localhost:7086/api/Sales
✅ Solution:
- Verify backend is running:
dotnet runin backend directory - Check port 7086 is not blocked by firewall
- Verify CORS is enabled in Program.cs
- Check browser console for exact error message
❌ "TypeScript compilation error"
error TS2307: Cannot find module '@syncfusion/ej2-react-pivotview'
✅ Solution:
- Run
npm installto install dependencies - Delete
node_modulesandpackage-lock.json - Run
npm installagain - Clear browser cache (Ctrl+Shift+Delete)
❌ CORS blocked request
Access to XMLHttpRequest blocked by CORS policy
✅ Solution:
- Verify CORS is configured in backend Program.cs:
app.UseCors("AllowAll");- Restart backend
- Check frontend URL matches configured origin
❌ "Connection refused" to PostgreSQL
Npgsql.NpgsqlException: could not connect to server
✅ Solution:
- Verify PostgreSQL is running:
psql -U postgres - Check connection string in appsettings.json
- Verify database exists:
psql -l - Check PostgreSQL is listening on port 5432
- Test manually:
psql -U postgres -d salesdb
❌ "Column does not exist" error
ERROR: column "salesperson" does not exist
✅ Solution:
- Verify table schema matches SalesData model
- Check PostgreSQL table structure:
\d salesdata- Recreate table if needed (see Database Setup section)
❌ Port 7086 already in use
System.IO.IOException: Failed to bind to address
✅ Solution:
# Find process using port (Windows PowerShell)
netstat -ano | findstr :7086
# Kill process (replace PID)
taskkill /PID <PID> /F
# Or use different port in launchSettings.json❌ "Database does not exist"
FATAL: database "salesdb" does not exist
✅ Solution:
- Create database:
CREATE DATABASE salesdb;- Create tables (see Database Setup section)
❌ "Permission denied" error
FATAL: role "postgres" does not have CONNECT privilege
✅ Solution:
- Check PostgreSQL user permissions
- Reset password:
psql -U postgres
ALTER USER postgres WITH PASSWORD 'newpassword';❌ Pivot table loads slowly
✅ Solutions:
- Create database indexes:
CREATE INDEX idx_orderdate ON salesdata(orderdate);
CREATE INDEX idx_country ON salesdata(country);
CREATE INDEX idx_productcategory ON salesdata(productcategory);- Reduce number of rows in view
- Use pagination instead of loading all data
We welcome contributions! Here's how to get started:
- Fork the repository (local development)
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes with clear, descriptive commits
- Test thoroughly before submitting
- Document your changes in code comments
- Follow the existing code style
- Write meaningful commit messages
- Add comments for complex logic
- Test all CRUD operations
- Ensure no console errors
- Update documentation if needed
- Test on both frontend and backend
- Ensure all tests pass
- Provide clear PR description
This is a commercial product subject to the Syncfusion End User License Agreement (EULA).
Free Community License is available for qualifying users/organizations: ś
- Annual gross revenue < $1 million USD
- 5 or fewer total developers
- 10 or fewer total employees
The community license allows free use in both internal and commercial applications under these conditions.
No registration or approval is required — just comply with the terms.
Paid Licenses are required for:
- Larger organizations
- Teams exceeding the community license limits
- Priority support, custom patches, or on-premise deployment options
Purchase options and pricing: https://www.syncfusion.com/sales/products
30-day free trial (full features, no credit card required): https://www.syncfusion.com/downloads/essential-js2
Community License details & FAQ: https://www.syncfusion.com/products/communitylicense
Full EULA: https://www.syncfusion.com/eula/es/
© 2026 Syncfusion, Inc. All Rights Reserved.