Local Development
Run diy-analytics locally for feature development, running the test suite, or contributing to the open-source repository.
Prerequisites
- Node.js
v18.17.0or higher (Node 20+recommended) - Git for version control
- PostgreSQL 14+ — a local install, a Docker container, or a cloud database on Neon/Supabase
Setup
1. Clone the repository
bash
2. Install dependencies
bash
3. Start a local PostgreSQL instance
If Docker is installed, launch a PostgreSQL 16 container with a single command:
bash
4. Configure environment variables
Create your .env.local:
bash
Set the minimal required variables:
bash
5. Apply schema migrations
bash
This initializes all tables — workspaces, projects, pageviews, events, and errors.
6. Start the development server
bash
Visit http://localhost:3000. You'll land on the initial setup form to create your workspace owner credentials.
CLI scripts
| Command | Description |
|---|---|
npm run dev | Starts the local Next.js development server with hot module replacement |
npm run build | Builds the production bundle and validates TypeScript types |
npm test | Runs the Jest unit and integration test suite |
npm run db:migrate | Applies all pending SQL migrations against DATABASE_URL |
npm run db:generate | Generates new SQL migration files after updating src/lib/schema/ |
npx drizzle-kit studio | Launches Drizzle Studio, an interactive web GUI for your database |
Drizzle Studio
To explore, query, and edit database records in real time during development:
bash
Drizzle Studio opens at https://local.drizzle.studio, connected to your local database.
Contributing
We welcome pull requests and issue reports.
- Fork the repository and create a feature branch (
git checkout -b feature/amazing-feature). - Verify all tests pass with
npm testandnpm run build. - Commit your changes and open a pull request on GitHub.