Skip to content

The 'stack' command

The stack command is used to manage so-called “stacks”.

Stacks

A stack is a part of OwnStats that fulfils specific purposes:

  • backend: The backend contains the necessary AWS infrastructure resources, like CloudFront Distributions, S3 Buckets, Kinesis Data Firehose and the Lambda function to aggregate and query the data
  • frontend: The frontend is a React SPA application that uses DuckDB to cache the web analytics data from S3 to guarantee very fast query response times
  • client: The client is the actual JavaScript tracking library that can be integrated and loaded from websites that need to be tracked

Stack-specific actions

Not all stacks make use of every action, please have a look below for the details.

Backend

The backend stack supports the following:

  • install: This will install the necessary dependencies for the backend stack with npm.
  • deploy: This will deploy the backend stack to your AWS account that. Usually, this will take 5-10 minutes.
  • package: This will package the CloudFormation IaC, and the deployment artefacts (e.g. Lambda functions), but not actually deploy the stack.
  • remove: This will remove (delete) the backend stack from your AWS account. It’s possible that you might have to manually clean the S3 Buckets before the stack can fully be removed.

Frontend

The frontend stack supports the following:

  • install: This will install the necessary dependencies for the frontend stack with npm.
  • build: This builds the frontend React application distribution with Vite, so that it can be synced to the frontend S3 Bucket via the sync action.
  • sync: This syncs the contents of the frontend/dist directory to the frontend S3 Bucket. The build command needs to be run first.
  • open: This will show a clickable link to the frontend CloudFront Distribution endpoint where the frontend is available. Hint: The frontend can also run only locally via npm run dev in the frontend directory of your OwnStats installation.

Client

The client stack supports the following:

  • install: This will install the necessary dependencies for the client stack with npm.
  • build: This builds the client tracking scripts, so that it can be synced to the backend S3 Bucket via the sync action.
  • sync: This syncs the contents of the client/dist directory to the backend S3 Bucket. The build command needs to be run first.

Usage

Terminal window
USAGE
$ ownstats stack ACTION NAME
ARGUMENTS
ACTION (deploy|package|remove|sync|build|install|open) The action to perform
NAME (frontend|backend|client) The stack name
DESCRIPTION
Interact with OwnStats stacks within an installation

Example usage

For example, if you want to deploy the backend stack, you can use the following command:

Terminal window
ownstats stack backend deploy

To build the frontend apllication, you could use

Terminal window
ownstats stack frontend build