A full-stack data visualization platform built with Svelte 5, SvelteKit, PostgreSQL, and D3.js. Upload CSV files, transform data, and create sophisticated visualizations with an intuitive interface.
- Frontend: Svelte 5, SvelteKit v2.16, TypeScript, Vite, D3.js v7.9, SCSS
- Backend: Node.js, PostgreSQL
- Data Processing: PapaParse v5.5 (CSV parsing)
- Tools: ESLint, Prettier, Svelte Check
Before running the application, ensure you have installed:
git clone <your-repo-url>
cd datanatornpm installThis will install all required packages including:
svelte@5- UI framework with runes@sveltejs/kit@2.16- Full-stack frameworktypescript@5.0- Type safetyd3@7.9- Data visualizationpapaparse@5.5- CSV parsingpg@8.16- PostgreSQL driversvelte-check- Type checkingeslint&prettier- Code quality tools
Create a .env.local file in the root directory with your PostgreSQL credentials:
SECRET_PGUSER=your_postgres_user
SECRET_PGPASSWORD=your_postgres_password
SECRET_PGHOST=localhost
SECRET_PGPORT=5432
SECRET_PGDATABASE=datanatorNote: These variables are required for the application to connect to PostgreSQL.
- Open PostgreSQL command line:
psql -U postgres- Create the database:
CREATE DATABASE datanator;- Connect to the new database:
\c datanator- Enable required PostgreSQL extensions:
CREATE EXTENSION IF NOT EXISTS ltree;
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";- Run the schema migration scripts (located in your
/databaseor/migrationsfolder):
psql -U your_postgres_user -d datanator -f ./database/schema.sql- Use pgAdmin or DBeaver to:
- Create a new database named
datanator - Run the schema SQL file from
/database/schema.sql - Enable extensions (ltree, pgcrypto, uuid-ossp)
- Create a new database named
Start the development server with hot module replacement (HMR):
npm run devThe application will be available at:
- Local:
http://localhost:5173 - Network: Check terminal output for your local IP
To open automatically in browser:
npm run dev -- --openCreate an optimized production build:
npm run buildTest the production build locally:
npm run preview| Command | Description |
|---|---|
npm run dev |
Start development server with HMR |
npm run dev -- --open |
Start dev server and open in browser |
npm run build |
Create production build |
npm run preview |
Preview production build |
npm run check |
Run TypeScript & Svelte type checking |
npm run lint |
Run ESLint code quality checks |
npm run format |
Auto-format code with Prettier |
datanator/
├── src/
│ ├── routes/ # SvelteKit pages & API endpoints
│ │ ├── api/ # REST API endpoints
│ │ ├── +layout.svelte # Root layout
│ │ ├── +page.svelte # Home page
│ │ └── login/ # Authentication pages
│ ├── lib/
│ │ ├── components/ # Reusable Svelte components
│ │ ├── stores/ # Svelte reactive stores
│ │ ├── api/ # Client API wrappers
│ │ ├── types/ # TypeScript interfaces
│ │ ├── utils/ # Utility functions
│ │ ├── common/ # Database connection
│ │ └── visualize/ # D3 visualization logic
│ ├── styles/ # Global SCSS styles
│ └── hooks.server.ts # Auth middleware
├── database/ # Database schema & migrations
├── .env.local # Environment variables (not committed)
├── svelte.config.js # SvelteKit config
├── vite.config.ts # Vite build config
└── tsconfig.json # TypeScript config
Key tables created during setup:
data.users- User accountsdata.sessions- Auth sessionsdata.projects- User projectsdata.project_members- Collaboration & access controldata.project_files- CSV files within projectsdata.file_ops- Operation log (audit trail)data.file_snapshots- Dataset snapshotsdata.visualizations- Saved chartsdata.visualization_revisions- Version history
✨ Multi-Project Workspace - Create and manage multiple data projects
📊 9 Chart Types - Line, bar, scatter, pie, area, histogram, boxplot, arc, alluvial
🔄 CSV Processing - Upload, parse, and transform CSV data
🎨 Advanced Visualization - Layered charts, conditional styling, custom tooltips
👥 Collaboration - Role-based access control (owner/editor/viewer)
💾 Data Snapshots - Save states at specific points in your workflow
🔐 Authentication - Secure password hashing and session management
Error: connect ECONNREFUSED 127.0.0.1:5432
Solution:
- Verify PostgreSQL is running:
sudo service postgresql status(Linux/Mac) or check Windows Services - Check
.env.localcredentials match your PostgreSQL setup - Ensure database
datanatorexists
Error: EADDRINUSE: address already in use :::5173
Solution:
npm run dev -- --port 5174Solution:
rm -rf node_modules package-lock.json
npm install
npm run checkSolution:
- Ensure
.env.localfile is in the root directory - Restart the dev server after updating
.env.local - Variables must start with
SECRET_to be accessible server-side
The application uses @sveltejs/adapter-auto for flexible deployment:
- Vercel: Deploy directly from GitHub
- Netlify: Connect repo, set build command to
npm run build - Traditional Node.js: Set environment variables and run
npm run preview
See SvelteKit Adapters for platform-specific setup.
- Run
npm run formatbefore committing - Ensure
npm run checkpasses (no type errors) - Follow the architectural patterns in
.github/copilot-instructions.md
✅ Passwords hashed with PostgreSQL pgcrypto
✅ SQL parameterization prevents injection
✅ Session expiry enforcement
✅ Role-based access control
✅ Safe expression evaluator (no eval())
For issues or questions, please open an issue.