Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
# Get your OpenAI API Key here for chat models: https://platform.openai.com/account/api-keys
OPENAI_API_KEY=****

# Get your Fireworks AI API Key here for reasoning models: https://fireworks.ai/account/api-keys
FIREWORKS_API_KEY=****

# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32`
AUTH_SECRET=****

# The following keys below are automatically created and
# added to your environment when you deploy on vercel

# Instructions to create a Vercel Blob Store here: https://vercel.com/docs/storage/vercel-blob
BLOB_READ_WRITE_TOKEN=****

# Instructions to create a database here: https://vercel.com/docs/storage/vercel-postgres/quickstart
POSTGRES_URL=****

NEXT_PUBLIC_PROJECT_ID=
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
NEXTAUTH_SECRET=

PATTERN_CORE_ENDPOINT=
AUTH_TRUST_HOST=
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Lint and Typechecking
name: CI
on:
pull_request:
branches: ['main', 'dev']
types: [opened, edited, reopened]

jobs:
lint:
Expand All @@ -13,8 +14,6 @@ jobs:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand All @@ -34,8 +33,6 @@ jobs:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker image
on:
push:
branches:
- dev

jobs:
build-and-push:
runs-on: ubuntu-latest

permissions:
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: 'linux/amd64'
push: true
tags: pattern-tech/pattern-app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/.next /app/.next
COPY --from=build /app/public /app/public

EXPOSE 3000
CMD ["pnpm", "start"]
9 changes: 2 additions & 7 deletions app/(auth)/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ import { authConfig } from './auth.config';
/**
* TODO: Move all configs into a validated configs module to avoid duplication
*
* https://github.com/pattern-tech/pattern-ui/issues/3
* https://github.com/pattern-tech/pattern-app/issues/3
*/
export const nextAuthSecret = process.env.NEXTAUTH_SECRET;
if (!nextAuthSecret) {
throw new Error('NEXTAUTH_SECRET is not set');
}

export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
if (!projectId) {
throw new Error('NEXT_PUBLIC_PROJECT_ID is not set');
}

const patternCoreEndpoint = process.env.PATTERN_CORE_ENDPOINT;
if (!patternCoreEndpoint) {
throw new Error('PATTERN_CORE_ENDPOINT is not set');
Expand Down Expand Up @@ -80,7 +75,7 @@ const providers = [
/**
* TODO: Handle errors accordingly, and show the user what went wrong
*
* https://github.com/pattern-tech/pattern-ui/issues/4
* https://github.com/pattern-tech/pattern-app/issues/4
*/

return null;
Expand Down
11 changes: 7 additions & 4 deletions app/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import {
import { getCsrfToken, getSession, signIn, signOut } from 'next-auth/react';
import { getAddress } from 'viem';

export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
if (!projectId) throw new Error('Project ID is not defined');
export const walletConnectProjectId =
process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID;
if (!walletConnectProjectId) throw new Error('Project ID is not defined');

export const metadata = {
name: 'Pattern',
Expand All @@ -35,7 +36,7 @@ export const chains: [AppKitNetwork, ...AppKitNetwork[]] = [

export const wagmiAdapter = new WagmiAdapter({
networks: chains,
projectId,
projectId: walletConnectProjectId,
ssr: true,
});

Expand All @@ -57,7 +58,9 @@ export const siweConfig = createSIWEConfig({
getMessageParams: async () => ({
domain: typeof window !== 'undefined' ? window.location.host : '',
uri: typeof window !== 'undefined' ? window.location.origin : '',
chains: chains.map((chain: AppKitNetwork) => Number.parseInt(chain.id.toString())),
chains: chains.map((chain: AppKitNetwork) =>
Number.parseInt(chain.id.toString()),
),
}),
createMessage: ({ address, ...args }: SIWECreateMessageArgs) =>
formatMessage(args, normalizeAddress(address)),
Expand Down
18 changes: 9 additions & 9 deletions app/context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
"use client";
'use client';

import { createAppKit } from "@reown/appkit/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import React, { ReactNode } from "react";
import { State, WagmiProvider } from "wagmi";
import { createAppKit } from '@reown/appkit/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React, { type ReactNode } from 'react';
import { type State, WagmiProvider } from 'wagmi';

import {
chains,
metadata,
projectId,
walletConnectProjectId,
siweConfig,
wagmiAdapter,
} from "../config";
} from '../config';

const queryClient = new QueryClient();

if (!projectId) throw new Error("Project ID is not defined");
if (!walletConnectProjectId) throw new Error('Project ID is not defined');

createAppKit({
adapters: [wagmiAdapter],
networks: chains,
projectId,
projectId: walletConnectProjectId,
siweConfig,
metadata,
features: {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"name": "ai-chatbot",
"name": "pattern-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbo",
"build": "tsx lib/db/migrate && next build",
"build": "next build",
"start": "next start",
"lint": "next lint && biome lint --write --unsafe",
"lint:fix": "next lint --fix && biome lint --write --unsafe",
"format": "biome format --write",
"db:generate": "drizzle-kit generate",
"db:migrate": "npx tsx lib/db/migrate.ts",
"db:studio": "drizzle-kit studio",
"db:push": "drizzle-kit push",
"db:pull": "drizzle-kit pull",
Expand Down Expand Up @@ -114,5 +113,6 @@
"tailwindcss": "^3.4.1",
"tsx": "^4.19.1",
"typescript": "^5.6.3"
}
},
"packageManager": "pnpm@9.14.1"
}