Introduction

Unsend’s codebase is fully open-source on github

Here is the codebase structure

apps
├── docs
├── marketing
├── web
packages
├── eslint-config
├── sdk
├── tailwind-config
├── typescript-config
├── ui 

The apps directory contains the code for:

  • web: Code for our dashboard and email infra

  • marketing: The code for the landing page of Unsend

  • docs: The documentation that you are currently reading.

The packages directory contains the code for:

  • eslint-config package contains shared ESLint configuration settings

  • sdk package contains typescript sdk for unsend rest api

  • tailwind-config This package contains a shared Tailwind CSS configuration.

  • typescript-config This package contains a shared typescript configuration

  • ui This package is a collection of reusable UI components like buttons, badges, etc

Running Unsend locally

To run Unsend, locally you will need to setup the following:

  • AWS Free tier account will work.

  • Cloudflare Free tier account will work.

  • Docker Recommended but not mandatory

Fork and Clone the repo

1

Fork the repo

Click on the fork button on Github to fork the repo

2

Clone the repo

Once the repo is forked you can clone it on your local machine using:

git clone https://github.com/your-username/unsend.git

Install Dependencies

1

corepack enable
2

pnpm install

Setup environment variables:

1

Copy the env.example file into .env

 cp .env.example .env
2

Nextauth secret

Use the following command to generate a key and add it under NEXTAUTH_SECRET

openssl rand -base64 32
3

Setup Github Oauth

Next, create a new GitHub App. This will allow you to sign in to Unsend with your GitHub account.4

Add the homepage as:

http://localhost:3000/login

and callback URL as:

http://localhost:3000/api/auth/callback/github

Once the app is added you can add the Client ID under GITHUB_IDand CLIENT SECRET under GITHUB_SECRET

4

Setup AWS credentials

Next, we need to add in the AWS credentials. Follow the detailed guide to get the AWS credentials with accurate permissions and add them in:

AWS_ACCESS_KEY_ID=<access-key-id>
AWS_SECRET_ACCESS_KEY=<secret-access-key>

Once the app is added you can add the Client ID under GITHUB_IDand CLIENT SECRET under GITHUB_SECRET

5

Optional: Enable prisma optimize

To enable Prisma Optimize and get insights on queires you can add this in you .env

ENABLE_PRISMA_CLIENT=true

Running Unsend locally

We are using a local Postgresql server and a local Redis server. But if you don’t have docker you can also manually set these up.

1

Start the dashboard

pnpm d
2

Dashboard and Landing page will start running

Dashboard will be started on

http://localhost:3000

Landing page will be started on

http://localhost:3001
3

Once you login with Github you will be prompted with SES settings. You will need to run cloudflare tunnel to add the callback URL

Run the following command to get the URL. Here is the more detailed guide by cloudflare

cloudflared tunnel --url http://localhost:3000

You can paste the URL provided by cloudflare in the Callback URL section

Option 2: Using your own database or hosted database

1

Set up your PostgreSQL and Redis database in Environment Variables

DATABASE_URL=""
REDIS_URL=""
2

Migrate the database

pnpm db:migrate-dev
3

Start the development server

pnpm dev
4

Once you login with Github you will be prompted with SES settings. You will need to run cloudflare tunnel to add the callback URL

Run the following command to get the URL. Here is the more detailed guide by cloudflare

cloudflared tunnel --url http://localhost:3000

You can paste the URL provided by cloudflare in the Callback URL section

Run documentation

To run the documentation run the following command:

pnpm dev:docs