Quick Start
Viewing typescript
switch to python
Prerequisites
- Node.js: version 20+ (opens in a new tab)
- OS: macOS or Linux (WSL supported for Windows)
- Run Docker: Run
open -a Docker
to start Docker Desktop. Installation instructions (opens in a new tab)
Create Your Moose Project
Initialize a New Project
Terminal
npx create-moose-app@latest my-moose-app ts
Terminal
# Create and activate a virtual environment (recommended)
python3 -m venv .venv && source .venv/bin/activate
# Install CLI and initialize project
pip install -U moose-cli && moose-cli init my-moose-app python
This creates a new project with all necessary files and configuration.
Set Up Project Dependencies
Terminal
cd my-moose-app && npm install
Terminal
cd my-moose-app && pip install -e .
Start the Development Server
Terminal
npx moose-cli dev
Terminal
moose-cli dev
Verify Infrastructure Setup
Open a new terminal, navigate to your project directory, and run:
Terminal
npx moose-cli ls
Terminal
moose-cli ls
You should see this output showing your ingestion points and tables:
Data Model | Ingestion Point | Table |
---|---|---|
Foo | /ingest/Foo | Foo_0_0 |
Bar | /ingest/Bar | Bar_0_0 |
Understanding Data Models
Explore Data Models
Your project includes two sample data models in app/datamodels/models.ts
:
/app/datamodels/models.ts
import { Key } from "@514labs/moose-lib";
export interface Foo {
primaryKey: Key<string>;
timestamp: Date;
optionalString?: string;
}
export interface Bar {
primaryKey: Key<string>;
utcTimestamp: Date;
hasString: boolean;
stringLength: number;
}
Your project includes two sample data models in app/datamodels/models.py
:
/app/datamodels/models.py
from moose_lib import Key, moose_data_model
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
@moose_data_model
@dataclass
class Foo:
primary_key: Key[str]
timestamp: datetime
optional_string: Optional[str]
@moose_data_model
@dataclass
class Bar:
primary_key: Key[str]
utc_timestamp: datetime
has_string: bool
string_length: int
MooseTip:
Moose automatically creates database tables and ingestion endpoints for these models. Run moose-cli ls
npx moose-cli ls
to see them.
Ingest Data
Send Data to an Ingestion Endpoint
Terminal
curl -X POST "http://localhost:4000/ingest/Foo" \
-H "Content-Type: application/json" \
-d '{"primaryKey": "1234567890", "timestamp": 1546300801.0, "optionalString": "hello world"}'
Terminal
curl -X POST "http://localhost:4000/ingest/Foo" \
-H "Content-Type: application/json" \
-d '{"primary_key": "1234567890", "timestamp": 1546300801.0, "optional_string": "hello world"}'
Verify Data Ingestion
Terminal
npx moose-cli peek Foo
Terminal
moose-cli peek Foo
You should see your ingested data:
{"primaryKey": "1234567890", "timestamp": 1546300801.0, "optionalString": "hello world"}
{"primary_key": "1234567890", "timestamp": 1546300801.0, "optional_string": "hello world"}
Troubleshooting
Next Steps
Congratulations!
You've successfully set up a Moose project and ingested your first data.
Database Connectivity
Connect to the local ClickHouse database:
moose.config.toml
[clickhouse_config]
db_name = "local"
user = "panda"
password = "pandapass"
host = "localhost"
host_port = 18123
native_port = 9000
use_ssl = false
VSCode Integration
- Install SQLTools (opens in a new tab) and SQLTools ClickHouse Driver (opens in a new tab)
- Moose automatically configures these extensions for your project
VSCode Integration
- Install SQLTools (opens in a new tab) and SQLTools ClickHouse Driver (opens in a new tab)
- Moose automatically configures these extensions for your project