Skip to content

Commit fc0a33a

Browse files
committed
release 0.1.0
0 parents  commit fc0a33a

49 files changed

Lines changed: 20986 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/packages/frontend/build
13+
/packages/common/dist
14+
/packages/backend/dist
15+
16+
# misc
17+
.DS_Store
18+
.env.local
19+
.env.development.local
20+
.env.test.local
21+
.env.production.local
22+
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
.idea
28+
node_modules
29+
30+
# typescript
31+
*.tsbuildinfo
32+
33+
# examples
34+
/dbt

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DBT_PROJECT_DIR=./dbt
2+
DBT_PROFILE_DIR=~/.dbt

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/packages/frontend/build
13+
/packages/common/dist
14+
/packages/backend/dist
15+
16+
# misc
17+
.DS_Store
18+
.env.local
19+
.env.development.local
20+
.env.test.local
21+
.env.production.local
22+
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
.idea
28+
node_modules
29+
30+
# typescript
31+
*.tsbuildinfo
32+
33+
# examples
34+
/dbt
35+
/profile*

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# lightdash
2+
3+
lightdash removes the gap between your data transformation layer and your data visualization layer. It enables data analysts and engineers to control all of their business intelligence (data transformations/business logic as well as data visualization) in a single place.
4+
5+
lightdash integrates with your dbt project and gives a framework for defining metrics and specifying joins between models all within your existing dbt YAML files. The data output from your dbt project is then available for exploring and sharing in lightdash.
6+
7+
- No more scattered, duplicated metrics across multiple tools.
8+
- No more time spent trying to maintain data changes in both dbt and and your data viz tools.
9+
- No more context lost between your data transformation and your data visualization layer.
10+
11+
## Getting Started
12+
---
13+
14+
### Quickstart with docker
15+
16+
The fastest way to get started is to use [docker](https://docs.docker.com/get-docker/)
17+
18+
```shell
19+
# Clone the lightdash repo
20+
git clone https://github.com/lightdash/lightdash
21+
22+
# Enter the repo directory
23+
cd lightdash
24+
25+
# Specify the path to your dbt project
26+
# (i.e. the directory containing dbt_project.yml)
27+
# You MUST use the absolute path (i.e no ../../myrepo)
28+
export DBT_PROJECT_DIR=/Users/myuser/dbtrepo
29+
30+
# Build and launch lightdash
31+
docker compose up
32+
33+
# Ready on http://localhost:8080 !
34+
```
35+
36+
### Installation from source
37+
38+
lightdash requires node.js and yarn.
39+
40+
**Install dependencies for Mac OS**
41+
```shell
42+
# Install node with homebrew
43+
brew install node
44+
45+
# Install yarn with node package manager
46+
npm install -g yarn
47+
48+
# Clone the lightdash repo
49+
git clone https://github.com/lightdash/lightdash
50+
51+
# Enter the repo directory
52+
cd lightdash
53+
54+
# Install lightdash dependencies and build
55+
yarn install
56+
yarn build
57+
```
58+
59+
### Adding dimensions, measures, joins, and more to your lightdash project
60+
61+
lightdash's configuration is fully defined in your dbt project. For example, measures and joins sit in your models' .yml files.
62+
63+
Check out our [example_model.yml](https://github.com/lightdash/lightdash/blob/main/examples/example_model.yml) file for more details on how to add these features to your project!
64+
65+
### Launching lightdash
66+
67+
```shell
68+
# Specify the path to your dbt project
69+
# (i.e. the directory containing dbt_project.yml)
70+
# You MUST use the absolute path (i.e no ../../myrepo)
71+
export DBT_PROJECT_PATH=/Users/myuser/dbtrepo
72+
73+
# Build and run lightdash
74+
yarn start
75+
76+
# Press ALLOW when asked to "accept incoming connections from python"
77+
```
78+
79+
## Join the community!
80+
---
81+
- Find us on [Slack](https://join.slack.com/t/seekercommunity/shared_invite/zt-ptiqsd6p-Dbjjn8GXozYkFhARgAs3cw). We'd love to hear what you have to say about lightdash :)
82+
- _coming soon_ Join the discussion in our discourse.
83+
84+
## Reporting bugs and feature requests
85+
---
86+
- Want to report a bug or request a feature? Let us know on [Slack](https://join.slack.com/t/seekercommunity/shared_invite/zt-ptiqsd6p-Dbjjn8GXozYkFhARgAs3cw), or open an [issue](https://github.com/lightdash/lightdash/issues/new/choose).

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: "3.9"
2+
services:
3+
dbt:
4+
image: "fishtownanalytics/dbt:0.19.1"
5+
volumes:
6+
- "${DBT_PROFILE_DIR}:/usr/app/profile"
7+
- "${DBT_PROJECT_DIR}:/usr/app"
8+
command: ["rpc", "--profiles-dir", "profile", "--host", "0.0.0.0", "--port", "8580"]
9+
10+
lightdash:
11+
build:
12+
context: .
13+
depends_on:
14+
- dbt
15+
environment:
16+
- LIGHTDASH_DBT_HOST=dbt
17+
- LIGHTDASH_DBT_PORT=8580
18+
- LIGHTDASH_SPAWN_DBT=false
19+
ports:
20+
- 8080:8080

dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
FROM node:14 AS base
2+
3+
WORKDIR /usr/app
4+
5+
# Stage 1: build the common, backend, and frontend distributions
6+
FROM base AS builder
7+
8+
# Install development dependencies for all
9+
COPY package.json .
10+
COPY yarn.lock .
11+
COPY packages/common/package.json ./packages/common/
12+
COPY packages/backend/package.json ./packages/backend/
13+
COPY packages/frontend/package.json ./packages/frontend/
14+
15+
RUN yarn install --pure-lockfile --non-interactive
16+
17+
# Build common
18+
COPY packages/common/ ./packages/common/
19+
RUN yarn --cwd ./packages/common/ build
20+
21+
# Build backend
22+
COPY packages/backend/ ./packages/backend/
23+
RUN yarn --cwd ./packages/backend/ build
24+
25+
# Build frontend
26+
COPY packages/frontend ./packages/frontend
27+
RUN yarn --cwd ./packages/frontend/ build
28+
29+
# Stage 2: execution environment for backend
30+
FROM base as executor
31+
32+
# Copy distributions into environment
33+
COPY --from=builder /usr/app/packages/common/package.json /usr/app/packages/common/package.json
34+
COPY --from=builder /usr/app/packages/common/dist /usr/app/packages/common/dist
35+
36+
37+
COPY --from=builder /usr/app/packages/backend/package.json /usr/app/packages/backend/package.json
38+
COPY --from=builder /usr/app/packages/backend/dist /usr/app/packages/backend/dist
39+
40+
41+
COPY --from=builder /usr/app/packages/frontend/package.json /usr/app/packages/frontend/package.json
42+
COPY --from=builder /usr/app/packages/frontend/build /usr/app/packages/frontend/build
43+
44+
# Install production dependencies
45+
COPY package.json .
46+
COPY yarn.lock .
47+
48+
ENV NODE_ENV production
49+
50+
RUN yarn install --pure-lockfile --non-interactive --production
51+
52+
# Run the backend
53+
WORKDIR /usr/app/packages/backend
54+
55+
USER node
56+
CMD ["yarn", "start"]

examples/example_model.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: 2
2+
3+
models:
4+
- name: users # In lightdash, the model name will match the name you define here.
5+
description: "One row per user_id. This is a list of all users and aggregated information for these users."
6+
7+
# If we want to join this model to other models in lightdash, we need to define this in the .yml file.
8+
# We add joins at the same indentation level as our model's name, description, etc. in a `meta` block
9+
# You can join multiple models other models to your model.
10+
# All joins are left-outer joins.
11+
meta:
12+
joins:
13+
- join: segment_web_sessions # name of model you're joining to
14+
left_on: user_id # join key of left model (i.e. this model)
15+
right_on: user_id # join key of right model (i.e. model you're joining)
16+
- join: payments
17+
sql_on: ${users.user_id} = ${segment_web_sessions.blended_user_id} # you can also write the join in SQL instead of using the left_on, right_on syntax
18+
19+
20+
# For a column to appear in lightdash, it needs to be defined in the model's .yml file.
21+
# To define a column, you only need to include the column name (descriptions are optional).
22+
# All of the column descriptions are automatically pulled into lightdash.
23+
columns:
24+
- name: user_id
25+
description: 'Unique identifier for a user.'
26+
tests:
27+
- unique
28+
- not_null
29+
30+
# We add measures in lightdash in a `meta` block within the column definition.
31+
# A single column can have multiple measures.
32+
meta:
33+
measures:
34+
- name: num_unique_users # this is the name of the measure.
35+
type: count_distinct # this is the type of calculation that's being done
36+
- name: num_unique_7d_active_users
37+
description: "Unique number of users that have had at least one web session in the past 7 days." # measures have default descriptions that are added to lightdash. But, you can override these with your own descriptions if you want!
38+
type: count_distinct
39+
- name: user_activated_date
40+
description: "Date ('yyyy-mm-dd') when the user ID was first recorded."
41+
- name: days_since_activated
42+
description: 'Number of days since the user ID was activated'
43+
- name: is_7d_web_active_latest
44+
description: 'TRUE/FALSE indicating whether or not the user has had at least 1 web session in the previous 7 days.'
45+
- name: num_web_sessions_prev_7d
46+
description: 'Total number of web sessions the user has had in the past 7 days'
47+
meta:
48+
measures:
49+
- name: total_num_web_sessions_prev_7d
50+
type: sum
51+
- name: num_web_sessions_prev_30d
52+
description: 'Total number of web sessions the user has had in the past 30 days'
53+
- name: num_web_sessions_total
54+
description: 'Total number of web sessiosn the user has ever had.'

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "lightdash",
3+
"version": "0.1.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"private": true,
7+
"workspaces": {
8+
"packages": [
9+
"packages/*"
10+
]
11+
},
12+
"devDependencies": {
13+
"npm-run-all": "^4.1.5"
14+
},
15+
"scripts": {
16+
"common-build": "yarn workspace common build",
17+
"backend-dev": "yarn workspace backend dev",
18+
"backend-build": "yarn workspace backend build",
19+
"backend-start": "yarn workspace backend start",
20+
"frontend-dev": "yarn workspace frontend start",
21+
"frontend-build": "yarn workspace frontend build",
22+
"dev": "run-p backend-dev frontend-dev",
23+
"build": "run-p backend-build frontend-build",
24+
"start": "run-p backend-start"
25+
}
26+
}

packages/backend/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "backend",
3+
"version": "0.1.0",
4+
"main": "dist/index",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"@types/express": "^4.17.11",
8+
"@types/node": "^14.14.35",
9+
"@types/node-fetch": "^2.5.10",
10+
"nodemon": "^2.0.7",
11+
"ts-node": "^9.1.1",
12+
"typescript": "^4.2.3"
13+
},
14+
"dependencies": {
15+
"@types/morgan": "^1.9.2",
16+
"ajv": "^8.3.0",
17+
"ajv-formats": "^2.1.0",
18+
"common": "1.0.0",
19+
"execa": "^5.0.0",
20+
"express": "^4.17.1",
21+
"fuse.js": "^6.4.6",
22+
"morgan": "^1.10.0",
23+
"node-cache": "^5.1.2",
24+
"node-fetch": "^2.6.1"
25+
},
26+
"scripts": {
27+
"dev": "nodemon src/index.ts",
28+
"build": "tsc --build tsconfig.json",
29+
"start": "node dist/index.js"
30+
}
31+
}

0 commit comments

Comments
 (0)