Full Code of georgegebbett/recipe-buddy for AI

master 595412f5fe4a cached
149 files
204.9 KB
56.3k tokens
108 symbols
1 requests
Download .txt
Showing preview only (238K chars total). Download the full file or copy to clipboard to get everything.
Repository: georgegebbett/recipe-buddy
Branch: master
Commit: 595412f5fe4a
Files: 149
Total size: 204.9 KB

Directory structure:
gitextract_33v7gf8m/

├── .dockerignore
├── .eslintrc.json
├── .github/
│   ├── actions/
│   │   ├── build-setup/
│   │   │   └── action.yml
│   │   ├── format/
│   │   │   └── action.yml
│   │   └── lint/
│   │       └── action.yml
│   └── workflows/
│       ├── ci.yml
│       ├── code-style.yml
│       └── release.yaml
├── .gitignore
├── .idea/
│   ├── .gitignore
│   ├── aws.xml
│   ├── codeStyles/
│   │   ├── Project.xml
│   │   └── codeStyleConfig.xml
│   ├── dataSources.xml
│   ├── git_toolbox_blame.xml
│   ├── git_toolbox_prj.xml
│   ├── inspectionProfiles/
│   │   └── Project_Default.xml
│   ├── jsLibraryMappings.xml
│   ├── misc.xml
│   ├── modules.xml
│   ├── prettier.xml
│   ├── recipe-buddy-v2.iml
│   ├── recipe-buddy.iml
│   ├── runConfigurations/
│   │   ├── Front_and_Back.xml
│   │   ├── Front_end_dev__back_end_docker.xml
│   │   └── recipe_buddy__Compose_Deployment.xml
│   ├── sqldialects.xml
│   └── vcs.xml
├── .prettierrc.cjs
├── Dockerfile
├── LICENSE
├── README.md
├── SECURITY.md
├── components.json
├── drizzle.config.ts
├── knip.json
├── next.config.js
├── package.json
├── postcss.config.cjs
├── scripts/
│   └── run.sh
├── src/
│   ├── app/
│   │   ├── (dashboard)/
│   │   │   ├── recipes/
│   │   │   │   ├── [id]/
│   │   │   │   │   ├── loading.tsx
│   │   │   │   │   ├── page.tsx
│   │   │   │   │   └── recipeForm.tsx
│   │   │   │   ├── layout.tsx
│   │   │   │   ├── loading.tsx
│   │   │   │   └── page.tsx
│   │   │   └── settings/
│   │   │       ├── layout.tsx
│   │   │       ├── loading.tsx
│   │   │       └── page.tsx
│   │   ├── (setup)/
│   │   │   └── setup/
│   │   │       └── page.tsx
│   │   ├── api/
│   │   │   ├── auth/
│   │   │   │   └── [...nextauth]/
│   │   │   │       └── route.ts
│   │   │   └── trpc/
│   │   │       └── [trpc]/
│   │   │           └── route.ts
│   │   ├── layout.tsx
│   │   └── page.tsx
│   ├── components/
│   │   ├── card-skeleton.tsx
│   │   ├── delete-recipe-button.tsx
│   │   ├── empty-placeholder.tsx
│   │   ├── grocy-product-combobox.tsx
│   │   ├── grocy-status.tsx
│   │   ├── grocy-unit-combobox.tsx
│   │   ├── header.tsx
│   │   ├── icons.tsx
│   │   ├── ingredient-group-combobox.tsx
│   │   ├── ingredient-note-dialog.tsx
│   │   ├── ingredient-table.tsx
│   │   ├── main-nav.tsx
│   │   ├── mobile-nav.tsx
│   │   ├── mode-toggle.tsx
│   │   ├── new-recipe-dialog.tsx
│   │   ├── new-user-dialog.tsx
│   │   ├── recipe-card.tsx
│   │   ├── recipe-title-input.tsx
│   │   ├── shell.tsx
│   │   ├── sign-in-button.tsx
│   │   ├── site-footer.tsx
│   │   ├── theme-provider.tsx
│   │   ├── ui/
│   │   │   ├── accordion.tsx
│   │   │   ├── alert.tsx
│   │   │   ├── avatar.tsx
│   │   │   ├── button.tsx
│   │   │   ├── card.tsx
│   │   │   ├── command.tsx
│   │   │   ├── dialog.tsx
│   │   │   ├── dropdown-menu.tsx
│   │   │   ├── form.tsx
│   │   │   ├── input.tsx
│   │   │   ├── label.tsx
│   │   │   ├── popover.tsx
│   │   │   ├── scroll-area.tsx
│   │   │   ├── skeleton.tsx
│   │   │   ├── sonner.tsx
│   │   │   ├── table.tsx
│   │   │   └── textarea.tsx
│   │   ├── user-account-nav.tsx
│   │   ├── user-avatar.tsx
│   │   └── user-table.tsx
│   ├── config/
│   │   ├── dashboard.ts
│   │   └── site.ts
│   ├── env.js
│   ├── hooks/
│   │   └── use-lock-body.ts
│   ├── lib/
│   │   ├── logger.ts
│   │   ├── routes.ts
│   │   ├── session.ts
│   │   └── utils.ts
│   ├── server/
│   │   ├── api/
│   │   │   ├── modules/
│   │   │   │   ├── grocy/
│   │   │   │   │   ├── procedures/
│   │   │   │   │   │   ├── checkGrocyConnection.ts
│   │   │   │   │   │   ├── createRecipeInGrocy.ts
│   │   │   │   │   │   ├── createRecipeInGrocySchema.ts
│   │   │   │   │   │   ├── getGrocyProducts.ts
│   │   │   │   │   │   └── getGrocyQuantityUnits.ts
│   │   │   │   │   └── service/
│   │   │   │   │       ├── client.ts
│   │   │   │   │       └── getGrocyProducts.ts
│   │   │   │   ├── recipes/
│   │   │   │   │   ├── procedures/
│   │   │   │   │   │   ├── deleteRecipe.ts
│   │   │   │   │   │   ├── getById.ts
│   │   │   │   │   │   ├── listRecipes.ts
│   │   │   │   │   │   ├── scrapeRecipe.ts
│   │   │   │   │   │   └── scrapeRecipeSchema.ts
│   │   │   │   │   └── service/
│   │   │   │   │       ├── deleteRecipe.ts
│   │   │   │   │       ├── schemas.ts
│   │   │   │   │       └── scraper.ts
│   │   │   │   └── users/
│   │   │   │       ├── procedures/
│   │   │   │       │   ├── checkIsSetup.ts
│   │   │   │       │   ├── createUser.ts
│   │   │   │       │   ├── createUserSchema.ts
│   │   │   │       │   ├── listUsers.ts
│   │   │   │       │   └── setupUser.ts
│   │   │   │       └── service/
│   │   │   │           ├── checkIsSetup.ts
│   │   │   │           └── createUser.ts
│   │   │   ├── root.ts
│   │   │   ├── routers/
│   │   │   │   ├── grocy.ts
│   │   │   │   ├── recipe.ts
│   │   │   │   └── user.ts
│   │   │   └── trpc.ts
│   │   ├── auth.ts
│   │   └── db/
│   │       ├── drizzle/
│   │       │   ├── 0000_rare_sauron.sql
│   │       │   ├── 0001_worthless_aqueduct.sql
│   │       │   └── meta/
│   │       │       ├── 0000_snapshot.json
│   │       │       ├── 0001_snapshot.json
│   │       │       └── _journal.json
│   │       ├── drizzle-migrate.mjs
│   │       ├── index.ts
│   │       ├── migrate.ts
│   │       ├── schema.ts
│   │       └── tsconfig.json
│   ├── styles/
│   │   └── globals.css
│   ├── trpc/
│   │   ├── react.tsx
│   │   ├── server.ts
│   │   └── shared.ts
│   └── types/
│       └── index.d.ts
├── tailwind.config.js
└── tsconfig.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .dockerignore
================================================
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
knip.json
sqlite.db
.env
.env.example


================================================
FILE: .eslintrc.json
================================================
{
  "$schema": "https://json.schemastore.org/eslintrc",
  "root": true,
  "extends": [
    "next/core-web-vitals",
    "prettier",
    "plugin:tailwindcss/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:react/recommended"
  ],
  "plugins": [
    "tailwindcss",
    "react"
  ],
  "rules": {
    "@next/next/no-html-link-for-pages": "off",
    "react/jsx-key": "off",
    "react/no-array-index-key": "warn",
    "tailwindcss/no-custom-classname": "off",
    "tailwindcss/classnames-order": "error",
    "react/prop-types": "off",
    "react/no-unknown-property": "off"
  },
  "globals": {
    "React": "writable"
  },
  "settings": {
    "react": {
      "version": "detect"
    },
    "tailwindcss": {
      "callees": [
        "cn",
        "cva"
      ],
      "config": "tailwind.config.js"
    },
    "next": {
      "rootDir": true
    }
  },
  "overrides": [
    {
      "files": [
        "*.ts",
        "*.tsx"
      ],
      "parser": "@typescript-eslint/parser"
    }
  ]
}


================================================
FILE: .github/actions/build-setup/action.yml
================================================
name: 'Prepare'
description: 'Sets up the build for NodeJS and cache'

runs:
  using: "composite"
  steps:
    - uses: pnpm/action-setup@v4
      name: Install pnpm
      with:
        run_install: false

    - name: Install Node.js
      uses: actions/setup-node@v4
      with:
        node-version: 20
        cache: 'pnpm'

    - name: Install dependencies
      run: pnpm install
      shell: bash


================================================
FILE: .github/actions/format/action.yml
================================================
name: 'Format'
description: 'Ensures the repo matches Prettier rules'
runs:
  using: "composite"
  steps:
    - name: Format
      shell: bash
      run: pnpm format


================================================
FILE: .github/actions/lint/action.yml
================================================
name: 'Lint'
description: 'Lints the repository'

runs:
  using: "composite"
  steps:
    - name: Lint
      shell: bash
      run: pnpm lint



================================================
FILE: .github/workflows/ci.yml
================================================
name: CI

on:
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  code-style:
    uses: ./.github/workflows/code-style.yml

  check:
    runs-on: ubuntu-20.04
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4

      - name: Setup
        uses: ./.github/actions/build-setup

      - name: Check
        run: pnpm check

  knip:
    runs-on: ubuntu-20.04
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4

      - name: Setup
        uses: ./.github/actions/build-setup

      - name: Check
        run: pnpm knip


================================================
FILE: .github/workflows/code-style.yml
================================================
name: Code Style Check
on:
  workflow_call:

jobs:
  lint:
    runs-on: ubuntu-20.04
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4

      - name: Setup
        uses: ./.github/actions/build-setup

      - name: Lint
        uses: ./.github/actions/lint

  format:
    runs-on: ubuntu-20.04
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v3

      - name: Setup
        uses: ./.github/actions/build-setup

      - name: Format
        uses: ./.github/actions/format


================================================
FILE: .github/workflows/release.yaml
================================================
name: Create and publish Docker image

on:
  release:
    types: [ published ]

env:
  REGISTRY: ghcr.io

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          # list of Docker images to use as base name for tags
          images: ghcr.io/georgegebbett/recipe-buddy
          # generate Docker tags based on the following events/attributes
          tags: |
            type=semver,pattern=${{ github.event.release.tag_name }}
            type=sha            

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

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to the Container registry
        uses: docker/login-action@v3
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max


================================================
FILE: .gitignore
================================================
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# database
/prisma/db.sqlite
/prisma/db.sqlite-journal

# next.js
/.next/
/out/
next-env.d.ts

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
.env
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo

sqlite.db


================================================
FILE: .idea/.gitignore
================================================
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions


================================================
FILE: .idea/aws.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="accountSettings">
    <option name="activeProfile" value="profile:default" />
    <option name="activeRegion" value="us-east-1" />
    <option name="recentlyUsedProfiles">
      <list>
        <option value="profile:default" />
      </list>
    </option>
    <option name="recentlyUsedRegions">
      <list>
        <option value="us-east-1" />
      </list>
    </option>
  </component>
</project>

================================================
FILE: .idea/codeStyles/Project.xml
================================================
<component name="ProjectCodeStyleConfiguration">
  <code_scheme name="Project" version="173">
    <HTMLCodeStyleSettings>
      <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
      <option name="HTML_QUOTE_STYLE" value="Single" />
      <option name="HTML_ENFORCE_QUOTES" value="true" />
    </HTMLCodeStyleSettings>
    <JSCodeStyleSettings version="0">
      <option name="FORCE_SEMICOLON_STYLE" value="true" />
      <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
      <option name="USE_DOUBLE_QUOTES" value="false" />
      <option name="FORCE_QUOTE_STYlE" value="true" />
      <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
      <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
      <option name="SPACES_WITHIN_IMPORTS" value="true" />
    </JSCodeStyleSettings>
    <TypeScriptCodeStyleSettings version="0">
      <option name="FORCE_SEMICOLON_STYLE" value="true" />
      <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
      <option name="USE_DOUBLE_QUOTES" value="false" />
      <option name="FORCE_QUOTE_STYlE" value="true" />
      <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
      <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
      <option name="SPACES_WITHIN_IMPORTS" value="true" />
    </TypeScriptCodeStyleSettings>
    <VueCodeStyleSettings>
      <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
      <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
    </VueCodeStyleSettings>
    <codeStyleSettings language="HTML">
      <option name="SOFT_MARGINS" value="80" />
      <indentOptions>
        <option name="INDENT_SIZE" value="2" />
        <option name="CONTINUATION_INDENT_SIZE" value="2" />
        <option name="TAB_SIZE" value="2" />
      </indentOptions>
    </codeStyleSettings>
    <codeStyleSettings language="JavaScript">
      <option name="SOFT_MARGINS" value="80" />
      <indentOptions>
        <option name="INDENT_SIZE" value="2" />
        <option name="CONTINUATION_INDENT_SIZE" value="2" />
        <option name="TAB_SIZE" value="2" />
      </indentOptions>
    </codeStyleSettings>
    <codeStyleSettings language="TypeScript">
      <option name="SOFT_MARGINS" value="80" />
      <indentOptions>
        <option name="INDENT_SIZE" value="2" />
        <option name="CONTINUATION_INDENT_SIZE" value="2" />
        <option name="TAB_SIZE" value="2" />
      </indentOptions>
    </codeStyleSettings>
    <codeStyleSettings language="Vue">
      <option name="SOFT_MARGINS" value="80" />
      <indentOptions>
        <option name="CONTINUATION_INDENT_SIZE" value="2" />
      </indentOptions>
    </codeStyleSettings>
  </code_scheme>
</component>

================================================
FILE: .idea/codeStyles/codeStyleConfig.xml
================================================
<component name="ProjectCodeStyleConfiguration">
  <state>
    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
  </state>
</component>

================================================
FILE: .idea/dataSources.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
    <data-source source="LOCAL" name="@localhost" uuid="dcc5ae3c-b275-40a9-8d48-bd6530d677e1">
      <driver-ref>mongo</driver-ref>
      <synchronize>true</synchronize>
      <jdbc-driver>com.dbschema.MongoJdbcDriver</jdbc-driver>
      <jdbc-url>mongodb://localhost:27017</jdbc-url>
      <working-dir>$ProjectFileDir$</working-dir>
    </data-source>
    <data-source source="LOCAL" name="sqlite.db" uuid="77c813d4-b24d-40f0-8fd9-765fc0b25509">
      <driver-ref>sqlite.xerial</driver-ref>
      <synchronize>true</synchronize>
      <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
      <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/sqlite.db</jdbc-url>
      <working-dir>$ProjectFileDir$</working-dir>
    </data-source>
  </component>
</project>

================================================
FILE: .idea/git_toolbox_blame.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GitToolBoxBlameSettings">
    <option name="version" value="2" />
  </component>
</project>

================================================
FILE: .idea/git_toolbox_prj.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GitToolBoxProjectSettings">
    <option name="commitMessageIssueKeyValidationOverride">
      <BoolValueOverride>
        <option name="enabled" value="true" />
      </BoolValueOverride>
    </option>
    <option name="commitMessageValidationEnabledOverride">
      <BoolValueOverride>
        <option name="enabled" value="true" />
      </BoolValueOverride>
    </option>
  </component>
</project>

================================================
FILE: .idea/inspectionProfiles/Project_Default.xml
================================================
<component name="InspectionProjectProfileManager">
  <profile version="1.0">
    <option name="myName" value="Project Default" />
    <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
  </profile>
</component>

================================================
FILE: .idea/jsLibraryMappings.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="JavaScriptLibraryMappings">
    <includedPredefinedLibrary name="Node.js Core" />
  </component>
</project>

================================================
FILE: .idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="MarkdownSettingsMigration">
    <option name="stateVersion" value="1" />
  </component>
</project>

================================================
FILE: .idea/modules.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/recipe-buddy-v2.iml" filepath="$PROJECT_DIR$/.idea/recipe-buddy-v2.iml" />
    </modules>
  </component>
</project>

================================================
FILE: .idea/prettier.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="PrettierConfiguration">
    <option name="myConfigurationMode" value="AUTOMATIC" />
    <option name="myRunOnSave" value="true" />
    <option name="myRunOnReformat" value="true" />
  </component>
</project>

================================================
FILE: .idea/recipe-buddy-v2.iml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
      <excludeFolder url="file://$MODULE_DIR$/temp" />
      <excludeFolder url="file://$MODULE_DIR$/tmp" />
      <excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

================================================
FILE: .idea/recipe-buddy.iml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/temp" />
      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
      <excludeFolder url="file://$MODULE_DIR$/tmp" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

================================================
FILE: .idea/runConfigurations/Front_and_Back.xml
================================================
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Front and Back" type="CompoundRunConfigurationType">
    <toRun name="Start Backend" type="js.build_tools.npm" />
    <toRun name="Start Frontend" type="js.build_tools.npm" />
    <method v="2" />
  </configuration>
</component>

================================================
FILE: .idea/runConfigurations/Front_end_dev__back_end_docker.xml
================================================
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Front end dev, back end docker" type="CompoundRunConfigurationType">
    <toRun name="docker-compose-dev.yml: Compose Deployment" type="docker-deploy" />
    <toRun name="Start Frontend" type="js.build_tools.npm" />
    <method v="2" />
  </configuration>
</component>

================================================
FILE: .idea/runConfigurations/recipe_buddy__Compose_Deployment.xml
================================================
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="recipe-buddy: Compose Deployment" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
    <deployment type="docker-compose.yml">
      <settings>
        <option name="envFilePath" value="" />
        <option name="sourceFilePath" value="../recipe-buddy/docker-compose.yml" />
      </settings>
    </deployment>
    <method v="2" />
  </configuration>
</component>

================================================
FILE: .idea/sqldialects.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="SqlDialectMappings">
    <file url="PROJECT" dialect="SQLite" />
  </component>
</project>

================================================
FILE: .idea/vcs.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="" vcs="Git" />
  </component>
</project>

================================================
FILE: .prettierrc.cjs
================================================
/** @type {import('prettier').Config} */
module.exports = {
  endOfLine: 'lf',
  semi: false,
  singleQuote: false,
  tabWidth: 2,
  trailingComma: 'es5',
  importOrder: [
    '^(react/(.*)$)|^(react$)',
    '^(next/(.*)$)|^(next$)',
    '<THIRD_PARTY_MODULES>',
    '',
    '^types$',
    '^~/env(.*)$',
    '^~/types/(.*)$',
    '^~/config/(.*)$',
    '^~/lib/(.*)$',
    '^~/hooks/(.*)$',
    '^~/components/ui/(.*)$',
    '^~/components/(.*)$',
    '^~/styles/(.*)$',
    '^~/app/(.*)$',
    '',
    '^[./]',
  ],
  importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'],
  plugins: ['@ianvs/prettier-plugin-sort-imports'],
};


================================================
FILE: Dockerfile
================================================
FROM node:18-alpine AS base

# mostly inspired from https://github.com/BretFisher/node-docker-good-defaults/blob/main/Dockerfile & https://github.com/remix-run/example-trellix/blob/main/Dockerfile

# Check https://github.com/nodejs/docker-node/blob/7c659dfc7bd632725695aa2112eb0cf0e5357cfd/README.md#nodealpine to understand why gcompat might be needed.
RUN apk add --no-cache gcompat
RUN corepack enable && corepack prepare pnpm@8.15.5 --activate
# set the store dir to a folder that is not in the project
RUN pnpm config set store-dir ~/.pnpm-store
RUN pnpm fetch

FROM base AS deps
USER node
# WORKDIR now sets correct permissions if you set USER first so `USER node` has permissions on `/app` directory
WORKDIR /home/node/app
COPY --chown=node:node package.json pnpm-lock.yaml* ./

USER root

RUN pnpm install

FROM base AS production-deps
WORKDIR /home/node/app

COPY --from=deps --chown=node:node /home/node/app/node_modules ./node_modules
COPY --chown=node:node package.json pnpm-lock.yaml* ./
RUN pnpm prune --prod

FROM base AS builder

WORKDIR /home/node/app
COPY --from=deps --chown=node:node /home/node/app/node_modules ./node_modules
COPY --chown=node:node src/server/db/drizzle ./migrations
COPY --chown=node:node . .

#RUN pnpm install --offline

ENV SKIP_ENV_VALIDATION=1

RUN pnpm build

FROM base AS runner
WORKDIR /home/node/app

RUN apk add --no-cache dumb-init

ENV NODE_ENV=production
ENV DATABASE_URL="/home/node/app/data/sqlite.db"

RUN mkdir data

VOLUME "/home/node/app/data"

COPY --from=builder /home/node/app/next.config.js ./
COPY --from=builder /home/node/app/public ./public
COPY --from=builder /home/node/app/package.json ./package.json
COPY --from=production-deps --chown=node:node home/node/app/node_modules ./node_modules


# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
# Some things are not allowed (see https://github.com/vercel/next.js/issues/38119#issuecomment-1172099259)
COPY --from=builder --chown=node:node /home/node/app/.next/standalone ./
COPY --from=builder --chown=node:node /home/node/app/.next/static ./.next/static
COPY --from=builder --chown=node:node /home/node/app/src/server/db ./db

COPY --from=builder --chown=node:node /home/node/app/migrations ./migrations

# Move the run script and litestream config to the runtime image
COPY --chown=node:node src/server/db/ ./migrations
COPY --chown=node:node scripts/run.sh ./run.sh

RUN npx tsc -b ./migrations

EXPOSE 3000

ENV PORT=3000
ENV HOSTNAME=0.0.0.0
ENV NEXTAUTH_URL_INTERNAL=http://0.0.0.0:3000

RUN chmod +x ./run.sh

CMD ["dumb-init", "--", "./run.sh"]


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
# Recipe Buddy

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua)
[![wakatime](https://wakatime.com/badge/user/43ab5910-d51d-486b-9e03-376e766a43d3/project/c2af7adc-0f49-4c92-bcaa-63bb2f09e9e2.svg)](https://wakatime.com/badge/user/43ab5910-d51d-486b-9e03-376e766a43d3/project/c2af7adc-0f49-4c92-bcaa-63bb2f09e9e2)

## Update - April 2024

V2 of Recipe Buddy is here! V2 brings a host of improvements, including:

* An all-new architecture - SQLIte replaces Mongo and Next.js replaces the massively overkill Nest.js and plain React
* Can be run in one (1) Docker container - no messing about with compose files
* A whole new UI

The only thing that hasn't really changed is the recipe scraping logic itself - that is coming (no promises on when
though)

## The problem

I am getting sick of manually importing recipes into Grocy.

## The solution

Overcomplication, naturally. Recipe Buddy is a web app which scrapes web pages for the
delicious [structured metadata](https://schema.org/Recipe) embedded therein.

Once the recipe has been extracted from the page, Recipe Buddy gives you a nice easy means to match each of its
ingredients up with a product from your Grocy stock, as well as a quantity unit. Once this is done, you simply hit the '
Add Recipe' button, and the TypeScript goblins painstakingly transcribe the recipe into your Grocy instance, ready for
meal planning!

## How you can have a go

"Well gee, George, that sounds mighty swell", I hear you say, "but how does little old me go about harnessing the
TypeScript goblins for my own recipe-scraping requirements?"

Well, dear reader, as I am a benevolent goblin-wrangler, I have imprisoned them in a poorly written Dockerfile for you!
All one needs to do to benefit from the gobliny goodness is as follows:

1. Generate yourself an auth secret using `openssl rand -base64 32`
2. Get the base url of your Grocy instance (everything up to the first `/`)
3. Get an API key for your Grocy instance
4. Run the following command:
    ```
   docker run \
     -p 3005:3000 \
     -v rb_data:/home/node/app/data \
     --env GROCY_API_KEY=YOUR_GROCY_API_KEY \
     --env GROCY_BASE_URL=YOUR_GROCY_BASE_URL \
     --env NEXTAUTH_SECRET=YOUR_AUTH_SECRET \
     --env NEXTAUTH_URL=http://localhost:3005 \
     ghcr.io/georgegebbett/recipe-buddy
   ```

## A disclaimer

I am apparently a professional software engineer, however I certainly do not profess to be any good at this stuff. I
hereby abdicate any responsibility for the misbehaviour of the TypeScript goblins. If you think you can do better, then
open a PR and I will almost certainly merge it without question.

Lots of love, George xoxoxoxo


================================================
FILE: SECURITY.md
================================================
# Security Policy

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported          |
| ------- | ------------------ |
| all     | :white_check_mark: |


## Reporting a Vulnerability

email me - github[at]georgegebbett[dot]co[dot]uk


================================================
FILE: components.json
================================================
{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "default",
  "rsc": true,
  "tsx": true,
  "tailwind": {
    "config": "tailwind.config.js",
    "css": "src/styles/globals.css",
    "baseColor": "slate",
    "cssVariables": true,
    "prefix": ""
  },
  "aliases": {
    "components": "~/components",
    "utils": "~/lib/utils"
  }
}

================================================
FILE: drizzle.config.ts
================================================
import { type Config } from "drizzle-kit"

import { env } from "./src/env"

export default {
  schema: "./src/server/db/schema.ts",
  driver: "better-sqlite",
  dbCredentials: {
    url: env.DATABASE_URL,
  },
  tablesFilter: ["recipe-buddy_*"],
  out: "./src/server/db/drizzle",
} satisfies Config


================================================
FILE: knip.json
================================================
{
  "$schema": "https://unpkg.com/knip@5/schema.json",
  "entry": [
    "src/server/db/drizzle-migrate.mjs"
  ],
  "ignore": [
    "src/components/ui/*.tsx",
    "src/trpc/**.*"
  ],
  "ignoreDependencies": [
    "@radix-ui/*",
    "server-only"
  ]
}


================================================
FILE: next.config.js
================================================
/**
 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
 * for Docker builds.
 */
await import("./src/env.js")

/** @type {import("next").NextConfig} */
const config = {
  output: "standalone",
}

export default config


================================================
FILE: package.json
================================================
{
  "name": "recipe-buddy",
  "version": "2.0.8",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "next build",
    "check": "tsc --noEmit",
    "db:migrate": "node migrations/drizzle-migrate.mjs",
    "db:migrate:dev": "dotenv tsx src/server/db/migrate.ts",
    "db:push": "dotenv drizzle-kit push:sqlite",
    "db:studio": "dotenv drizzle-kit studio",
    "dev": "next dev | pino-pretty",
    "format": "SKIP_ENV_VALIDATION=1 prettier -c src --ignore-path .gitignore",
    "format:fix": "prettier -l -w src --ignore-path .gitignore",
    "knip": "SKIP_ENV_VALIDATION=1 knip",
    "lint": "SKIP_ENV_VALIDATION=1 next lint",
    "lint:fix": "next lint --fix",
    "start": "next start"
  },
  "dependencies": {
    "@hookform/resolvers": "^3.3.3",
    "@planetscale/database": "^1.11.0",
    "@radix-ui/react-accordion": "^1.1.2",
    "@radix-ui/react-avatar": "^1.0.4",
    "@radix-ui/react-dialog": "^1.0.5",
    "@radix-ui/react-dropdown-menu": "^2.0.6",
    "@radix-ui/react-label": "^2.0.2",
    "@radix-ui/react-popover": "^1.0.7",
    "@radix-ui/react-scroll-area": "^1.0.5",
    "@radix-ui/react-slot": "^1.0.2",
    "@t3-oss/env-nextjs": "^0.7.1",
    "@tanstack/react-query": "^4.36.1",
    "@trpc/client": "^10.43.6",
    "@trpc/react-query": "^10.43.6",
    "@trpc/server": "^10.43.6",
    "bcrypt": "^5.1.1",
    "better-sqlite3": "^9.2.2",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.0.0",
    "cmdk": "^1.0.0",
    "drizzle-orm": "^0.30.9",
    "jsdom": "^23.0.1",
    "lucide-react": "^0.368.0",
    "next": "^14.0.3",
    "next-auth": "^4.24.5",
    "next-themes": "^0.2.1",
    "normalize-url": "^8.0.0",
    "pino": "^8.17.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-hook-form": "^7.49.2",
    "server-only": "^0.0.1",
    "slugify": "^1.6.6",
    "sonner": "^1.3.1",
    "superjson": "^2.2.1",
    "tailwind-merge": "^2.2.0",
    "tailwindcss-animate": "^1.0.7",
    "tsx": "^4.7.1",
    "typescript": "^5.1.6",
    "uuid": "^9.0.1",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@ianvs/prettier-plugin-sort-imports": "^4.1.1",
    "@types/bcrypt": "^5.0.2",
    "@types/better-sqlite3": "^7.6.8",
    "@types/jsdom": "^21.1.6",
    "@types/node": "^18.17.0",
    "@types/react": "^18.2.37",
    "@types/react-dom": "^18.2.15",
    "@types/uuid": "^9.0.7",
    "@typescript-eslint/eslint-plugin": "^7.4.0",
    "@typescript-eslint/parser": "^7.4.0",
    "autoprefixer": "^10.4.14",
    "dotenv-cli": "^7.3.0",
    "drizzle-kit": "^0.20.17",
    "eslint": "^8.57.0",
    "eslint-config-next": "13.0.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-react": "^7.34.1",
    "eslint-plugin-tailwindcss": "^3.11.0",
    "knip": "^5.46.0",
    "pino-pretty": "^10.3.1",
    "postcss": "^8.4.31",
    "prettier": "^3.1.0",
    "tailwindcss": "^3.3.5"
  },
  "packageManager": "pnpm@10.6.3+sha512.bb45e34d50a9a76e858a95837301bfb6bd6d35aea2c5d52094fa497a467c43f5c440103ce2511e9e0a2f89c3d6071baac3358fc68ac6fb75e2ceb3d2736065e6",
  "pnpm": {
    "onlyBuiltDependencies": [
      "bcrypt",
      "better-sqlite3",
      "es5-ext",
      "esbuild"
    ]
  },
  "ct3aMetadata": {
    "initVersion": "7.25.0"
  }
}


================================================
FILE: postcss.config.cjs
================================================
const config = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

module.exports = config;


================================================
FILE: scripts/run.sh
================================================
#!/bin/sh

## Check if DATABASE_URL is not set
#if [ -z "$DATABASE_URL" ]; then
#    # Check if all required variables are provided
#    if [ -n "$DATABASE_HOST" ] && [ -n "$DATABASE_USERNAME" ] && [ -n "$DATABASE_PASSWORD" ]  && [ -n "$DATABASE_NAME" ]; then
#        # Construct DATABASE_URL from the provided variables
#        DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}"
#        export DATABASE_URL
#    else
#        echo "Error: Required database environment variables are not set. Provide a postgres url for DATABASE_URL."
#        exit 1
#    fi
#fi
#
## Set DIRECT_URL to the value of DATABASE_URL if it is not set, required for migrations
#if [ -z "$DIRECT_URL" ]; then
#    export DIRECT_URL=$DATABASE_URL
#fi




# Apply migrations
npm run db:migrate
status=$?

# If migration fails (returns non-zero exit status), exit script with that status
if [ $status -ne 0 ]; then
    echo "Applying database migrations failed. This is mostly caused by the database being unavailable."
    echo "Exiting..."
    exit $status
fi

# Start server
node server.js


================================================
FILE: src/app/(dashboard)/recipes/[id]/loading.tsx
================================================
import { Skeleton } from "~/components/ui/skeleton"
import { DashboardShell } from "~/components/shell"

export default function DashboardLoading() {
  return (
    <DashboardShell>
      <Skeleton className="h-16" />
      <div className="flex flex-col gap-2">
        <Skeleton className="h-8" />
        <Skeleton className="h-8" />
        <Skeleton className="h-8" />
        <Skeleton className="h-8" />
        <Skeleton className="h-8" />
      </div>
    </DashboardShell>
  )
}


================================================
FILE: src/app/(dashboard)/recipes/[id]/page.tsx
================================================
import { unstable_noStore as noStore } from "next/dist/server/web/spec-extension/unstable-no-store"

import { env } from "~/env"
import { DashboardShell } from "~/components/shell"
import { RecipeForm } from "~/app/(dashboard)/recipes/[id]/recipeForm"

export default async function RecipePage({
  params,
}: {
  params: { id: string }
}) {
  noStore()

  const baseUrl = env.GROCY_BASE_URL

  return (
    <DashboardShell>
      <RecipeForm recipeId={parseInt(params.id)} grocyBaseUrl={baseUrl} />
    </DashboardShell>
  )
}


================================================
FILE: src/app/(dashboard)/recipes/[id]/recipeForm.tsx
================================================
"use client"

import Link from "next/link"
import { useRouter } from "next/navigation"
import { zodResolver } from "@hookform/resolvers/zod"
import {
  CreateRecipeInGrocyCommand,
  CreateRecipeInGrocyCommandSchema,
} from "~/server/api/modules/grocy/procedures/createRecipeInGrocySchema"
import { api } from "~/trpc/react"
import { RouterOutputs } from "~/trpc/shared"
import { Controller, FormProvider, useForm } from "react-hook-form"
import { toast } from "sonner"

import { Button } from "~/components/ui/button"
import {
  FormControl,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "~/components/ui/form"
import { Input } from "~/components/ui/input"
import { IngredientTable } from "~/components/ingredient-table"
import { RecipeTitleInput } from "~/components/recipe-title-input"

type RecipeFormProps = {
  recipeId: number
  grocyBaseUrl: string
}

export function RecipeForm({ recipeId, grocyBaseUrl }: RecipeFormProps) {
  const { data: recipe } = api.recipe.get.useQuery({
    id: recipeId,
  })

  return (
    recipe && <RecipeFormInner recipe={recipe} grocyBaseUrl={grocyBaseUrl} />
  )
}

type RecipeWithIngredients = RouterOutputs["recipe"]["get"]

function RecipeFormInner({
  recipe,
  grocyBaseUrl,
}: {
  recipe: NonNullable<RecipeWithIngredients>
  grocyBaseUrl?: string
}) {
  const form = useForm<CreateRecipeInGrocyCommand>({
    resolver: zodResolver(CreateRecipeInGrocyCommandSchema),
    defaultValues: {
      ingredients: recipe.ingredients.map((a) => {
        const amount = /\d+/g.exec(a.scrapedName)
        return {
          scrapedName: a.scrapedName,
          amount: amount ? parseInt(amount[0]) : undefined,
          ignored: false as const,
        }
      }),
      recipeName: recipe.name,
      method: recipe.steps ?? undefined,
      imageUrl: recipe.imageUrl ?? undefined,
      recipeBuddyRecipeId: recipe.id,
      servings: recipe.servings ?? undefined,
    },
  })

  const { push } = useRouter()

  const { mutate, isLoading: mutLoading } = api.grocy.createRecipe.useMutation({
    onSuccess: () => {
      toast("Recipe created")
      push("/recipes")
    },
  })

  const onSubmit = (a: CreateRecipeInGrocyCommand) => mutate(a)

  return (
    <FormProvider {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)}>
        <input hidden {...form.register("recipeBuddyRecipeId")} />
        <div className="flex flex-col gap-2">
          <Controller
            render={({ field }) => (
              <RecipeTitleInput value={field.value} onChange={field.onChange} />
            )}
            name="recipeName"
            control={form.control}
          />
          <FormField
            render={({ field }) => (
              <FormItem className="flex items-center gap-2">
                <FormLabel>Servings</FormLabel>
                <FormControl>
                  <Input className="max-w-[70px]" type="number" {...field} />
                </FormControl>
                <FormMessage />
              </FormItem>
            )}
            name="servings"
            control={form.control}
          />
          <Link
            href={recipe.url}
            className="pl-1 text-lg text-muted-foreground"
            target="_blank"
          >
            View Original
          </Link>
        </div>
        <div className="flex flex-col gap-2">
          <IngredientTable grocyBaseUrl={grocyBaseUrl ?? ""} />
          <Button type="submit" isLoading={mutLoading} className="self-end">
            Create Recipe
          </Button>
        </div>
      </form>
    </FormProvider>
  )
}


================================================
FILE: src/app/(dashboard)/recipes/layout.tsx
================================================
import { ReactNode } from "react"

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <div className="container flex-1 gap-12 md:grid-cols-[200px_1fr]">
      <main className="flex w-full flex-1 flex-col overflow-hidden">
        {children}
      </main>
    </div>
  )
}


================================================
FILE: src/app/(dashboard)/recipes/loading.tsx
================================================
import { CardSkeleton } from "~/components/card-skeleton"
import { DashboardHeader } from "~/components/header"
import { NewRecipeDialog } from "~/components/new-recipe-dialog"
import { DashboardShell } from "~/components/shell"

export default function DashboardLoading() {
  return (
    <DashboardShell>
      <DashboardHeader heading="Recipes" text="Add and manage recipes.">
        <NewRecipeDialog />
      </DashboardHeader>
      <div className="grid grid-cols-3 gap-4">
        <CardSkeleton />
        <CardSkeleton />
        <CardSkeleton />
        <CardSkeleton />
        <CardSkeleton />
        <CardSkeleton />
      </div>
    </DashboardShell>
  )
}


================================================
FILE: src/app/(dashboard)/recipes/page.tsx
================================================
"use client"

import { api } from "~/trpc/react"

import { EmptyPlaceholder } from "~/components/empty-placeholder"
import { DashboardHeader } from "~/components/header"
import { NewRecipeDialog } from "~/components/new-recipe-dialog"
import { RecipeCard } from "~/components/recipe-card"
import { DashboardShell } from "~/components/shell"

export default function DashboardPage() {
  const { data: recipes } = api.recipe.list.useQuery()

  return (
    <DashboardShell>
      <DashboardHeader heading="Recipes" text="Add and manage recipes.">
        <NewRecipeDialog />
      </DashboardHeader>
      {recipes && recipes.length > 0 ? (
        <div className="grid grid-cols-3 gap-4">
          {recipes.map((a) => (
            <RecipeCard key={a.id} recipe={a} />
          ))}
        </div>
      ) : (
        <NoRecipesPlaceholder />
      )}
    </DashboardShell>
  )
}

const NoRecipesPlaceholder = () => (
  <EmptyPlaceholder>
    <EmptyPlaceholder.Icon name="post" />
    <EmptyPlaceholder.Title>No recipes added</EmptyPlaceholder.Title>
    <EmptyPlaceholder.Description>
      You haven&apos;t added any recipes yet. Why not add one?
    </EmptyPlaceholder.Description>
    <NewRecipeDialog variant="outline" />
  </EmptyPlaceholder>
)


================================================
FILE: src/app/(dashboard)/settings/layout.tsx
================================================
import { ReactNode } from "react"

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <div className="container flex-1 gap-12 md:grid-cols-[200px_1fr]">
      <main className="flex w-full flex-1 flex-col overflow-hidden">
        {children}
      </main>
    </div>
  )
}


================================================
FILE: src/app/(dashboard)/settings/loading.tsx
================================================
import { CardSkeleton } from "~/components/card-skeleton"
import { DashboardHeader } from "~/components/header"
import { DashboardShell } from "~/components/shell"

export default function DashboardSettingsLoading() {
  return (
    <DashboardShell>
      <DashboardHeader
        heading="Settings"
        text="Manage account and website settings."
      />
      <div className="grid gap-10">
        <CardSkeleton />
      </div>
    </DashboardShell>
  )
}


================================================
FILE: src/app/(dashboard)/settings/page.tsx
================================================
import { redirect } from "next/navigation"
import { authOptions } from "~/server/auth"

import { getCurrentUser } from "~/lib/session"
import { GrocyStatus } from "~/components/grocy-status"
import { DashboardHeader } from "~/components/header"
import { DashboardShell } from "~/components/shell"
import { UserTable } from "~/components/user-table"

export const metadata = {
  title: "Settings",
  description: "Manage account and website settings.",
}

export default async function SettingsPage() {
  const user = await getCurrentUser()

  if (!user) {
    redirect(authOptions?.pages?.signIn || "/login")
  }

  return (
    <DashboardShell>
      <DashboardHeader heading="Settings" />
      <div className="grid gap-10">
        <GrocyStatus />
        <UserTable />
      </div>
    </DashboardShell>
  )
}


================================================
FILE: src/app/(setup)/setup/page.tsx
================================================
"use client"

import { useEffect } from "react"
import { useRouter } from "next/navigation"
import { zodResolver } from "@hookform/resolvers/zod"
import {
  CreateUser,
  CreateUserSchema,
} from "~/server/api/modules/users/procedures/createUserSchema"
import { api } from "~/trpc/react"
import { useForm } from "react-hook-form"

import { ROUTES } from "~/lib/routes"
import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardFooter,
  CardHeader,
  CardTitle,
} from "~/components/ui/card"
import {
  Form,
  FormControl,
  FormDescription,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "~/components/ui/form"
import { Input } from "~/components/ui/input"

export default function Page() {
  const form = useForm<CreateUser>({
    resolver: zodResolver(CreateUserSchema),
  })

  const utils = api.useContext()

  const { mutate, isLoading } = api.users.setupUser.useMutation({
    onSuccess: () => {
      utils.users.checkIsSetup.invalidate()
    },
  })

  const { data } = api.users.checkIsSetup.useQuery()

  const { push } = useRouter()

  useEffect(() => {
    if (data) {
      push(ROUTES.recipes.root)
    }
  }, [data])

  return (
    <div className="flex flex-row items-center justify-center">
      <Card>
        <CardHeader>
          <CardTitle>Setup User</CardTitle>
        </CardHeader>
        <CardContent>
          <Form {...form}>
            <form id="setupUser" onSubmit={form.handleSubmit((a) => mutate(a))}>
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Name</FormLabel>
                    <FormControl>
                      <Input autoComplete="off" {...field} />
                    </FormControl>
                    <FormDescription>The user&apos;s full name</FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="name"
                control={form.control}
              />
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Username</FormLabel>
                    <FormControl>
                      <Input autoComplete="off" {...field} />
                    </FormControl>
                    <FormDescription>
                      The username that will be used to log in
                    </FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="username"
                control={form.control}
              />
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Password</FormLabel>
                    <FormControl>
                      <Input
                        type="password"
                        autoComplete="new-password"
                        {...field}
                      />
                    </FormControl>
                    <FormDescription>The user&apos;s password</FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="password"
                control={form.control}
              />
            </form>
          </Form>
        </CardContent>
        <CardFooter>
          <Button type="submit" form="setupUser" disabled={isLoading}>
            Create User
          </Button>
        </CardFooter>
      </Card>
    </div>
  )
}


================================================
FILE: src/app/api/auth/[...nextauth]/route.ts
================================================
import { authOptions } from "~/server/auth"
import NextAuth from "next-auth"

const handler = NextAuth(authOptions)
export { handler as GET, handler as POST }


================================================
FILE: src/app/api/trpc/[trpc]/route.ts
================================================
import { type NextRequest } from "next/server"
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"
import { appRouter } from "~/server/api/root"
import { createTRPCContext } from "~/server/api/trpc"

import { env } from "~/env"

/**
 * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
 * handling a HTTP request (e.g. when you make requests from Client Components).
 */
const createContext = async (req: NextRequest) => {
  return createTRPCContext({
    headers: req.headers,
  })
}

const handler = (req: NextRequest) =>
  fetchRequestHandler({
    endpoint: "/api/trpc",
    req,
    router: appRouter,
    createContext: () => createContext(req),
    onError:
      env.NODE_ENV === "development"
        ? ({ path, error }) => {
            console.error(
              `❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
            )
          }
        : undefined,
  })

export { handler as GET, handler as POST }


================================================
FILE: src/app/layout.tsx
================================================
import "~/styles/globals.css"

import { Inter } from "next/font/google"
import { cookies } from "next/headers"
import { checkIsSetup } from "~/server/api/modules/users/service/checkIsSetup"
import { TRPCReactProvider } from "~/trpc/react"

import { dashboardConfig } from "~/config/dashboard"
import { getCurrentUser } from "~/lib/session"
import { cn } from "~/lib/utils"
import { Toaster } from "~/components/ui/sonner"
import { MainNav } from "~/components/main-nav"
import { SignInButton } from "~/components/sign-in-button"
import { SiteFooter } from "~/components/site-footer"
import { ThemeProvider } from "~/components/theme-provider"
import { UserAccountNav } from "~/components/user-account-nav"

const inter = Inter({
  subsets: ["latin"],
  variable: "--font-sans",
})

export const metadata = {
  title: "Recipe Buddy",
  description: "Recipe Buddy",
  icons: [{ rel: "icon", url: "/favicon.ico" }],
}

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  const user = await getCurrentUser()

  return (
    <html lang="en">
      <body
        className={cn(
          "min-h-screen bg-background font-sans antialiased",
          inter.variable
        )}
      >
        <TRPCReactProvider cookies={cookies().toString()}>
          <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
            <div className="flex min-h-screen flex-col space-y-6">
              <header className="sticky top-0 z-40 border-b bg-background">
                <div className="container flex h-16 items-center justify-between py-4">
                  <MainNav items={user ? dashboardConfig.mainNav : []} />
                  {user && (
                    <UserAccountNav
                      user={{
                        name: user?.name,
                        username: user?.username,
                      }}
                    />
                  )}
                </div>
              </header>
              {user ? (
                children
              ) : (await checkIsSetup()) ? (
                <div className="flex items-center justify-center">
                  <SignInButton />
                </div>
              ) : (
                children
              )}
              <Toaster />
            </div>
            <SiteFooter />
          </ThemeProvider>
        </TRPCReactProvider>
      </body>
    </html>
  )
}


================================================
FILE: src/app/page.tsx
================================================
import { redirect } from "next/navigation"
import { checkIsSetup } from "~/server/api/modules/users/service/checkIsSetup"
import { getServerAuthSession } from "~/server/auth"

import { ROUTES } from "~/lib/routes"

export default async function Home() {
  const session = await getServerAuthSession()

  const isSetup = await checkIsSetup()

  if (session) {
    redirect(ROUTES.recipes.root)
  } else if (!isSetup) {
    redirect(ROUTES.setup)
  }
}


================================================
FILE: src/components/card-skeleton.tsx
================================================
import { Card, CardContent, CardFooter, CardHeader } from "~/components/ui/card"
import { Skeleton } from "~/components/ui/skeleton"

export function CardSkeleton() {
  return (
    <Card>
      <CardHeader className="gap-2">
        <Skeleton className="h-5 w-1/5" />
        <Skeleton className="h-4 w-4/5" />
      </CardHeader>
      <CardContent className="h-10" />
      <CardFooter>
        <Skeleton className="h-8 w-[120px]" />
      </CardFooter>
    </Card>
  )
}


================================================
FILE: src/components/delete-recipe-button.tsx
================================================
"use client"

import { api } from "~/trpc/react"

import { Button } from "~/components/ui/button"

type DeleteRecipeButtonProps = {
  recipeId: number
}

export function DeleteRecipeButton({ recipeId }: DeleteRecipeButtonProps) {
  const utils = api.useUtils()
  const { mutate, isLoading } = api.recipe.delete.useMutation({
    onSuccess: () => utils.recipe.list.invalidate(),
  })

  const handleDelete = () => {
    mutate({ recipeId })
  }

  return (
    <Button variant="destructive" onClick={handleDelete} isLoading={isLoading}>
      Delete
    </Button>
  )
}


================================================
FILE: src/components/empty-placeholder.tsx
================================================
import * as React from "react"

import { cn } from "~/lib/utils"
import { Icons } from "~/components/icons"

interface EmptyPlaceholderProps extends React.HTMLAttributes<HTMLDivElement> {}

export function EmptyPlaceholder({
  className,
  children,
  ...props
}: EmptyPlaceholderProps) {
  return (
    <div
      className={cn(
        "flex min-h-[400px] flex-col items-center justify-center rounded-md border border-dashed p-8 text-center animate-in fade-in-50",
        className
      )}
      {...props}
    >
      <div className="mx-auto flex max-w-[420px] flex-col items-center justify-center text-center">
        {children}
      </div>
    </div>
  )
}

interface EmptyPlaceholderIconProps
  extends Partial<React.SVGProps<SVGSVGElement>> {
  name: keyof typeof Icons
}

EmptyPlaceholder.Icon = function EmptyPlaceHolderIcon({
  name,
  className,
  ...props
}: EmptyPlaceholderIconProps) {
  const Icon = Icons[name]

  if (!Icon) {
    return null
  }

  return (
    <div className="flex size-20 items-center justify-center rounded-full bg-muted">
      <Icon className={cn("size-10", className)} {...props} />
    </div>
  )
}

interface EmptyPlacholderTitleProps
  extends React.HTMLAttributes<HTMLHeadingElement> {}

EmptyPlaceholder.Title = function EmptyPlaceholderTitle({
  className,
  ...props
}: EmptyPlacholderTitleProps) {
  return (
    <h2 className={cn("mt-6 text-xl font-semibold", className)} {...props} />
  )
}

interface EmptyPlacholderDescriptionProps
  extends React.HTMLAttributes<HTMLParagraphElement> {}

EmptyPlaceholder.Description = function EmptyPlaceholderDescription({
  className,
  ...props
}: EmptyPlacholderDescriptionProps) {
  return (
    <p
      className={cn(
        "mb-8 mt-2 text-center text-sm font-normal leading-6 text-muted-foreground",
        className
      )}
      {...props}
    />
  )
}


================================================
FILE: src/components/grocy-product-combobox.tsx
================================================
"use client"

import * as React from "react"
import { api } from "~/trpc/react"
import { ChevronsUpDown, PlusCircleIcon } from "lucide-react"

import { Button } from "~/components/ui/button"
import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
} from "~/components/ui/command"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "~/components/ui/popover"

type GrocyProductComboboxProps = {
  productName: string
  disabled?: boolean
  value: string
  setValue: (newValue: string) => void
  baseUrl: string
}

export function GrocyProductCombobox({
  productName,
  disabled,
  value,
  setValue,
  baseUrl,
}: GrocyProductComboboxProps) {
  const [open, setOpen] = React.useState(false)

  const utils = api.useContext()

  const { data } = api.grocy.getProducts.useQuery()

  const newProductSlug = `/product/new?closeAfterCreation&flow=InplaceNewProductWithName&name=${productName}`

  const onCreateNewProduct = () => {
    window.addEventListener("visibilitychange", onRefocusAfterCreateProduct)
    window.open(`${baseUrl}${newProductSlug}`)
  }

  const onRefocusAfterCreateProduct = async () => {
    if (document.visibilityState === "visible") {
      await utils.grocy.getProducts.invalidate()
      await utils.grocy.getProducts.refetch()

      const prods = await utils.grocy.getProducts.ensureData()

      const [highestProd] = prods.sort(
        (a, b) => parseInt(b.id) - parseInt(a.id)
      )

      console.log("gighest prod")
      console.log(highestProd)

      if (highestProd) {
        setValue(highestProd.id)
      }

      window.removeEventListener(
        "visibilitychange",
        onRefocusAfterCreateProduct
      )
    }
  }

  return (
    data && (
      <Popover open={open} onOpenChange={setOpen}>
        <PopoverTrigger asChild>
          <Button
            variant="outline"
            role="combobox"
            aria-expanded={open}
            className="w-[200px] justify-between"
            disabled={disabled}
          >
            <div className="overflow-x-clip text-ellipsis">
              {value
                ? data.find((product) => product.id === value)?.name
                : "Select product..."}
            </div>
            <ChevronsUpDown className="ml-2 size-4 shrink-0 opacity-50" />
          </Button>
        </PopoverTrigger>
        <PopoverContent className="w-[200px] p-0">
          <Command>
            <CommandInput placeholder="Search products..." />
            <CommandList>
              <CommandEmpty>No product found</CommandEmpty>
              <CommandGroup>
                <CommandItem value="add" onSelect={onCreateNewProduct}>
                  <div className="flex items-center gap-2">
                    <PlusCircleIcon className="size-4 fill-black text-white" />
                    <p>Add Product</p>
                  </div>
                </CommandItem>
              </CommandGroup>
              <CommandSeparator />
              <CommandGroup className="max-h-52 overflow-y-scroll">
                {data.map((product) => (
                  <CommandItem
                    key={product.id}
                    value={product.name}
                    onSelect={(currentValue) => {
                      setValue(currentValue === product.id ? "" : product.id)
                      setOpen(false)
                    }}
                  >
                    {product.name}
                  </CommandItem>
                ))}
              </CommandGroup>
            </CommandList>
          </Command>
        </PopoverContent>
      </Popover>
    )
  )
}


================================================
FILE: src/components/grocy-status.tsx
================================================
"use client"

import { api } from "~/trpc/react"
import { CheckCircle } from "lucide-react"

import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"
import { Skeleton } from "~/components/ui/skeleton"

export const GrocyStatus = () => {
  const { data, isLoading } = api.grocy.checkConnection.useQuery()

  return (
    <>
      {data && data.success ? (
        <Alert>
          <CheckCircle className="size-4" />
          <AlertTitle>Connected to Grocy</AlertTitle>
          <AlertDescription>
            Connected to Grocy v{data.data.grocy_version.Version}
          </AlertDescription>
        </Alert>
      ) : isLoading ? (
        <Alert className="pl-10">
          <AlertTitle>
            <Skeleton className="h-5 w-40" />
          </AlertTitle>
          <AlertDescription>
            <Skeleton className="h-4 w-80" />
          </AlertDescription>
        </Alert>
      ) : (
        <Alert>
          <CheckCircle className="size-4" />
          <AlertTitle>Not connected to Grocy</AlertTitle>
          <AlertDescription>
            Unable to connect to Grocy - check your URL and API key
          </AlertDescription>
        </Alert>
      )}
    </>
  )
}


================================================
FILE: src/components/grocy-unit-combobox.tsx
================================================
import * as React from "react"
import { api } from "~/trpc/react"
import { ChevronsUpDown } from "lucide-react"

import { Button } from "~/components/ui/button"
import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
} from "~/components/ui/command"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "~/components/ui/popover"

export function GrocyUnitCombobox({
  disabled,
  value,
  setValue,
}: {
  disabled?: boolean
  value: string
  setValue: (newValue: string) => void
}) {
  const [open, setOpen] = React.useState(false)

  const { data } = api.grocy.getQuantityUnits.useQuery()

  return (
    data && (
      <Popover open={open} onOpenChange={setOpen}>
        <PopoverTrigger asChild>
          <Button
            variant="outline"
            role="combobox"
            aria-expanded={open}
            className="w-[200px] justify-between"
            disabled={disabled}
          >
            {value
              ? data.find((product) => product.id === value)?.name
              : "Select unit..."}
            <ChevronsUpDown className="ml-2 size-4 shrink-0 opacity-50" />
          </Button>
        </PopoverTrigger>
        <PopoverContent className="w-[200px] p-0">
          <Command>
            <CommandInput placeholder="Search units..." />
            <CommandList>
              <CommandEmpty>No product found.</CommandEmpty>
              <CommandGroup className="max-h-52 overflow-y-scroll">
                {data.map((product) => (
                  <CommandItem
                    key={product.id}
                    value={product.name}
                    onSelect={(currentValue) => {
                      setValue(currentValue === product.id ? "" : product.id)
                      setOpen(false)
                    }}
                  >
                    {product.name}
                  </CommandItem>
                ))}
              </CommandGroup>
            </CommandList>
          </Command>
        </PopoverContent>
      </Popover>
    )
  )
}


================================================
FILE: src/components/header.tsx
================================================
import { cn } from "~/lib/utils"

interface DashboardHeaderProps {
  heading: string
  text?: string
  children?: React.ReactNode
  className?: string
}

export function DashboardHeader({
  heading,
  text,
  children,
  className,
}: DashboardHeaderProps) {
  return (
    <div className={cn("flex items-center justify-between px-2", className)}>
      <div className="grid gap-1">
        <h1 className="font-heading text-3xl md:text-4xl">{heading}</h1>
        {text && <p className="text-lg text-muted-foreground">{text}</p>}
      </div>
      {children}
    </div>
  )
}


================================================
FILE: src/components/icons.tsx
================================================
import {
  AlertTriangle,
  ArrowRight,
  Check,
  ChevronLeft,
  ChevronRight,
  CookingPot,
  CreditCard,
  File,
  FileText,
  HelpCircle,
  Image,
  Laptop,
  Loader2,
  LucideProps,
  Moon,
  MoreVertical,
  Pizza,
  Plus,
  Settings,
  SunMedium,
  Trash,
  Twitter,
  User,
  X,
} from "lucide-react"

export const Icons = {
  logo: CookingPot,
  close: X,
  spinner: Loader2,
  chevronLeft: ChevronLeft,
  chevronRight: ChevronRight,
  trash: Trash,
  post: FileText,
  page: File,
  media: Image,
  settings: Settings,
  billing: CreditCard,
  ellipsis: MoreVertical,
  add: Plus,
  warning: AlertTriangle,
  user: User,
  arrowRight: ArrowRight,
  help: HelpCircle,
  pizza: Pizza,
  sun: SunMedium,
  moon: Moon,
  laptop: Laptop,
  gitHub: ({ ...props }: LucideProps) => (
    <svg
      aria-hidden="true"
      focusable="false"
      data-prefix="fab"
      data-icon="github"
      role="img"
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 496 512"
      {...props}
    >
      <path
        fill="currentColor"
        d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"
      ></path>
    </svg>
  ),
  twitter: Twitter,
  check: Check,
}


================================================
FILE: src/components/ingredient-group-combobox.tsx
================================================
import * as React from "react"
import { useState } from "react"
import { ChevronsUpDown, PlusCircleIcon } from "lucide-react"

import { Button } from "~/components/ui/button"
import {
  Command,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
} from "~/components/ui/command"
import { InputProps } from "~/components/ui/input"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "~/components/ui/popover"

interface IngredientGroupComboboxProps extends InputProps {
  setValue: (newValue: string) => void
  groups: string[]
  addGroup: (newGroup: string) => void
}

export function IngredientGroupCombobox({
  disabled,
  value,
  setValue,
  groups,
  addGroup,
}: IngredientGroupComboboxProps) {
  const [open, setOpen] = useState(false)

  const onCreateNewGroup = (groupName: string) => {
    if (groups.includes(groupName)) {
      setValue(groupName)
      setOpen(false)
      return
    }

    addGroup(groupName)
    setValue(groupName)
    setOpen(false)
  }

  const [textVal, setTextVal] = useState("")

  return (
    <Popover open={open} onOpenChange={setOpen}>
      <PopoverTrigger asChild>
        <Button
          variant="outline"
          role="combobox"
          aria-expanded={open}
          className="w-[200px] justify-between"
          disabled={disabled}
        >
          <div className="overflow-x-clip text-ellipsis">
            {value ?? "Select group..."}
          </div>
          <ChevronsUpDown className="ml-2 size-4 shrink-0 opacity-50" />
        </Button>
      </PopoverTrigger>
      <PopoverContent className="w-[200px] p-0">
        <Command>
          <CommandInput
            placeholder="Search groups..."
            value={textVal}
            onValueChange={setTextVal}
          />
          <CommandList>
            <CommandGroup forceMount>
              <CommandItem
                forceMount
                value="e388b184-9b92-4969-a5e9-a7d25df8dc72"
                onSelect={() => onCreateNewGroup(textVal)}
                disabled={textVal.length === 0 || groups.includes(textVal)}
              >
                <div className="flex items-center gap-2">
                  <PlusCircleIcon className="size-4 fill-black text-white" />
                  <p>Add {textVal}</p>
                </div>
              </CommandItem>
            </CommandGroup>
            <CommandSeparator />
            <CommandGroup className="max-h-52 overflow-y-scroll">
              {groups.map((group) => (
                <CommandItem
                  key={group}
                  value={group}
                  onSelect={(val) => {
                    setValue(val)
                    setOpen(false)
                  }}
                >
                  {group}
                </CommandItem>
              ))}
            </CommandGroup>
          </CommandList>
        </Command>
      </PopoverContent>
    </Popover>
  )
}


================================================
FILE: src/components/ingredient-note-dialog.tsx
================================================
import { useState } from "react"
import { DialogBody } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"

import { Button } from "~/components/ui/button"
import {
  Dialog,
  DialogContent,
  DialogFooter,
  DialogHeader,
  DialogTrigger,
} from "~/components/ui/dialog"
import { Textarea, TextareaProps } from "~/components/ui/textarea"

interface IngredientNoteDialogProps extends TextareaProps {}

export function IngredientNoteDialog({
  children,
  ...props
}: IngredientNoteDialogProps) {
  const [open, setOpen] = useState(false)

  return (
    <Dialog open={open} onOpenChange={setOpen}>
      <DialogTrigger asChild>{children}</DialogTrigger>
      <DialogContent>
        <DialogHeader>Add note</DialogHeader>
        <DialogBody>
          <Textarea {...props} />
        </DialogBody>
        <DialogFooter>
          <Button onClick={() => setOpen(false)}>Close</Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  )
}


================================================
FILE: src/components/ingredient-table.tsx
================================================
"use client"

import { useState } from "react"
import { CreateRecipeInGrocyCommand } from "~/server/api/modules/grocy/procedures/createRecipeInGrocySchema"
import { api } from "~/trpc/react"
import { SquarePen } from "lucide-react"
import {
  Controller,
  FormProvider,
  useFieldArray,
  useFormContext,
} from "react-hook-form"

import { Button } from "~/components/ui/button"
import { FormField, FormMessage } from "~/components/ui/form"
import { Input } from "~/components/ui/input"
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "~/components/ui/table"
import { GrocyUnitCombobox } from "~/components/grocy-unit-combobox"
import { IngredientGroupCombobox } from "~/components/ingredient-group-combobox"
import { IngredientNoteDialog } from "~/components/ingredient-note-dialog"

import { GrocyProductCombobox } from "./grocy-product-combobox"

type IngredientTableProps = {
  grocyBaseUrl: string
}

export function IngredientTable({ grocyBaseUrl }: IngredientTableProps) {
  const f = useFormContext<CreateRecipeInGrocyCommand>()

  const [groups, setGroups] = useState<string[]>([])

  const addGroup = (groupName: string) =>
    setGroups((old) => [groupName, ...old])

  const { fields } = useFieldArray<CreateRecipeInGrocyCommand>({
    name: "ingredients",
    control: f.control,
  })

  return (
    <div className="flex flex-col">
      <Table>
        <TableHeader>
          <TableRow>
            <TableHead>Name</TableHead>
            <TableHead>Product</TableHead>
            <TableHead>Amount</TableHead>
            <TableHead>Unit</TableHead>
            <TableHead>Group</TableHead>
            <TableHead>Note</TableHead>
            <TableHead>Ignore</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          <FormProvider {...f}>
            {fields.map((a, i) => (
              <IngredientTableRow
                ingredientName={a.scrapedName}
                key={a.id}
                index={i}
                grocyBaseUrl={grocyBaseUrl}
                addGroup={addGroup}
                groups={groups}
                {...a}
              />
            ))}
          </FormProvider>
        </TableBody>
      </Table>
    </div>
  )
}

const IngredientTableRow = ({
  ingredientName,
  index,
  grocyBaseUrl,
  groups,
  addGroup,
}: {
  ingredientName: string
  index: number
  grocyBaseUrl: string
  groups: string[]
  addGroup: (newGroup: string) => void
}) => {
  const f = useFormContext<CreateRecipeInGrocyCommand>()

  const { data: products } = api.grocy.getProducts.useQuery()

  const isRowIgnored = f.watch(`ingredients.${index}.ignored`)

  return (
    <TableRow>
      <TableCell className={isRowIgnored ? "line-through" : ""}>
        {ingredientName}
      </TableCell>
      <TableCell>
        <FormField
          render={({ field }) => (
            <>
              <GrocyProductCombobox
                baseUrl={grocyBaseUrl}
                productName={ingredientName}
                disabled={isRowIgnored}
                value={field.value}
                setValue={(a) => {
                  field.onChange(a)
                  const prod = products
                    ? products.find((b) => b.id === a)
                    : undefined
                  if (prod) {
                    f.setValue(`ingredients.${index}.unitId`, prod.qu_id_stock)
                  }
                }}
              />
              <FormMessage />
            </>
          )}
          name={`ingredients.${index}.productId`}
          control={f.control}
        />
      </TableCell>
      <TableCell>
        <FormField
          render={({ field }) => (
            <>
              <Input type="number" disabled={isRowIgnored} {...field} />
              <FormMessage />
            </>
          )}
          name={`ingredients.${index}.amount`}
          control={f.control}
        />
      </TableCell>
      <TableCell>
        <FormField
          render={({ field }) => (
            <>
              <GrocyUnitCombobox
                disabled={isRowIgnored}
                value={field.value}
                setValue={field.onChange}
              />
              <FormMessage />
            </>
          )}
          name={`ingredients.${index}.unitId`}
          control={f.control}
        />
      </TableCell>
      <TableCell>
        <FormField
          render={({ field }) => (
            <>
              <IngredientGroupCombobox
                disabled={isRowIgnored}
                setValue={field.onChange}
                groups={groups}
                addGroup={addGroup}
                value={field.value}
              />
              <FormMessage />
            </>
          )}
          name={`ingredients.${index}.group`}
          control={f.control}
        />
      </TableCell>
      <TableCell>
        <Controller
          render={({ field }) => {
            return (
              <IngredientNoteDialog {...field}>
                <Button
                  size="icon"
                  variant="outline"
                  data-has-note={field.value && field.value.trim().length > 0}
                  className="data-[has-note=true]:bg-green-200"
                >
                  <SquarePen strokeWidth={1} className={"size-4"} />
                </Button>
              </IngredientNoteDialog>
            )
          }}
          name={`ingredients.${index}.note`}
          control={f.control}
        />
      </TableCell>
      <TableCell>
        <Controller
          render={({ field }) => {
            return (
              <Button onClick={() => field.onChange(!field.value)}>
                {field.value ? "Unignore" : "Ignore"}
              </Button>
            )
          }}
          name={`ingredients.${index}.ignored`}
          control={f.control}
        />
      </TableCell>
    </TableRow>
  )
}


================================================
FILE: src/components/main-nav.tsx
================================================
"use client"

import * as React from "react"
import Link from "next/link"
import { useSelectedLayoutSegment } from "next/navigation"
import { MainNavItem } from "~/types"

import { siteConfig } from "~/config/site"
import { cn } from "~/lib/utils"

import { Icons } from "./icons"
import { MobileNav } from "./mobile-nav"

interface MainNavProps {
  items?: MainNavItem[]
  children?: React.ReactNode
}

export function MainNav({ items, children }: MainNavProps) {
  const segment = useSelectedLayoutSegment()
  const [showMobileMenu, setShowMobileMenu] = React.useState<boolean>(false)

  return (
    <div className="flex gap-6 md:gap-10">
      <Link href="/" className="hidden items-center space-x-2 md:flex">
        <Icons.logo />
        <span className="hidden font-bold sm:inline-block">
          {siteConfig.name}
        </span>
      </Link>
      {items?.length ? (
        <nav className="hidden gap-6 md:flex">
          {items?.map((item) => (
            <Link
              key={item.href}
              href={item.disabled ? "#" : item.href}
              className={cn(
                "flex items-center text-lg font-medium transition-colors hover:text-foreground/80 sm:text-sm",
                item.href.startsWith(`/${segment}`)
                  ? "text-foreground"
                  : "text-foreground/60",
                item.disabled && "cursor-not-allowed opacity-80"
              )}
            >
              {item.title}
            </Link>
          ))}
        </nav>
      ) : null}
      <button
        className="flex items-center space-x-2 md:hidden"
        onClick={() => setShowMobileMenu(!showMobileMenu)}
      >
        {showMobileMenu ? <Icons.close /> : <Icons.logo />}
        <span className="font-bold">Menu</span>
      </button>
      {showMobileMenu && items && (
        <MobileNav items={items}>{children}</MobileNav>
      )}
    </div>
  )
}


================================================
FILE: src/components/mobile-nav.tsx
================================================
import * as React from "react"
import Link from "next/link"
import { MainNavItem } from "~/types"

import { siteConfig } from "~/config/site"
import { cn } from "~/lib/utils"
import { useLockBody } from "~/hooks/use-lock-body"

import { Icons } from "./icons"

interface MobileNavProps {
  items: MainNavItem[]
  children?: React.ReactNode
}

export function MobileNav({ items, children }: MobileNavProps) {
  useLockBody()

  return (
    <div
      className={cn(
        "fixed inset-0 top-16 z-50 grid h-[calc(100vh-4rem)] grid-flow-row auto-rows-max overflow-auto p-6 pb-32 shadow-md animate-in slide-in-from-bottom-80 md:hidden"
      )}
    >
      <div className="relative z-20 grid gap-6 rounded-md bg-popover p-4 text-popover-foreground shadow-md">
        <Link href="/" className="flex items-center space-x-2">
          <Icons.logo />
          <span className="font-bold">{siteConfig.name}</span>
        </Link>
        <nav className="grid grid-flow-row auto-rows-max text-sm">
          {items.map((item) => (
            <Link
              key={item.href}
              href={item.disabled ? "#" : item.href}
              className={cn(
                "flex w-full items-center rounded-md p-2 text-sm font-medium hover:underline",
                item.disabled && "cursor-not-allowed opacity-60"
              )}
            >
              {item.title}
            </Link>
          ))}
        </nav>
        {children}
      </div>
    </div>
  )
}


================================================
FILE: src/components/mode-toggle.tsx
================================================
"use client"

import * as React from "react"
import { useTheme } from "next-themes"

import { Button } from "~/components/ui/button"
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu"

import { Icons } from "./icons"

export function ModeToggle() {
  const { setTheme } = useTheme()

  return (
    <DropdownMenu>
      <DropdownMenuTrigger asChild>
        <Button variant="ghost" size="sm" className="size-8 px-0">
          <Icons.sun className="rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
          <Icons.moon className="absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
          <span className="sr-only">Toggle theme</span>
        </Button>
      </DropdownMenuTrigger>
      <DropdownMenuContent align="end">
        <DropdownMenuItem onClick={() => setTheme("light")}>
          <Icons.sun className="mr-2 size-4" />
          <span>Light</span>
        </DropdownMenuItem>
        <DropdownMenuItem onClick={() => setTheme("dark")}>
          <Icons.moon className="mr-2 size-4" />
          <span>Dark</span>
        </DropdownMenuItem>
        <DropdownMenuItem onClick={() => setTheme("system")}>
          <Icons.laptop className="mr-2 size-4" />
          <span>System</span>
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}


================================================
FILE: src/components/new-recipe-dialog.tsx
================================================
"use client"

import * as React from "react"
import { useState } from "react"
import { DialogBody } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"
import { zodResolver } from "@hookform/resolvers/zod"
import {
  ScrapeRecipe,
  ScrapeRecipeSchema,
} from "~/server/api/modules/recipes/procedures/scrapeRecipeSchema"
import { api } from "~/trpc/react"
import { useForm } from "react-hook-form"

import { cn } from "~/lib/utils"
import { Button, ButtonProps, buttonVariants } from "~/components/ui/button"
import {
  Dialog,
  DialogContent,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "~/components/ui/dialog"
import {
  Form,
  FormControl,
  FormDescription,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "~/components/ui/form"
import { Input } from "~/components/ui/input"
import { Icons } from "~/components/icons"

interface NewRecipeDialogProps extends ButtonProps {}
export const NewRecipeDialog = ({
  className,
  variant,
  ...props
}: NewRecipeDialogProps) => {
  const [open, setOpen] = useState(false)

  const form = useForm<ScrapeRecipe>({
    resolver: zodResolver(ScrapeRecipeSchema),
  })

  const utils = api.useContext()

  const { mutate, isLoading } = api.recipe.scrape.useMutation({
    onSuccess: () => {
      utils.recipe.list.invalidate()
      setOpen(false)
    },
  })

  return (
    <Dialog open={open} onOpenChange={setOpen}>
      <DialogTrigger asChild>
        <button
          className={cn(
            buttonVariants({ variant }),
            {
              "cursor-not-allowed opacity-60": isLoading,
            },
            className
          )}
          disabled={isLoading}
          type="submit"
          {...props}
        >
          {isLoading ? (
            <Icons.spinner className="mr-2 size-4 animate-spin" />
          ) : (
            <Icons.add className="mr-2 size-4" />
          )}
          Add recipe
        </button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Add Recipe</DialogTitle>
        </DialogHeader>
        <DialogBody>
          <Form {...form}>
            <form id="addRecipe" onSubmit={form.handleSubmit((a) => mutate(a))}>
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Name</FormLabel>
                    <FormControl>
                      <Input autoComplete="off" {...field} />
                    </FormControl>
                    <FormDescription>
                      The URL of the recipe to scrape
                    </FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="url"
                control={form.control}
              />
            </form>
          </Form>
        </DialogBody>
        <DialogFooter>
          <Button disabled={isLoading} type="submit" form="addRecipe">
            Add
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  )
}


================================================
FILE: src/components/new-user-dialog.tsx
================================================
"use client"

import { useState } from "react"
import { DialogBody } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"
import { zodResolver } from "@hookform/resolvers/zod"
import {
  CreateUser,
  CreateUserSchema,
} from "~/server/api/modules/users/procedures/createUserSchema"
import { api } from "~/trpc/react"
import { useForm } from "react-hook-form"
import { toast } from "sonner"

import { Button } from "~/components/ui/button"
import {
  Dialog,
  DialogContent,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "~/components/ui/dialog"
import {
  Form,
  FormControl,
  FormDescription,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "~/components/ui/form"
import { Input } from "~/components/ui/input"

export const NewUserDialog = () => {
  const [open, setOpen] = useState(false)

  const form = useForm<CreateUser>({
    resolver: zodResolver(CreateUserSchema),
  })

  const utils = api.useContext()

  const { mutate, isLoading } = api.users.create.useMutation({
    onMutate: (variables) => {
      const prevData = utils.users.list.getData()
      utils.users.list.setData(undefined, (old) =>
        old
          ? [
              ...old,
              {
                name: variables.name,
                username: variables.username,
                id: 5000,
              },
            ]
          : [{ name: variables.name, username: variables.username, id: 5000 }]
      )

      return { prevData }
    },
    onError(_err, _newPost, ctx) {
      toast.error("Unable to create user")
      utils.users.list.setData(undefined, ctx?.prevData || [])
    },
    onSettled() {
      setOpen(false)
      utils.users.list.invalidate()
    },
  })

  return (
    <Dialog open={open} onOpenChange={setOpen}>
      <DialogTrigger asChild>
        <Button disabled={isLoading}>Add User</Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Add User</DialogTitle>
        </DialogHeader>
        <DialogBody>
          <Form {...form}>
            <form id="addUser" onSubmit={form.handleSubmit((a) => mutate(a))}>
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Name</FormLabel>
                    <FormControl>
                      <Input autoComplete="off" {...field} />
                    </FormControl>
                    <FormDescription>The user&apos;s full name</FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="name"
                control={form.control}
              />
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Username</FormLabel>
                    <FormControl>
                      <Input autoComplete="off" {...field} />
                    </FormControl>
                    <FormDescription>
                      The username that will be used to log in
                    </FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="username"
                control={form.control}
              />
              <FormField
                render={({ field }) => (
                  <FormItem>
                    <FormLabel>Password</FormLabel>
                    <FormControl>
                      <Input
                        type="password"
                        autoComplete="new-password"
                        {...field}
                      />
                    </FormControl>
                    <FormDescription>The user&apos;s password</FormDescription>
                    <FormMessage />
                  </FormItem>
                )}
                name="password"
                control={form.control}
              />
            </form>
          </Form>
        </DialogBody>
        <DialogFooter>
          <Button disabled={isLoading} type="submit" form="addUser">
            Add
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  )
}


================================================
FILE: src/components/recipe-card.tsx
================================================
import Link from "next/link"
import { Recipe } from "~/server/db/schema"

import { ROUTES } from "~/lib/routes"
import { Button } from "~/components/ui/button"
import {
  Card,
  CardFooter,
  CardHeader,
  CardImage,
  CardTitle,
} from "~/components/ui/card"
import { DeleteRecipeButton } from "~/components/delete-recipe-button"

type RecipeCardProps = {
  recipe: Pick<Recipe, "name" | "id" | "imageUrl">
}

export function RecipeCard({ recipe }: RecipeCardProps) {
  return (
    <Card>
      {recipe.imageUrl && (
        <CardImage
          src={recipe.imageUrl}
          alt={`An image of ${recipe.name}`}
          className="h-24 object-cover"
        />
      )}
      <CardHeader className="gap-2">
        <CardTitle className="text-xl">{recipe.name}</CardTitle>
      </CardHeader>
      <CardFooter className="justify-between">
        <DeleteRecipeButton recipeId={recipe.id} />
        <Link href={ROUTES.recipes.details(recipe.id)}>
          <Button>Add</Button>
        </Link>
      </CardFooter>
    </Card>
  )
}


================================================
FILE: src/components/recipe-title-input.tsx
================================================
"use client"

import { cn } from "~/lib/utils"
import { Input, InputProps } from "~/components/ui/input"

interface RecipeTitleInputProps extends InputProps {}

export function RecipeTitleInput({
  className,
  ...props
}: RecipeTitleInputProps) {
  return (
    <Input className={cn("py-6 text-3xl md:text-4xl", className)} {...props} />
  )
}


================================================
FILE: src/components/shell.tsx
================================================
import * as React from "react"

import { cn } from "~/lib/utils"

interface DashboardShellProps extends React.HTMLAttributes<HTMLDivElement> {}

export function DashboardShell({
  children,
  className,
  ...props
}: DashboardShellProps) {
  return (
    <div className={cn("grid items-start gap-8", className)} {...props}>
      {children}
    </div>
  )
}


================================================
FILE: src/components/sign-in-button.tsx
================================================
"use client"

import { signIn } from "next-auth/react"

import { Button } from "~/components/ui/button"

export const SignInButton = () => (
  <Button onClick={() => signIn()}>Sign in</Button>
)


================================================
FILE: src/components/site-footer.tsx
================================================
import * as React from "react"

import { siteConfig } from "~/config/site"
import { cn } from "~/lib/utils"
import { ModeToggle } from "~/components/mode-toggle"

import { Icons } from "./icons"

export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {
  return (
    <footer className={cn(className)}>
      <div className="container flex flex-col items-center justify-between gap-4 py-10 md:h-12 md:flex-row md:py-0">
        <div className="flex flex-col items-center gap-4 px-8 md:flex-row md:gap-2 md:px-0">
          <Icons.logo />
          <p className="text-center text-sm leading-loose md:text-left">
            Built by{" "}
            <a
              href={siteConfig.links.twitter}
              target="_blank"
              rel="noreferrer"
              className="font-medium underline underline-offset-4"
            >
              @georgegebbett
            </a>
            . The source code is available on{" "}
            <a
              href={siteConfig.links.github}
              target="_blank"
              rel="noreferrer"
              className="font-medium underline underline-offset-4"
            >
              GitHub
            </a>
            .
          </p>
        </div>
        <ModeToggle />
      </div>
    </footer>
  )
}


================================================
FILE: src/components/theme-provider.tsx
================================================
"use client"

import * as React from "react"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { ThemeProviderProps } from "next-themes/dist/types"

export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
  return <NextThemesProvider {...props}>{children}</NextThemesProvider>
}


================================================
FILE: src/components/ui/accordion.tsx
================================================
"use client"

import * as React from "react"
import * as AccordionPrimitive from "@radix-ui/react-accordion"
import { ChevronDown } from "lucide-react"

import { cn } from "~/lib/utils"

const Accordion = AccordionPrimitive.Root

const AccordionItem = React.forwardRef<
  React.ElementRef<typeof AccordionPrimitive.Item>,
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
  <AccordionPrimitive.Item
    ref={ref}
    className={cn("border-b", className)}
    {...props}
  />
))
AccordionItem.displayName = "AccordionItem"

const AccordionTrigger = React.forwardRef<
  React.ElementRef<typeof AccordionPrimitive.Trigger>,
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
  <AccordionPrimitive.Header className="flex">
    <AccordionPrimitive.Trigger
      ref={ref}
      className={cn(
        "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
        className
      )}
      {...props}
    >
      {children}
      <ChevronDown className="size-4 shrink-0 transition-transform duration-200" />
    </AccordionPrimitive.Trigger>
  </AccordionPrimitive.Header>
))
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName

const AccordionContent = React.forwardRef<
  React.ElementRef<typeof AccordionPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
>(({ className, children, ...props }, ref) => (
  <AccordionPrimitive.Content
    ref={ref}
    className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
    {...props}
  >
    <div className={cn("pb-4 pt-0", className)}>{children}</div>
  </AccordionPrimitive.Content>
))

AccordionContent.displayName = AccordionPrimitive.Content.displayName

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }


================================================
FILE: src/components/ui/alert.tsx
================================================
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "~/lib/utils"

const alertVariants = cva(
  "relative w-full rounded-lg border p-4 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
  {
    variants: {
      variant: {
        default: "bg-background text-foreground",
        destructive:
          "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
      },
    },
    defaultVariants: {
      variant: "default",
    },
  }
)

const Alert = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
>(({ className, variant, ...props }, ref) => (
  <div
    ref={ref}
    role="alert"
    className={cn(alertVariants({ variant }), className)}
    {...props}
  />
))
Alert.displayName = "Alert"

const AlertTitle = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
  <h5
    ref={ref}
    className={cn("mb-1 font-medium leading-none tracking-tight", className)}
    {...props}
  />
))
AlertTitle.displayName = "AlertTitle"

const AlertDescription = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("text-sm [&_p]:leading-relaxed", className)}
    {...props}
  />
))
AlertDescription.displayName = "AlertDescription"

export { Alert, AlertTitle, AlertDescription }


================================================
FILE: src/components/ui/avatar.tsx
================================================
"use client"

import * as React from "react"
import * as AvatarPrimitive from "@radix-ui/react-avatar"

import { cn } from "~/lib/utils"

const Avatar = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
  <AvatarPrimitive.Root
    ref={ref}
    className={cn(
      "relative flex size-10 shrink-0 overflow-hidden rounded-full",
      className
    )}
    {...props}
  />
))
Avatar.displayName = AvatarPrimitive.Root.displayName

const AvatarImage = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Image>,
  React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
  <AvatarPrimitive.Image
    ref={ref}
    className={cn("aspect-square size-full", className)}
    {...props}
  />
))
AvatarImage.displayName = AvatarPrimitive.Image.displayName

const AvatarFallback = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Fallback>,
  React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
  <AvatarPrimitive.Fallback
    ref={ref}
    className={cn(
      "flex size-full items-center justify-center rounded-full bg-muted",
      className
    )}
    {...props}
  />
))
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName

export { Avatar, AvatarImage, AvatarFallback }


================================================
FILE: src/components/ui/button.tsx
================================================
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { RefreshCw } from "lucide-react"

import { cn } from "~/lib/utils"

const buttonVariants = cva(
  "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground hover:bg-primary/90",
        destructive:
          "bg-destructive text-destructive-foreground hover:bg-destructive/90",
        outline:
          "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
        secondary:
          "bg-secondary text-secondary-foreground hover:bg-secondary/80",
        ghost: "hover:bg-accent hover:text-accent-foreground",
        link: "text-primary underline-offset-4 hover:underline",
      },
      size: {
        default: "h-10 px-4 py-2",
        sm: "h-9 rounded-md px-3",
        lg: "h-11 rounded-md px-8",
        icon: "size-10",
      },
    },
    defaultVariants: {
      variant: "default",
      size: "default",
    },
  }
)

export interface ButtonProps
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
    VariantProps<typeof buttonVariants> {
  asChild?: boolean
  isLoading?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
  (
    {
      className,
      variant,
      size,
      asChild = false,
      isLoading,
      children,
      disabled,
      type = "button",
      ...props
    },
    ref
  ) => {
    const Comp = asChild ? Slot : "button"
    return (
      <Comp
        className={cn(buttonVariants({ variant, size, className }))}
        ref={ref}
        disabled={disabled || isLoading}
        type={type}
        {...props}
      >
        {isLoading ? (
          <div className="flex items-center gap-2">
            <RefreshCw className="size-4 animate-spin" />
            {children}
          </div>
        ) : (
          children
        )}
      </Comp>
    )
  }
)
Button.displayName = "Button"

export { Button, buttonVariants }


================================================
FILE: src/components/ui/card.tsx
================================================
import * as React from "react"

import { cn } from "~/lib/utils"

const Card = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "rounded-lg border bg-card text-card-foreground shadow-sm",
      className
    )}
    {...props}
  />
))
Card.displayName = "Card"

const CardHeader = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("flex flex-col space-y-1.5 p-6", className)}
    {...props}
  />
))
CardHeader.displayName = "CardHeader"

const CardTitle = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
  <h3
    ref={ref}
    className={cn(
      "text-2xl font-semibold leading-none tracking-tight",
      className
    )}
    {...props}
  />
))
CardTitle.displayName = "CardTitle"

const CardDescription = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
  <p
    ref={ref}
    className={cn("text-sm text-muted-foreground", className)}
    {...props}
  />
))
CardDescription.displayName = "CardDescription"

const CardContent = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
))
CardContent.displayName = "CardContent"

const CardFooter = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("flex items-center p-6 pt-0", className)}
    {...props}
  />
))
CardFooter.displayName = "CardFooter"

const CardImage = React.forwardRef<
  HTMLImageElement,
  React.ImgHTMLAttributes<HTMLImageElement>
>(({ className, ...props }, ref) => (
  <img ref={ref} className={cn("h-auto w-full", className)} {...props} />
))
CardImage.displayName = "CardImage"

export {
  Card,
  CardHeader,
  CardFooter,
  CardTitle,
  CardDescription,
  CardContent,
  CardImage,
}


================================================
FILE: src/components/ui/command.tsx
================================================
"use client"

import * as React from "react"
import { type DialogProps } from "@radix-ui/react-dialog"
import { Command as CommandPrimitive } from "cmdk"
import { Search } from "lucide-react"

import { cn } from "~/lib/utils"
import { Dialog, DialogContent } from "~/components/ui/dialog"

const Command = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive>
>(({ className, ...props }, ref) => (
  <CommandPrimitive
    ref={ref}
    className={cn(
      "flex size-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
      className
    )}
    {...props}
  />
))
Command.displayName = CommandPrimitive.displayName

interface CommandDialogProps extends DialogProps {}

const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
  return (
    <Dialog {...props}>
      <DialogContent className="overflow-hidden p-0 shadow-lg">
        <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:size-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:size-5">
          {children}
        </Command>
      </DialogContent>
    </Dialog>
  )
}

const CommandInput = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.Input>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
  <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
    <Search className="mr-2 size-4 shrink-0 opacity-50" />
    <CommandPrimitive.Input
      ref={ref}
      className={cn(
        "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
        className
      )}
      {...props}
    />
  </div>
))

CommandInput.displayName = CommandPrimitive.Input.displayName

const CommandList = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.List>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
>(({ className, ...props }, ref) => (
  <CommandPrimitive.List
    ref={ref}
    className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
    {...props}
  />
))

CommandList.displayName = CommandPrimitive.List.displayName

const CommandEmpty = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.Empty>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
>((props, ref) => (
  <CommandPrimitive.Empty
    ref={ref}
    className="py-6 text-center text-sm"
    {...props}
  />
))

CommandEmpty.displayName = CommandPrimitive.Empty.displayName

const CommandGroup = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.Group>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
>(({ className, ...props }, ref) => (
  <CommandPrimitive.Group
    ref={ref}
    className={cn(
      "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
      className
    )}
    {...props}
  />
))

CommandGroup.displayName = CommandPrimitive.Group.displayName

const CommandSeparator = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.Separator>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
>(({ className, ...props }, ref) => (
  <CommandPrimitive.Separator
    ref={ref}
    className={cn("-mx-1 h-px bg-border", className)}
    {...props}
  />
))
CommandSeparator.displayName = CommandPrimitive.Separator.displayName

const CommandItem = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.Item>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
>(({ className, ...props }, ref) => (
  <CommandPrimitive.Item
    ref={ref}
    className={cn(
      "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",
      className
    )}
    {...props}
  />
))

CommandItem.displayName = CommandPrimitive.Item.displayName

const CommandShortcut = ({
  className,
  ...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
  return (
    <span
      className={cn(
        "ml-auto text-xs tracking-widest text-muted-foreground",
        className
      )}
      {...props}
    />
  )
}
CommandShortcut.displayName = "CommandShortcut"

export {
  Command,
  CommandDialog,
  CommandInput,
  CommandList,
  CommandEmpty,
  CommandGroup,
  CommandItem,
  CommandShortcut,
  CommandSeparator,
}


================================================
FILE: src/components/ui/dialog.tsx
================================================
"use client"

import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"

import { cn } from "~/lib/utils"

const Dialog = DialogPrimitive.Root

const DialogTrigger = DialogPrimitive.Trigger

const DialogPortal = DialogPrimitive.Portal

const DialogClose = DialogPrimitive.Close

const DialogOverlay = React.forwardRef<
  React.ElementRef<typeof DialogPrimitive.Overlay>,
  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
  <DialogPrimitive.Overlay
    ref={ref}
    className={cn(
      "fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
      className
    )}
    {...props}
  />
))
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName

const DialogContent = React.forwardRef<
  React.ElementRef<typeof DialogPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
  <DialogPortal>
    <DialogOverlay />
    <DialogPrimitive.Content
      ref={ref}
      className={cn(
        "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
        className
      )}
      {...props}
    >
      {children}
      <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
        <X className="size-4" />
        <span className="sr-only">Close</span>
      </DialogPrimitive.Close>
    </DialogPrimitive.Content>
  </DialogPortal>
))
DialogContent.displayName = DialogPrimitive.Content.displayName

const DialogHeader = ({
  className,
  ...props
}: React.HTMLAttributes<HTMLDivElement>) => (
  <div
    className={cn(
      "flex flex-col space-y-1.5 text-center sm:text-left",
      className
    )}
    {...props}
  />
)
DialogHeader.displayName = "DialogHeader"

const DialogFooter = ({
  className,
  ...props
}: React.HTMLAttributes<HTMLDivElement>) => (
  <div
    className={cn(
      "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
      className
    )}
    {...props}
  />
)
DialogFooter.displayName = "DialogFooter"

const DialogTitle = React.forwardRef<
  React.ElementRef<typeof DialogPrimitive.Title>,
  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
  <DialogPrimitive.Title
    ref={ref}
    className={cn(
      "text-lg font-semibold leading-none tracking-tight",
      className
    )}
    {...props}
  />
))
DialogTitle.displayName = DialogPrimitive.Title.displayName

const DialogDescription = React.forwardRef<
  React.ElementRef<typeof DialogPrimitive.Description>,
  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
  <DialogPrimitive.Description
    ref={ref}
    className={cn("text-sm text-muted-foreground", className)}
    {...props}
  />
))
DialogDescription.displayName = DialogPrimitive.Description.displayName

export {
  Dialog,
  DialogPortal,
  DialogOverlay,
  DialogClose,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogFooter,
  DialogTitle,
  DialogDescription,
}


================================================
FILE: src/components/ui/dropdown-menu.tsx
================================================
"use client"

import * as React from "react"
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
import { Check, ChevronRight, Circle } from "lucide-react"

import { cn } from "~/lib/utils"

const DropdownMenu = DropdownMenuPrimitive.Root

const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger

const DropdownMenuGroup = DropdownMenuPrimitive.Group

const DropdownMenuPortal = DropdownMenuPrimitive.Portal

const DropdownMenuSub = DropdownMenuPrimitive.Sub

const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup

const DropdownMenuSubTrigger = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
    inset?: boolean
  }
>(({ className, inset, children, ...props }, ref) => (
  <DropdownMenuPrimitive.SubTrigger
    ref={ref}
    className={cn(
      "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
      inset && "pl-8",
      className
    )}
    {...props}
  >
    {children}
    <ChevronRight className="ml-auto size-4" />
  </DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName =
  DropdownMenuPrimitive.SubTrigger.displayName

const DropdownMenuSubContent = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
>(({ className, ...props }, ref) => (
  <DropdownMenuPrimitive.SubContent
    ref={ref}
    className={cn(
      "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      className
    )}
    {...props}
  />
))
DropdownMenuSubContent.displayName =
  DropdownMenuPrimitive.SubContent.displayName

const DropdownMenuContent = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
  <DropdownMenuPrimitive.Portal>
    <DropdownMenuPrimitive.Content
      ref={ref}
      sideOffset={sideOffset}
      className={cn(
        "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
        className
      )}
      {...props}
    />
  </DropdownMenuPrimitive.Portal>
))
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName

const DropdownMenuItem = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.Item>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
    inset?: boolean
  }
>(({ className, inset, ...props }, ref) => (
  <DropdownMenuPrimitive.Item
    ref={ref}
    className={cn(
      "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      inset && "pl-8",
      className
    )}
    {...props}
  />
))
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName

const DropdownMenuCheckboxItem = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
>(({ className, children, checked, ...props }, ref) => (
  <DropdownMenuPrimitive.CheckboxItem
    ref={ref}
    className={cn(
      "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      className
    )}
    checked={checked}
    {...props}
  >
    <span className="absolute left-2 flex size-3.5 items-center justify-center">
      <DropdownMenuPrimitive.ItemIndicator>
        <Check className="size-4" />
      </DropdownMenuPrimitive.ItemIndicator>
    </span>
    {children}
  </DropdownMenuPrimitive.CheckboxItem>
))
DropdownMenuCheckboxItem.displayName =
  DropdownMenuPrimitive.CheckboxItem.displayName

const DropdownMenuRadioItem = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
>(({ className, children, ...props }, ref) => (
  <DropdownMenuPrimitive.RadioItem
    ref={ref}
    className={cn(
      "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      className
    )}
    {...props}
  >
    <span className="absolute left-2 flex size-3.5 items-center justify-center">
      <DropdownMenuPrimitive.ItemIndicator>
        <Circle className="size-2 fill-current" />
      </DropdownMenuPrimitive.ItemIndicator>
    </span>
    {children}
  </DropdownMenuPrimitive.RadioItem>
))
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName

const DropdownMenuLabel = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.Label>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
    inset?: boolean
  }
>(({ className, inset, ...props }, ref) => (
  <DropdownMenuPrimitive.Label
    ref={ref}
    className={cn(
      "px-2 py-1.5 text-sm font-semibold",
      inset && "pl-8",
      className
    )}
    {...props}
  />
))
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName

const DropdownMenuSeparator = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
>(({ className, ...props }, ref) => (
  <DropdownMenuPrimitive.Separator
    ref={ref}
    className={cn("-mx-1 my-1 h-px bg-muted", className)}
    {...props}
  />
))
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName

const DropdownMenuShortcut = ({
  className,
  ...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
  return (
    <span
      className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
      {...props}
    />
  )
}
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"

export {
  DropdownMenu,
  DropdownMenuTrigger,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuCheckboxItem,
  DropdownMenuRadioItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuShortcut,
  DropdownMenuGroup,
  DropdownMenuPortal,
  DropdownMenuSub,
  DropdownMenuSubContent,
  DropdownMenuSubTrigger,
  DropdownMenuRadioGroup,
}


================================================
FILE: src/components/ui/form.tsx
================================================
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { Slot } from "@radix-ui/react-slot"
import {
  Controller,
  ControllerProps,
  FieldPath,
  FieldValues,
  FormProvider,
  useFormContext,
} from "react-hook-form"

import { cn } from "~/lib/utils"
import { Label } from "~/components/ui/label"

const Form = FormProvider

type FormFieldContextValue<
  TFieldValues extends FieldValues = FieldValues,
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = {
  name: TName
}

const FormFieldContext = React.createContext<FormFieldContextValue>(
  {} as FormFieldContextValue
)

const FormField = <
  TFieldValues extends FieldValues = FieldValues,
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>({
  ...props
}: ControllerProps<TFieldValues, TName>) => {
  return (
    <FormFieldContext.Provider value={{ name: props.name }}>
      <Controller {...props} />
    </FormFieldContext.Provider>
  )
}

const useFormField = () => {
  const fieldContext = React.useContext(FormFieldContext)
  const itemContext = React.useContext(FormItemContext)
  const { getFieldState, formState } = useFormContext()

  const fieldState = getFieldState(fieldContext.name, formState)

  if (!fieldContext) {
    throw new Error("useFormField should be used within <FormField>")
  }

  const { id } = itemContext

  return {
    id,
    name: fieldContext.name,
    formItemId: `${id}-form-item`,
    formDescriptionId: `${id}-form-item-description`,
    formMessageId: `${id}-form-item-message`,
    ...fieldState,
  }
}

type FormItemContextValue = {
  id: string
}

const FormItemContext = React.createContext<FormItemContextValue>(
  {} as FormItemContextValue
)

const FormItem = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
  const id = React.useId()

  return (
    <FormItemContext.Provider value={{ id }}>
      <div ref={ref} className={cn("space-y-2", className)} {...props} />
    </FormItemContext.Provider>
  )
})
FormItem.displayName = "FormItem"

const FormLabel = React.forwardRef<
  React.ElementRef<typeof LabelPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
>(({ className, ...props }, ref) => {
  const { error, formItemId } = useFormField()

  return (
    <Label
      ref={ref}
      className={cn(error && "text-destructive", className)}
      htmlFor={formItemId}
      {...props}
    />
  )
})
FormLabel.displayName = "FormLabel"

const FormControl = React.forwardRef<
  React.ElementRef<typeof Slot>,
  React.ComponentPropsWithoutRef<typeof Slot>
>(({ ...props }, ref) => {
  const { error, formItemId, formDescriptionId, formMessageId } = useFormField()

  return (
    <Slot
      ref={ref}
      id={formItemId}
      aria-describedby={
        !error
          ? `${formDescriptionId}`
          : `${formDescriptionId} ${formMessageId}`
      }
      aria-invalid={!!error}
      {...props}
    />
  )
})
FormControl.displayName = "FormControl"

const FormDescription = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
  const { formDescriptionId } = useFormField()

  return (
    <p
      ref={ref}
      id={formDescriptionId}
      className={cn("text-sm text-muted-foreground", className)}
      {...props}
    />
  )
})
FormDescription.displayName = "FormDescription"

const FormMessage = React.forwardRef<
  HTMLParagraphElement,
  React.HTMLAttributes<HTMLParagraphElement>
>(({ className, children, ...props }, ref) => {
  const { error, formMessageId } = useFormField()
  const body = error ? String(error?.message) : children

  if (!body) {
    return null
  }

  return (
    <p
      ref={ref}
      id={formMessageId}
      className={cn("text-sm font-medium text-destructive", className)}
      {...props}
    >
      {body}
    </p>
  )
})
FormMessage.displayName = "FormMessage"

export {
  useFormField,
  Form,
  FormItem,
  FormLabel,
  FormControl,
  FormDescription,
  FormMessage,
  FormField,
}


================================================
FILE: src/components/ui/input.tsx
================================================
import * as React from "react"

import { cn } from "~/lib/utils"

export interface InputProps
  extends React.InputHTMLAttributes<HTMLInputElement> {}

const Input = React.forwardRef<HTMLInputElement, InputProps>(
  ({ className, type, ...props }, ref) => {
    return (
      <input
        type={type}
        className={cn(
          "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
          className
        )}
        ref={ref}
        {...props}
      />
    )
  }
)
Input.displayName = "Input"

export { Input }


================================================
FILE: src/components/ui/label.tsx
================================================
"use client"

import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "~/lib/utils"

const labelVariants = cva(
  "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)

const Label = React.forwardRef<
  React.ElementRef<typeof LabelPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
    VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
  <LabelPrimitive.Root
    ref={ref}
    className={cn(labelVariants(), className)}
    {...props}
  />
))
Label.displayName = LabelPrimitive.Root.displayName

export { Label }


================================================
FILE: src/components/ui/popover.tsx
================================================
"use client"

import * as React from "react"
import * as PopoverPrimitive from "@radix-ui/react-popover"

import { cn } from "~/lib/utils"

const Popover = PopoverPrimitive.Root

const PopoverTrigger = PopoverPrimitive.Trigger

const PopoverContent = React.forwardRef<
  React.ElementRef<typeof PopoverPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
  <PopoverPrimitive.Portal>
    <PopoverPrimitive.Content
      ref={ref}
      align={align}
      sideOffset={sideOffset}
      className={cn(
        "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
        className
      )}
      {...props}
    />
  </PopoverPrimitive.Portal>
))
PopoverContent.displayName = PopoverPrimitive.Content.displayName

export { Popover, PopoverTrigger, PopoverContent }


================================================
FILE: src/components/ui/scroll-area.tsx
================================================
"use client"

import * as React from "react"
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"

import { cn } from "~/lib/utils"

const ScrollArea = React.forwardRef<
  React.ElementRef<typeof ScrollAreaPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
>(({ className, children, ...props }, ref) => (
  <ScrollAreaPrimitive.Root
    ref={ref}
    className={cn("relative overflow-hidden", className)}
    {...props}
  >
    <ScrollAreaPrimitive.Viewport className="size-full rounded-[inherit]">
      {children}
    </ScrollAreaPrimitive.Viewport>
    <ScrollBar />
    <ScrollAreaPrimitive.Corner />
  </ScrollAreaPrimitive.Root>
))
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName

const ScrollBar = React.forwardRef<
  React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
  React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
>(({ className, orientation = "vertical", ...props }, ref) => (
  <ScrollAreaPrimitive.ScrollAreaScrollbar
    ref={ref}
    orientation={orientation}
    className={cn(
      "flex touch-none select-none transition-colors",
      orientation === "vertical" &&
        "h-full w-2.5 border-l border-l-transparent p-px",
      orientation === "horizontal" &&
        "h-2.5 flex-col border-t border-t-transparent p-px",
      className
    )}
    {...props}
  >
    <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
  </ScrollAreaPrimitive.ScrollAreaScrollbar>
))
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName

export { ScrollArea, ScrollBar }


================================================
FILE: src/components/ui/skeleton.tsx
================================================
import { cn } from "~/lib/utils"

function Skeleton({
  className,
  ...props
}: React.HTMLAttributes<HTMLDivElement>) {
  return (
    <div
      className={cn("animate-pulse rounded-md bg-muted", className)}
      {...props}
    />
  )
}

export { Skeleton }


================================================
FILE: src/components/ui/sonner.tsx
================================================
"use client"

import { useTheme } from "next-themes"
import { Toaster as Sonner } from "sonner"

type ToasterProps = React.ComponentProps<typeof Sonner>

const Toaster = ({ ...props }: ToasterProps) => {
  const { theme = "system" } = useTheme()

  return (
    <Sonner
      theme={theme as ToasterProps["theme"]}
      className="toaster group"
      toastOptions={{
        classNames: {
          toast:
            "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
          description: "group-[.toast]:text-muted-foreground",
          actionButton:
            "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
          cancelButton:
            "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
        },
      }}
      {...props}
    />
  )
}

export { Toaster }


================================================
FILE: src/components/ui/table.tsx
================================================
import * as React from "react"

import { cn } from "~/lib/utils"

const Table = React.forwardRef<
  HTMLTableElement,
  React.HTMLAttributes<HTMLTableElement>
>(({ className, ...props }, ref) => (
  <div className="relative w-full overflow-auto">
    <table
      ref={ref}
      className={cn("w-full caption-bottom text-sm", className)}
      {...props}
    />
  </div>
))
Table.displayName = "Table"

const TableHeader = React.forwardRef<
  HTMLTableSectionElement,
  React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
  <thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
))
TableHeader.displayName = "TableHeader"

const TableBody = React.forwardRef<
  HTMLTableSectionElement,
  React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
  <tbody
    ref={ref}
    className={cn("[&_tr:last-child]:border-0", className)}
    {...props}
  />
))
TableBody.displayName = "TableBody"

const TableFooter = React.forwardRef<
  HTMLTableSectionElement,
  React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
  <tfoot
    ref={ref}
    className={cn(
      "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
      className
    )}
    {...props}
  />
))
TableFooter.displayName = "TableFooter"

const TableRow = React.forwardRef<
  HTMLTableRowElement,
  React.HTMLAttributes<HTMLTableRowElement>
>(({ className, ...props }, ref) => (
  <tr
    ref={ref}
    className={cn(
      "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
      className
    )}
    {...props}
  />
))
TableRow.displayName = "TableRow"

const TableHead = React.forwardRef<
  HTMLTableCellElement,
  React.ThHTMLAttributes<HTMLTableCellElement>
>(({ className, ...props }, ref) => (
  <th
    ref={ref}
    className={cn(
      "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
      className
    )}
    {...props}
  />
))
TableHead.displayName = "TableHead"

const TableCell = React.forwardRef<
  HTMLTableCellElement,
  React.TdHTMLAttributes<HTMLTableCellElement>
>(({ className, ...props }, ref) => (
  <td
    ref={ref}
    className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
    {...props}
  />
))
TableCell.displayName = "TableCell"

const TableCaption = React.forwardRef<
  HTMLTableCaptionElement,
  React.HTMLAttributes<HTMLTableCaptionElement>
>(({ className, ...props }, ref) => (
  <caption
    ref={ref}
    className={cn("mt-4 text-sm text-muted-foreground", className)}
    {...props}
  />
))
TableCaption.displayName = "TableCaption"

export {
  Table,
  TableHeader,
  TableBody,
  TableFooter,
  TableHead,
  TableRow,
  TableCell,
  TableCaption,
}


================================================
FILE: src/components/ui/textarea.tsx
================================================
import * as React from "react"

import { cn } from "~/lib/utils"

export interface TextareaProps
  extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}

const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
  ({ className, ...props }, ref) => {
    return (
      <textarea
        className={cn(
          "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
          className
        )}
        ref={ref}
        {...props}
      />
    )
  }
)
Textarea.displayName = "Textarea"

export { Textarea }


================================================
FILE: src/components/user-account-nav.tsx
================================================
"use client"

import { User } from "next-auth"
import { signOut } from "next-auth/react"

import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu"

import { UserAvatar } from "./user-avatar"

interface UserAccountNavProps extends React.HTMLAttributes<HTMLDivElement> {
  user: Pick<User, "name" | "username">
}

export function UserAccountNav({ user }: UserAccountNavProps) {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger>
        <UserAvatar user={{ name: user.name }} className="size-8" />
      </DropdownMenuTrigger>
      <DropdownMenuContent align="end">
        <div className="flex items-center justify-start gap-2 p-2">
          <div className="flex flex-col space-y-1 leading-none">
            {user.name && <p className="font-medium">{user.name}</p>}
            {user.username && (
              <p className="w-[200px] truncate text-sm text-muted-foreground">
                {user.username}
              </p>
            )}
          </div>
        </div>
        <DropdownMenuSeparator />
        <DropdownMenuItem
          className="cursor-pointer"
          onSelect={(event: Event) => {
            event.preventDefault()
            signOut({
              callbackUrl: `${window.location.origin}/login`,
            })
          }}
        >
          Sign out
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}


================================================
FILE: src/components/user-avatar.tsx
================================================
import { AvatarProps } from "@radix-ui/react-avatar"
import { User } from "next-auth"

import { Icons } from "./icons"
import { Avatar, AvatarFallback } from "./ui/avatar"

interface UserAvatarProps extends AvatarProps {
  user: Pick<User, "name">
}

export function UserAvatar({ user, ...props }: UserAvatarProps) {
  return (
    <Avatar {...props}>
      <AvatarFallback>
        <span className="sr-only">{user.name}</span>
        <Icons.user className="size-4" />
      </AvatarFallback>
    </Avatar>
  )
}


================================================
FILE: src/components/user-table.tsx
================================================
"use client"

import { api } from "~/trpc/react"

import { Button } from "~/components/ui/button"
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "~/components/ui/table"
import { NewUserDialog } from "~/components/new-user-dialog"

export function UserTable() {
  const { data } = api.users.list.useQuery()

  return (
    <div className="flex flex-col">
      <div className="flex items-center justify-between">
        <p className="text-xl">Users</p>
        <NewUserDialog />
      </div>
      <Table>
        <TableHeader>
          <TableRow>
            <TableHead>ID</TableHead>
            <TableHead>Name</TableHead>
            <TableHead>Username</TableHead>
            <TableHead>Actions</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {data &&
            data.map((a) => (
              <TableRow key={a.id}>
                <TableCell>{a.id}</TableCell>
                <TableCell>{a.name}</TableCell>
                <TableCell>{a.username}</TableCell>
                <TableCell className="flex gap-2">
                  <Button>Edit</Button>
                  <Button>Delete</Button>
                </TableCell>
              </TableRow>
            ))}
        </TableBody>
      </Table>
    </div>
  )
}


================================================
FILE: src/config/dashboard.ts
================================================
import { DashboardConfig } from "~/types"

export const dashboardConfig: DashboardConfig = {
  mainNav: [
    {
      title: "Recipes",
      href: "/recipes",
    },
    {
      title: "Settings",
      href: "/settings",
    },
  ],
  sidebarNav: [
    {
      title: "Recipes",
      href: "/recipes",
      icon: "post",
    },
    {
      title: "Settings",
      href: "/settings",
      icon: "settings",
    },
  ],
}


================================================
FILE: src/config/site.ts
================================================
import { SiteConfig } from "~/types"

export const siteConfig: SiteConfig = {
  name: "Recipe Buddy",
  description: "A better way to import recipes to Grocy.1",
  url: "https://github.com/georgegebbett/recipe-buddy",
  ogImage: "https://tx.shadcn.com/og.jpg",
  links: {
    twitter: "https://twitter.com/georgegebbett",
    github: "https://github.com/georgegebbett/recipe-buddy",
  },
}


================================================
FILE: src/env.js
================================================
import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"

export const env = createEnv({
  /**
   * Specify your server-side environment variables schema here. This way you can ensure the app
   * isn't built with invalid env vars.
   */
  server: {
    DATABASE_URL: z.string(),
    NODE_ENV: z
      .enum(["development", "test", "production"])
      .default("development"),
    NEXTAUTH_SECRET:
      process.env.NODE_ENV === "production"
        ? z.string()
        : z.string().optional(),
    NEXTAUTH_URL: z.preprocess(
      // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL
      // Since NextAuth.js automatically uses the VERCEL_URL if present.
      (str) => process.env.VERCEL_URL ?? str,
      // VERCEL_URL doesn't include `https` so it cant be validated as a URL
      process.env.VERCEL ? z.string() : z.string().url()
    ),
    GROCY_BASE_URL: z.string(),
    GROCY_API_KEY: z.string(),
  },

  /**
   * Specify your client-side environment variables schema here. This way you can ensure the app
   * isn't built with invalid env vars. To expose them to the client, prefix them with
   * `NEXT_PUBLIC_`.
   */
  client: {
    // NEXT_PUBLIC_CLIENTVAR: z.string(),
  },

  /**
   * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
   * middlewares) or client-side so we need to destruct manually.
   */
  runtimeEnv: {
    DATABASE_URL: process.env.DATABASE_URL,
    NODE_ENV: process.env.NODE_ENV,
    NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
    NEXTAUTH_URL: process.env.NEXTAUTH_URL,
    GROCY_BASE_URL: process.env.GROCY_BASE_URL,
    GROCY_API_KEY: process.env.GROCY_API_KEY,
  },
  /**
   * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
   * useful for Docker builds.
   */
  skipValidation: !!process.env.SKIP_ENV_VALIDATION,
  /**
   * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
   * `SOME_VAR=''` will throw an error.
   */
  emptyStringAsUndefined: true,
})


================================================
FILE: src/hooks/use-lock-body.ts
================================================
import * as React from "react"

// @see https://usehooks.com/useLockBodyScroll.
export function useLockBody() {
  React.useLayoutEffect((): (() => void) => {
    const originalStyle: string = window.getComputedStyle(
      document.body
    ).overflow
    document.body.style.overflow = "hidden"
    return () => (document.body.style.overflow = originalStyle)
  }, [])
}


================================================
FILE: src/lib/logger.ts
================================================
import pino from "pino"

export const logger = pino()


================================================
FILE: src/lib/routes.ts
================================================
export const ROUTES = {
  recipes: {
    root: "/recipes",
    details: (id: number | string) => `/recipes/${id}`,
  },
  setup: "/setup",
}


================================================
FILE: src/lib/session.ts
================================================
import { authOptions } from "~/server/auth"
import { getServerSession } from "next-auth/next"

export async function getCurrentUser() {
  const session = await getServerSession(authOptions)

  return session?.user
}


================================================
FILE: src/lib/utils.ts
================================================
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}


================================================
FILE: src/server/api/modules/grocy/procedures/checkGrocyConnection.ts
================================================
import { grocyFetch } from "~/server/api/modules/grocy/service/client"
import { protectedProcedure } from "~/server/api/trpc"
import z from "zod"

const GrocyStatusSchema = z.object({
  grocy_version: z.object({
    Version: z.string(),
    ReleaseDate: z.string(),
  }),
})

export const checkGrocyConnectionProcedure = protectedProcedure.query(
  async () => {
    const res = await grocyFetch(`/system/info`)

    const body = await res.json()

    return GrocyStatusSchema.safeParse(body)
  }
)


================================================
FILE: src/server/api/modules/grocy/procedures/createRecipeInGrocy.ts
================================================
import {
  CreateRecipeInGrocyCommandSchema,
  UnignoredIngredient,
} from "~/server/api/modules/grocy/procedures/createRecipeInGrocySchema"
import { grocyFetch } from "~/server/api/modules/grocy/service/client"
import { getGrocyProducts } from "~/server/api/modules/grocy/service/getGrocyProducts"
import { deleteRecipe } from "~/server/api/modules/recipes/service/deleteRecipe"
import { protectedProcedure } from "~/server/api/trpc"
import normalizeUrl from "normalize-url"
import slugify from "slugify"
import { v4 } from "uuid"
import z from "zod"

import { logger } from "~/lib/logger"

export const createRecipeInGrocyProcedure = protectedProcedure
  .input(CreateRecipeInGrocyCommandSchema)
  .mutation(async ({ input }) => {
    let imageFilename: string | undefined = undefined

    const grocyProducts = await getGrocyProducts()

    if (input.imageUrl) {
      const normalised = normalizeUrl(input.imageUrl, {
        removeQueryParameters: true,
      })

      const split = normalised.split(".")
      const extension = split[split.length - 1]

      const image = await fetch(input.imageUrl)
      const blob = await image.blob()

      const slug = slugify(input.recipeName)

      const uuid = v4()
      const [beginningOfUuid] = uuid.split("-")

      imageFilename = slug + "-" + beginningOfUuid + "." + extension

      logger.info(
        { imageFilename, base64: btoa(imageFilename) },
        "Uploading image to Grocy"
      )

      await grocyFetch(`/files/recipepictures/${btoa(imageFilename)}`, {
        method: "PUT",
        body: blob,
        headers: { "Content-Type": "application/octet-stream" },
      })

      logger.info("Uploaded image to Grocy")
    }

    logger.info(input, "Creating recipe in Grocy")

    const recipeBody = {
      name: input.recipeName,
      description: input.method,
      picture_file_name: imageFilename,
      base_servings: input.servings,
    }

    const recipeResponse = await grocyFetch("/objects/recipes", {
      method: "POST",
      body: JSON.stringify(recipeBody),
      headers: { "Content-Type": "application/json" },
    })

    const recipeJson = await recipeResponse.json()

    logger.info(recipeJson, "Recipe created")

    const recipeId = z.coerce.string().parse(recipeJson.created_object_id)

    const filteredIngredients = input.ingredients.filter(
      (a): a is UnignoredIngredient => !a.ignored
    )

    for (const ingredient of filteredIngredients) {
      logger.info(ingredient, `Creating ingredient [${ingredient.scrapedName}]`)

      const grocyProduct = grocyProducts.find(
        (a) => a.id === ingredient.productId
      )

      if (!grocyProduct) continue

      const useAnyUnit: "1" | "0" =
        ingredient.unitId === grocyProduct.qu_id_stock ? "0" : "1"

      const body = {
        recipe_id: recipeId,
        product_id: ingredient.productId,
        amount: ingredient.amount,
        qu_id: ingredient.unitId,
        only_check_single_unit_in_stock: useAnyUnit,
        note: ingredient.note,
        ingredient_group: ingredient.group,
      }

      const ingredientResponse = await grocyFetch("/objects/recipes_pos", {
        method: "POST",
        body: JSON.stringify(body),
        headers: { "Content-Type": "application/json" },
      })

      const ingredientJson = await ingredientResponse.json()

      if (!ingredientResponse.ok) {
        throw new Error(ingredientJson.error_message ?? "An error occurred")
      }

      logger.info(ingredientJson, "Ingredient created")
    }

    logger.info("Recipe creation success, deleting recipe from Recipe Buddy")

    await deleteRecipe(input.recipeBuddyRecipeId)
  })


================================================
FILE: src/server/api/modules/grocy/procedures/createRecipeInGrocySchema.ts
================================================
import z from "zod"

const IgnoredIngredientSchema = z.object({
  scrapedName: z.string(),
  ignored: z.literal(true),
})

const UnignoredIngredientSchema = z.object({
  productId: z.string(),
  amount: z.coerce.number(),
  unitId: z.string(),
  scrapedName: z.string(),
  ignored: z.literal(false),
  note: z.string().trim().optional(),
  group: z.string().trim().optional(),
})

export type UnignoredIngredient = z.infer<typeof UnignoredIngredientSchema>

const IngredientSchema = z.union([
  UnignoredIngredientSchema,
  IgnoredIngredientSchema,
])

const numberLike = z.union([z.number(), z.string()])
const numberLikeToNumberAtLeastOne = numberLike
  .pipe(
    z.coerce
      .number()
      .int("Must be a whole number")
      .min(0, "Must be a positive number")
  )
  .transform((a) => {
    if (a < 1) return 1
    return a
  })

export const CreateRecipeInGrocyCommandSchema = z.object({
  recipeBuddyRecipeId: z.number(),
  recipeName: z.string().trim().min(1),
  ingredients: IngredientSchema.array(),
  method: z.string().optional(),
  imageUrl: z.string().url().optional(),
  servings: numberLikeToNumberAtLeastOne.optional(),
})

export type CreateRecipeInGrocyCommand = z.infer<
  typeof CreateRecipeInGrocyCommandSchema
>


================================================
FILE: src/server/api/modules/grocy/procedures/getGrocyProducts.ts
================================================
import { getGrocyProducts } from "~/server/api/modules/grocy/service/getGrocyProducts"
import { protectedProcedure } from "~/server/api/trpc"

export const getGrocyProductsProcedure =
  protectedProcedure.query(getGrocyProducts)


================================================
FILE: src/server/api/modules/grocy/procedures/getGrocyQuantityUnits.ts
================================================
import { grocyFetch } from "~/server/api/modules/grocy/service/client"
import { protectedProcedure } from "~/server/api/trpc"
import z from "zod"

const grocyQuantityUnitSchema = z.object({
  id: z.coerce.string(),
  name: z.string(),
})

export const getGrocyQuantityUnitsProcedure = protectedProcedure.query(
  async () => {
    const prods = await grocyFetch("/objects/quantity_units")

    const json = await prods.json()

    return grocyQuantityUnitSchema.array().parse(json)
  }
)


================================================
FILE: src/server/api/modules/grocy/service/client.ts
================================================
import { env } from "~/env"

const headers = {
  "GROCY-API-KEY": env.GROCY_API_KEY,
}

export const grocyFetch = (suffix: string, init?: RequestInit) =>
  fetch(`${env.GROCY_BASE_URL}/api${suffix}`, {
    ...init,
    headers: {
      ...init?.headers,
      ...headers,
    },
  })


================================================
FILE: src/server/api/modules/grocy/service/getGrocyProducts.ts
================================================
import { grocyFetch } from "~/server/api/modules/grocy/service/client"
import z from "zod"

const grocyProductSchema = z.object({
  id: z.coerce.string(),
  name: z.string(),
  qu_id_stock: z.coerce.string(),
})

type GrocyProduct = z.infer<typeof grocyProductSchema>

export const getGrocyProducts = async (): Promise<GrocyProduct[]> => {
  const prods = await grocyFetch("/objects/products", { cache: "no-cache" })

  const json = await prods.json()

  return grocyProductSchema.array().parse(json)
}


================================================
FILE: src/server/api/modules/recipes/procedures/deleteRecipe.ts
================================================
import { deleteRecipe } from "~/server/api/modules/recipes/service/deleteRecipe"
import { protectedProcedure } from "~/server/api/trpc"
import { z } from "zod"

export const deleteRecipeProcedure = protectedProcedure
  .input(
    z.object({
      recipeId: z.number(),
    })
  )
  .mutation(({ input }) => deleteRecipe(input.recipeId))


================================================
FILE: src/server/api/modules/recipes/procedures/getById.ts
================================================
import { protectedProcedure } from "~/server/api/trpc"
import { db } from "~/server/db"
import { recipes as recipeTable } from "~/server/db/schema"
import { eq } from "drizzle-orm"
import z from "zod"

export const getRecipeByIdProcedure = protectedProcedure
  .input(
    z.object({
      id: z.coerce.number().int(),
    })
  )
  .query(async ({ input }) =>
    db.query.recipes.findFirst({
      where: eq(recipeTable.id, input.id),
      with: { ingredients: true },
    })
  )


================================================
FILE: src/server/api/modules/recipes/procedures/listRecipes.ts
================================================
import { protectedProcedure } from "~/server/api/trpc"
import { db } from "~/server/db"
import { recipes as recipeTable } from "~/server/db/schema"
import z from "zod"

export const listRecipesProcedure = protectedProcedure
  .output(
    z
      .object({
        id: z.number(),
        name: z.string(),
        imageUrl: z.string().nullable(),
      })
      .array()
  )
  .query(async () => {
    return db
      .select({
        id: recipeTable.id,
        name: recipeTable.name,
        imageUrl: recipeTable.imageUrl,
      })
      .from(recipeTable)
  })


================================================
FILE: src/server/api/modules/recipes/procedures/scrapeRecipe.ts
================================================
import { hydrateRecipe } from "~/server/api/modules/recipes/service/scraper"
import { protectedProcedure } from "~/server/api/trpc"
import { db } from "~/server/db"
import { ingredients as ingredientsTable, recipes } from "~/server/db/schema"
import z from "zod"

import { logger } from "~/lib/logger"

export const scrapeRecipeProcedure = protectedProcedure
  .input(
    z.object({
      url: z.string().url(),
    })
  )
  .mutation(async ({ input }) => {
    const { url } = input

    const { recipe, ingredients } = await hydrateRecipe(url)

    const dbRecipe = await db.insert(recipes).values({
      ...recipe,
    })

    ingredients.map(
      async (a) =>
        await db.insert(ingredientsTable).values({
          scrapedName: a.scrapedName,
          recipeId: dbRecipe.lastInsertRowid.valueOf() as number,
        })
    )

    logger.info({ recipe, ingredients }, "Recipe added")

    return url
  })


================================================
FILE: src/server/api/modules/recipes/procedures/scrapeRecipeSchema.ts
================================================
import z from "zod"

export const ScrapeRecipeSchema = z.object({
  url: z.string().url({ message: "Please enter a valid URL" }),
})

export type ScrapeRecipe = z.infer<typeof ScrapeRecipeSchema>


================================================
FILE: src/server/api/modules/recipes/service/deleteRecipe.ts
================================================
import { db } from "~/server/db"
import { recipes } from "~/server/db/schema"
import { eq } from "drizzle-orm"

import { logger } from "~/lib/logger"

export const deleteRecipe = (recipeId: number) => {
  logger.info(`Deleting recipe with ID ${recipeId}`)

  return db.delete(recipes).where(eq(recipes.id, recipeId))
}


================================================
FILE: src/server/api/modules/recipes/service/schemas.ts
================================================
import z from "zod"

const StepSchema = z.object({
  text: z.string(),
})

const beautifyInstructions = (input: string): string => {
  const sections = input.split(/\n\n+/)

  const formattedSections = sections.map((section, index) => {
    const numberedSection = section.replace(/\n/g, "<br>")
    return `${index + 1}. ${numberedSection}`
  })

  return formattedSections.map((section) => `<p>${section}</p>`).join("")
}

export const StepsToStringSchema = z
  .union([z.array(StepSchema), z.string()])
  .transform((steps) => {
    if (typeof steps === "string") return beautifyInstructions(steps)
    return beautifyInstructions(steps.map((step) => step.text).join("\n\n"))
  })

const baseUrlSchema = z.union([z.string(), z.object({ url: z.string() })])
export const RecipeImageUrlSchema = z
  .union([baseUrlSchema, baseUrlSchema.array()])
  .transform((input): string | undefined => {
    const res = Array.isArray(input) ? input[0] : input

    if (!res || typeof res === "string") return res
    return res.url
  })

export const JsonLdRecipeSchema = z.object({
  "@type": z.union([z.string(), z.tuple([z.string()]).transform((a) => a[0])]),
})

export const ExtractNumberSchema = z.coerce.string().transform((val, ctx) => {
  const numberRegex = /\d+/g

  const regexResult = numberRegex.exec(val)

  if (!regexResult) {
    ctx.addIssue({
      message: "No numbers found in servings",
      code: "custom",
    })
    return z.NEVER
  }

  const [first] = regexResult

  return parseInt(first)
})


================================================
FILE: src/server/api/modules/recipes/service/scraper.ts
================================================
import { TRPCError } from "@trpc/server"
import {
  ExtractNumberSchema,
  JsonLdRecipeSchema,
  RecipeImageUrlSchema,
  StepsToStringSchema,
} from "~/server/api/modules/recipes/service/schemas"
import { InsertIngredient, InsertRecipe } from "~/server/db/schema"
import { JSDOM } from "jsdom"

import { logger } from "~/lib/logger"

async function getNodeListOfMetadataNodesFromUrl(url: string) {
  const dom = await JSDOM.fromURL(url)
  const nodeList: NodeList = dom.window.document.querySelectorAll(
    "script[type='application/ld+json']"
  )

  if (nodeList.length === 0) {
    throw new TRPCError({
      message: "The linked page contains no metadata",
      code: "INTERNAL_SERVER_ERROR",
    })
  }

  return nodeList
}

function jsonObjectIsRecipe(jsonObject: Record<string, unknown>): boolean {
  const parsed = JsonLdRecipeSchema.safeParse(jsonObject)

  if (parsed.success) {
    if (parsed.data["@type"].toLowerCase().includes("recipe")) return true
  }

  return false
}

function jsonObjectHasGraph(jsonObject: Record<string, unknown>): boolean {
  return Object.prototype.hasOwnProperty.call(jsonObject, "@graph")
}

function normalizeWhitespace(input: string): string {
  return input.replace(
    /[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,
    " "
  )
}

function escapeRealLineBreaksInString(input: string): string {
  return input.replace(/(["'])([\s\S]*?)\1/g, (match, quote, content) => {
    const escapedContent = content.replace(/\n/g, "\\n").replace(/\r/g, "\\r")
    return quote + escapedContent + quote
  })
}

function getSchemaRecipeFromNodeList(nodeList: NodeList) {
  for (const node of nodeList.values()) {
    const { textContent } = node

    if (!textContent) {
      logger.debug("No text content in node, trying next node")
      continue
    }

    // Preprocess the text to ensure that it can be parsed as JSON
    const textContentWithEscapedLinebreaks =
      escapeRealLineBreaksInString(textContent)
    const formattedTextContent = normalizeWhitespace(
      textContentWithEscapedLinebreaks
    )

    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    let parsedNodeContent: any

    try {
      parsedNodeContent = JSON.parse(formattedTextContent)
    } catch (e) {
      logger.error(
        { error: e, textContent },
        "Error in extracting JSON from node content"
      )
      continue
    }

    if (Array.isArray(parsedNodeContent)) {
      for (const metadataObject of parsedNodeContent) {
        if (jsonObjectIsRecipe(metadataObject)) {
          return metadataObject
        }
      }
    } else {
      if (jsonObjectIsRecipe(parsedNodeContent)) {
        return parsedNodeContent
      }
      if (jsonObjectHasGraph(parsedNodeContent)) {
        for (const graphNode of parsedNodeContent["@graph"]) {
          if (jsonObjectIsRecipe(graphNode)) {
            return graphNode
          }
        }
      }
    }
  }
  throw new Error("Unable to extract Recipe metadata from provided url")
}

export async function hydrateRecipe(url: string) {
  const nodeList: NodeList = await getNodeListOfMetadataNodesFromUrl(url)

  const recipeData = getSchemaRecipeFromNodeList(nodeList)

  const { error, data: steps } = StepsToStringSchema.safeParse(
    recipeData.recipeInstructions
  )

  if (error) {
    throw new Error("Unable to parse steps")
  }

  const ingredients: string[] = recipeData.recipeIngredient
    .flat()
    .map((ingredient: string) => ingredient.trim())

  const image = RecipeImageUrlSchema.safeParse(recipeData.image)

  const ings: Pick<InsertIngredient, "scrapedName">[] = ingredients.map(
    (a) => ({ scrapedName: a })
  )

  const servings = ExtractNumberSchema.safeParse(recipeData.recipeYield)

  const recipe: InsertRecipe = {
    name: recipeData.name,
    url,
    steps,
    imageUrl: image.success ? image.data : undefined,
    servings: servings.success ? servings.data : undefined,
  }

  return { recipe, ingredients: ings }
}


================================================
FILE: src/server/api/modules/users/procedures/checkIsSetup.ts
================================================
import { checkIsSetup } from "~/server/api/modules/users/service/checkIsSetup"
import { publicProcedure } from "~/server/api/trpc"

export const checkIsSetupProcedure = publicProcedure.query(checkIsSetup)


================================================
FILE: src/server/api/modules/users/procedures/createUser.ts
================================================
import { CreateUserSchema } from "~/server/api/modules/users/procedures/createUserSchema"
import { createUser } from "~/server/api/modules/users/service/createUser"
import { protectedProcedure } from "~/server/api/trpc"
import z from "zod"

export const createUserProcedure = protectedProcedure
  .input(CreateUserSchema)
  .output(
    z.object({
      id: z.number(),
      name: z.string(),
      username: z.string(),
    })
  )
  .mutation(async ({ input }) => {
    return createUser(input)
  })


================================================
FILE: src/server/api/modules/users/procedures/createUserSchema.ts
================================================
import z from "zod"

export const CreateUserSchema = z.object({
  name: z.string(),
  username: z.string(),
  password: z.string(),
})

export type CreateUser = z.infer<typeof CreateUserSchema>


================================================
FILE: src/server/api/modules/users/procedures/listUsers.ts
================================================
import { protectedProcedure } from "~/server/api/trpc"
import { db } from "~/server/db"
import { users as userTable } from "~/server/db/schema"
import z from "zod"

export const listUsersProcedure = protectedProcedure
  .output(
    z
      .object({
        id: z.number(),
        name: z.string(),
        username: z.string(),
      })
      .array()
  )
  .query(async () => {
    return db
      .select({
        id: userTable.id,
        name: userTable.name,
        username: userTable.username,
      })
      .from(userTable)
  })


================================================
FILE: src/server/api/modules/users/procedures/setupUser.ts
================================================
import { TRPCError } from "@trpc/server"
import { CreateUserSchema } from "~/server/api/modules/users/procedures/createUserSchema"
import { checkIsSetup } from "~/server/api/modules/users/service/checkIsSetup"
import { createUser } from "~/server/api/modules/users/service/createUser"
import { publicProcedure } from "~/server/api/trpc"

export const setupUserProcedure = publicProcedure
  .input(CreateUserSchema)
  .mutation(async ({ input }) => {
    const isSetup = await checkIsSetup()

    if (isSetup)
      throw new TRPCError({
        code: "FORBIDDEN",
        message: "Already set up",
      })

    // Otherwise, create a user
    return await createUser(input)
  })


================================================
FILE: src/server/api/modules/users/service/checkIsSetup.ts
================================================
import { db } from "~/server/db"
import { users } from "~/server/db/schema"
import { count } from "drizzle-orm"

import { logger } from "~/lib/logger"

export const checkIsSetup = async () => {
  logger.info("Checking if instance setup")

  const [numberOfUsers] = await db
    .select({ value: count(users.id) })
    .from(users)

  const isSetup = !numberOfUsers || (numberOfUsers && numberOfUsers.value > 0)

  logger.info({ isSetup })

  return isSetup
}


================================================
FILE: src/server/api/modules/users/service/createUser.ts
================================================
import { db } from "~/server/db"
import { users as userTable } from "~/server/db/schema"
import bcrypt from "bcrypt"

type CreateUserInput = {
  username: string
  name: string
  password: string
}
export const createUser = async (input: CreateUserInput) => {
  const hashed = await bcrypt.hash(input.password, 10)

  const insertedUser = await db.insert(userTable).values({
    ...input,
    passwordHash: hashed,
  })

  return {
    id: insertedUser.lastInsertRowid as number,
    ...input,
  }
}


================================================
FILE: src/server/api/root.ts
================================================
import { grocyRouter } from "~/server/api/routers/grocy"
import { recipeRouter } from "~/server/api/routers/recipe"
import { userRouter } from "~/server/api/routers/user"
import { createTRPCRouter } from "~/server/api/trpc"

/**
 * This is the primary router for your server.
 *
 * All routers added in /api/routers should be manually added here.
 */
export const appRouter = createTRPCRouter({
  recipe: recipeRouter,
  grocy: grocyRouter,
  users: userRouter,
})

// export type definition of API
export type AppRouter = typeof appRouter


================================================
FILE: src/server/api/routers/grocy.ts
================================================
import { checkGrocyConnectionProcedure } from "~/server/api/modules/grocy/procedures/checkGrocyConnection"
import { createRecipeInGrocyProcedure } from "~/server/api/modules/grocy/procedures/createRecipeInGrocy"
import { getGrocyProductsProcedure } from "~/server/api/modules/grocy/procedures/getGrocyProducts"
import { getGrocyQuantityUnitsProcedure } from "~/server/api/modules/grocy/procedures/getGrocyQuantityUnits"
import { createTRPCRouter } from "~/server/api/trpc"

export const grocyRouter = createTRPCRouter({
  checkConnection: checkGrocyConnectionProcedure,
  getProducts: getGrocyProductsProcedure,
  getQuantityUnits: getGrocyQuantityUnitsProcedure,
  createRecipe: createRecipeInGrocyProcedure,
})


================================================
FILE: src/server/api/routers/recipe.ts
================================================
import { deleteRecipeProcedure } from "~/server/api/modules/recipes/procedures/deleteRecipe"
import { getRecipeByIdProcedure } from "~/server/api/modules/recipes/procedures/getById"
import { listRecipesProcedure } from "~/server/api/modules/recipes/procedures/listRecipes"
import { scrapeRecipeProcedure } from "~/server/api/modules/recipes/procedures/scrapeRecipe"
import {
  createTRPCRouter,
  protectedProcedure,
  publicProcedure,
} from "~/server/api/trpc"
import { z } from "zod"

export const recipeRouter = createTRPCRouter({
  hello: publicProcedure
    .input(z.object({ text: z.string() }))
    .query(({ input }) => {
      return {
        greeting: `Hello ${input.text}`,
      }
    }),

  getSecretMessage: protectedProcedure.query(() => {
    return "you can now see this secret message!"
  }),
  scrape: scrapeRecipeProcedure,
  list: listRecipesProcedure,
  get: getRecipeByIdProcedure,
  delete: deleteRecipeProcedure,
})


================================================
FILE: src/server/api/routers/user.ts
================================================
import { checkIsSetupProcedure } from "~/server/api/modules/users/procedures/checkIsSetup"
import { createUserProcedure } from "~/server/api/modules/users/procedures/createUser"
import { listUsersProcedure } from "~/server/api/modules/users/procedures/listUsers"
import { setupUserProcedure } from "~/server/api/modules/users/procedures/setupUser"
import { createTRPCRouter } from "~/server/api/trpc"

export const userRouter = createTRPCRouter({
  list: listUsersProcedure,
  create: createUserProcedure,
  checkIsSetup: checkIsSetupProcedure,
  setupUser: setupUs
Download .txt
gitextract_33v7gf8m/

├── .dockerignore
├── .eslintrc.json
├── .github/
│   ├── actions/
│   │   ├── build-setup/
│   │   │   └── action.yml
│   │   ├── format/
│   │   │   └── action.yml
│   │   └── lint/
│   │       └── action.yml
│   └── workflows/
│       ├── ci.yml
│       ├── code-style.yml
│       └── release.yaml
├── .gitignore
├── .idea/
│   ├── .gitignore
│   ├── aws.xml
│   ├── codeStyles/
│   │   ├── Project.xml
│   │   └── codeStyleConfig.xml
│   ├── dataSources.xml
│   ├── git_toolbox_blame.xml
│   ├── git_toolbox_prj.xml
│   ├── inspectionProfiles/
│   │   └── Project_Default.xml
│   ├── jsLibraryMappings.xml
│   ├── misc.xml
│   ├── modules.xml
│   ├── prettier.xml
│   ├── recipe-buddy-v2.iml
│   ├── recipe-buddy.iml
│   ├── runConfigurations/
│   │   ├── Front_and_Back.xml
│   │   ├── Front_end_dev__back_end_docker.xml
│   │   └── recipe_buddy__Compose_Deployment.xml
│   ├── sqldialects.xml
│   └── vcs.xml
├── .prettierrc.cjs
├── Dockerfile
├── LICENSE
├── README.md
├── SECURITY.md
├── components.json
├── drizzle.config.ts
├── knip.json
├── next.config.js
├── package.json
├── postcss.config.cjs
├── scripts/
│   └── run.sh
├── src/
│   ├── app/
│   │   ├── (dashboard)/
│   │   │   ├── recipes/
│   │   │   │   ├── [id]/
│   │   │   │   │   ├── loading.tsx
│   │   │   │   │   ├── page.tsx
│   │   │   │   │   └── recipeForm.tsx
│   │   │   │   ├── layout.tsx
│   │   │   │   ├── loading.tsx
│   │   │   │   └── page.tsx
│   │   │   └── settings/
│   │   │       ├── layout.tsx
│   │   │       ├── loading.tsx
│   │   │       └── page.tsx
│   │   ├── (setup)/
│   │   │   └── setup/
│   │   │       └── page.tsx
│   │   ├── api/
│   │   │   ├── auth/
│   │   │   │   └── [...nextauth]/
│   │   │   │       └── route.ts
│   │   │   └── trpc/
│   │   │       └── [trpc]/
│   │   │           └── route.ts
│   │   ├── layout.tsx
│   │   └── page.tsx
│   ├── components/
│   │   ├── card-skeleton.tsx
│   │   ├── delete-recipe-button.tsx
│   │   ├── empty-placeholder.tsx
│   │   ├── grocy-product-combobox.tsx
│   │   ├── grocy-status.tsx
│   │   ├── grocy-unit-combobox.tsx
│   │   ├── header.tsx
│   │   ├── icons.tsx
│   │   ├── ingredient-group-combobox.tsx
│   │   ├── ingredient-note-dialog.tsx
│   │   ├── ingredient-table.tsx
│   │   ├── main-nav.tsx
│   │   ├── mobile-nav.tsx
│   │   ├── mode-toggle.tsx
│   │   ├── new-recipe-dialog.tsx
│   │   ├── new-user-dialog.tsx
│   │   ├── recipe-card.tsx
│   │   ├── recipe-title-input.tsx
│   │   ├── shell.tsx
│   │   ├── sign-in-button.tsx
│   │   ├── site-footer.tsx
│   │   ├── theme-provider.tsx
│   │   ├── ui/
│   │   │   ├── accordion.tsx
│   │   │   ├── alert.tsx
│   │   │   ├── avatar.tsx
│   │   │   ├── button.tsx
│   │   │   ├── card.tsx
│   │   │   ├── command.tsx
│   │   │   ├── dialog.tsx
│   │   │   ├── dropdown-menu.tsx
│   │   │   ├── form.tsx
│   │   │   ├── input.tsx
│   │   │   ├── label.tsx
│   │   │   ├── popover.tsx
│   │   │   ├── scroll-area.tsx
│   │   │   ├── skeleton.tsx
│   │   │   ├── sonner.tsx
│   │   │   ├── table.tsx
│   │   │   └── textarea.tsx
│   │   ├── user-account-nav.tsx
│   │   ├── user-avatar.tsx
│   │   └── user-table.tsx
│   ├── config/
│   │   ├── dashboard.ts
│   │   └── site.ts
│   ├── env.js
│   ├── hooks/
│   │   └── use-lock-body.ts
│   ├── lib/
│   │   ├── logger.ts
│   │   ├── routes.ts
│   │   ├── session.ts
│   │   └── utils.ts
│   ├── server/
│   │   ├── api/
│   │   │   ├── modules/
│   │   │   │   ├── grocy/
│   │   │   │   │   ├── procedures/
│   │   │   │   │   │   ├── checkGrocyConnection.ts
│   │   │   │   │   │   ├── createRecipeInGrocy.ts
│   │   │   │   │   │   ├── createRecipeInGrocySchema.ts
│   │   │   │   │   │   ├── getGrocyProducts.ts
│   │   │   │   │   │   └── getGrocyQuantityUnits.ts
│   │   │   │   │   └── service/
│   │   │   │   │       ├── client.ts
│   │   │   │   │       └── getGrocyProducts.ts
│   │   │   │   ├── recipes/
│   │   │   │   │   ├── procedures/
│   │   │   │   │   │   ├── deleteRecipe.ts
│   │   │   │   │   │   ├── getById.ts
│   │   │   │   │   │   ├── listRecipes.ts
│   │   │   │   │   │   ├── scrapeRecipe.ts
│   │   │   │   │   │   └── scrapeRecipeSchema.ts
│   │   │   │   │   └── service/
│   │   │   │   │       ├── deleteRecipe.ts
│   │   │   │   │       ├── schemas.ts
│   │   │   │   │       └── scraper.ts
│   │   │   │   └── users/
│   │   │   │       ├── procedures/
│   │   │   │       │   ├── checkIsSetup.ts
│   │   │   │       │   ├── createUser.ts
│   │   │   │       │   ├── createUserSchema.ts
│   │   │   │       │   ├── listUsers.ts
│   │   │   │       │   └── setupUser.ts
│   │   │   │       └── service/
│   │   │   │           ├── checkIsSetup.ts
│   │   │   │           └── createUser.ts
│   │   │   ├── root.ts
│   │   │   ├── routers/
│   │   │   │   ├── grocy.ts
│   │   │   │   ├── recipe.ts
│   │   │   │   └── user.ts
│   │   │   └── trpc.ts
│   │   ├── auth.ts
│   │   └── db/
│   │       ├── drizzle/
│   │       │   ├── 0000_rare_sauron.sql
│   │       │   ├── 0001_worthless_aqueduct.sql
│   │       │   └── meta/
│   │       │       ├── 0000_snapshot.json
│   │       │       ├── 0001_snapshot.json
│   │       │       └── _journal.json
│   │       ├── drizzle-migrate.mjs
│   │       ├── index.ts
│   │       ├── migrate.ts
│   │       ├── schema.ts
│   │       └── tsconfig.json
│   ├── styles/
│   │   └── globals.css
│   ├── trpc/
│   │   ├── react.tsx
│   │   ├── server.ts
│   │   └── shared.ts
│   └── types/
│       └── index.d.ts
├── tailwind.config.js
└── tsconfig.json
Download .txt
SYMBOL INDEX (108 symbols across 59 files)

FILE: src/app/(dashboard)/recipes/[id]/loading.tsx
  function DashboardLoading (line 4) | function DashboardLoading() {

FILE: src/app/(dashboard)/recipes/[id]/page.tsx
  function RecipePage (line 7) | async function RecipePage({

FILE: src/app/(dashboard)/recipes/[id]/recipeForm.tsx
  type RecipeFormProps (line 27) | type RecipeFormProps = {
  function RecipeForm (line 32) | function RecipeForm({ recipeId, grocyBaseUrl }: RecipeFormProps) {
  type RecipeWithIngredients (line 42) | type RecipeWithIngredients = RouterOutputs["recipe"]["get"]
  function RecipeFormInner (line 44) | function RecipeFormInner({

FILE: src/app/(dashboard)/recipes/layout.tsx
  function Layout (line 3) | function Layout({ children }: { children: ReactNode }) {

FILE: src/app/(dashboard)/recipes/loading.tsx
  function DashboardLoading (line 6) | function DashboardLoading() {

FILE: src/app/(dashboard)/recipes/page.tsx
  function DashboardPage (line 11) | function DashboardPage() {

FILE: src/app/(dashboard)/settings/layout.tsx
  function Layout (line 3) | function Layout({ children }: { children: ReactNode }) {

FILE: src/app/(dashboard)/settings/loading.tsx
  function DashboardSettingsLoading (line 5) | function DashboardSettingsLoading() {

FILE: src/app/(dashboard)/settings/page.tsx
  function SettingsPage (line 15) | async function SettingsPage() {

FILE: src/app/(setup)/setup/page.tsx
  function Page (line 33) | function Page() {

FILE: src/app/layout.tsx
  function RootLayout (line 29) | async function RootLayout({

FILE: src/app/page.tsx
  function Home (line 7) | async function Home() {

FILE: src/components/card-skeleton.tsx
  function CardSkeleton (line 4) | function CardSkeleton() {

FILE: src/components/delete-recipe-button.tsx
  type DeleteRecipeButtonProps (line 7) | type DeleteRecipeButtonProps = {
  function DeleteRecipeButton (line 11) | function DeleteRecipeButton({ recipeId }: DeleteRecipeButtonProps) {

FILE: src/components/empty-placeholder.tsx
  type EmptyPlaceholderProps (line 6) | interface EmptyPlaceholderProps extends React.HTMLAttributes<HTMLDivElem...
  function EmptyPlaceholder (line 8) | function EmptyPlaceholder({
  type EmptyPlaceholderIconProps (line 28) | interface EmptyPlaceholderIconProps
  type EmptyPlacholderTitleProps (line 51) | interface EmptyPlacholderTitleProps
  type EmptyPlacholderDescriptionProps (line 63) | interface EmptyPlacholderDescriptionProps

FILE: src/components/grocy-product-combobox.tsx
  type GrocyProductComboboxProps (line 23) | type GrocyProductComboboxProps = {
  function GrocyProductCombobox (line 31) | function GrocyProductCombobox({

FILE: src/components/grocy-unit-combobox.tsx
  function GrocyUnitCombobox (line 20) | function GrocyUnitCombobox({

FILE: src/components/header.tsx
  type DashboardHeaderProps (line 3) | interface DashboardHeaderProps {
  function DashboardHeader (line 10) | function DashboardHeader({

FILE: src/components/ingredient-group-combobox.tsx
  type IngredientGroupComboboxProps (line 21) | interface IngredientGroupComboboxProps extends InputProps {
  function IngredientGroupCombobox (line 27) | function IngredientGroupCombobox({

FILE: src/components/ingredient-note-dialog.tsx
  type IngredientNoteDialogProps (line 14) | interface IngredientNoteDialogProps extends TextareaProps {}
  function IngredientNoteDialog (line 16) | function IngredientNoteDialog({

FILE: src/components/ingredient-table.tsx
  type IngredientTableProps (line 31) | type IngredientTableProps = {
  function IngredientTable (line 35) | function IngredientTable({ grocyBaseUrl }: IngredientTableProps) {

FILE: src/components/main-nav.tsx
  type MainNavProps (line 14) | interface MainNavProps {
  function MainNav (line 19) | function MainNav({ items, children }: MainNavProps) {

FILE: src/components/mobile-nav.tsx
  type MobileNavProps (line 11) | interface MobileNavProps {
  function MobileNav (line 16) | function MobileNav({ items, children }: MobileNavProps) {

FILE: src/components/mode-toggle.tsx
  function ModeToggle (line 16) | function ModeToggle() {

FILE: src/components/new-recipe-dialog.tsx
  type NewRecipeDialogProps (line 36) | interface NewRecipeDialogProps extends ButtonProps {}

FILE: src/components/new-user-dialog.tsx
  method onError (line 61) | onError(_err, _newPost, ctx) {
  method onSettled (line 65) | onSettled() {

FILE: src/components/recipe-card.tsx
  type RecipeCardProps (line 15) | type RecipeCardProps = {
  function RecipeCard (line 19) | function RecipeCard({ recipe }: RecipeCardProps) {

FILE: src/components/recipe-title-input.tsx
  type RecipeTitleInputProps (line 6) | interface RecipeTitleInputProps extends InputProps {}
  function RecipeTitleInput (line 8) | function RecipeTitleInput({

FILE: src/components/shell.tsx
  type DashboardShellProps (line 5) | interface DashboardShellProps extends React.HTMLAttributes<HTMLDivElemen...
  function DashboardShell (line 7) | function DashboardShell({

FILE: src/components/site-footer.tsx
  function SiteFooter (line 9) | function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {

FILE: src/components/theme-provider.tsx
  function ThemeProvider (line 7) | function ThemeProvider({ children, ...props }: ThemeProviderProps) {

FILE: src/components/ui/button.tsx
  type ButtonProps (line 37) | interface ButtonProps

FILE: src/components/ui/command.tsx
  type CommandDialogProps (line 26) | interface CommandDialogProps extends DialogProps {}

FILE: src/components/ui/form.tsx
  type FormFieldContextValue (line 18) | type FormFieldContextValue<
  type FormItemContextValue (line 65) | type FormItemContextValue = {

FILE: src/components/ui/input.tsx
  type InputProps (line 5) | interface InputProps

FILE: src/components/ui/skeleton.tsx
  function Skeleton (line 3) | function Skeleton({

FILE: src/components/ui/sonner.tsx
  type ToasterProps (line 6) | type ToasterProps = React.ComponentProps<typeof Sonner>

FILE: src/components/ui/textarea.tsx
  type TextareaProps (line 5) | interface TextareaProps

FILE: src/components/user-account-nav.tsx
  type UserAccountNavProps (line 16) | interface UserAccountNavProps extends React.HTMLAttributes<HTMLDivElemen...
  function UserAccountNav (line 20) | function UserAccountNav({ user }: UserAccountNavProps) {

FILE: src/components/user-avatar.tsx
  type UserAvatarProps (line 7) | interface UserAvatarProps extends AvatarProps {
  function UserAvatar (line 11) | function UserAvatar({ user, ...props }: UserAvatarProps) {

FILE: src/components/user-table.tsx
  function UserTable (line 16) | function UserTable() {

FILE: src/hooks/use-lock-body.ts
  function useLockBody (line 4) | function useLockBody() {

FILE: src/lib/routes.ts
  constant ROUTES (line 1) | const ROUTES = {

FILE: src/lib/session.ts
  function getCurrentUser (line 4) | async function getCurrentUser() {

FILE: src/lib/utils.ts
  function cn (line 4) | function cn(...inputs: ClassValue[]) {

FILE: src/server/api/modules/grocy/procedures/createRecipeInGrocySchema.ts
  type UnignoredIngredient (line 18) | type UnignoredIngredient = z.infer<typeof UnignoredIngredientSchema>
  type CreateRecipeInGrocyCommand (line 47) | type CreateRecipeInGrocyCommand = z.infer<

FILE: src/server/api/modules/grocy/service/getGrocyProducts.ts
  type GrocyProduct (line 10) | type GrocyProduct = z.infer<typeof grocyProductSchema>

FILE: src/server/api/modules/recipes/procedures/scrapeRecipeSchema.ts
  type ScrapeRecipe (line 7) | type ScrapeRecipe = z.infer<typeof ScrapeRecipeSchema>

FILE: src/server/api/modules/recipes/service/scraper.ts
  function getNodeListOfMetadataNodesFromUrl (line 13) | async function getNodeListOfMetadataNodesFromUrl(url: string) {
  function jsonObjectIsRecipe (line 29) | function jsonObjectIsRecipe(jsonObject: Record<string, unknown>): boolean {
  function jsonObjectHasGraph (line 39) | function jsonObjectHasGraph(jsonObject: Record<string, unknown>): boolean {
  function normalizeWhitespace (line 43) | function normalizeWhitespace(input: string): string {
  function escapeRealLineBreaksInString (line 50) | function escapeRealLineBreaksInString(input: string): string {
  function getSchemaRecipeFromNodeList (line 57) | function getSchemaRecipeFromNodeList(nodeList: NodeList) {
  function hydrateRecipe (line 108) | async function hydrateRecipe(url: string) {

FILE: src/server/api/modules/users/procedures/createUserSchema.ts
  type CreateUser (line 9) | type CreateUser = z.infer<typeof CreateUserSchema>

FILE: src/server/api/modules/users/service/createUser.ts
  type CreateUserInput (line 5) | type CreateUserInput = {

FILE: src/server/api/root.ts
  type AppRouter (line 18) | type AppRouter = typeof appRouter

FILE: src/server/api/trpc.ts
  method errorFormatter (line 47) | errorFormatter({ shape, error }) {

FILE: src/server/auth.ts
  type Session (line 19) | interface Session {
  type User (line 23) | interface User {
  method authorize (line 43) | async authorize(credentials) {
  method jwt (line 72) | jwt({ token, user }) {

FILE: src/server/db/drizzle/0000_rare_sauron.sql
  type `recipe-buddy_ingredient` (line 1) | CREATE TABLE `recipe-buddy_ingredient` (
  type `recipe-buddy_recipe` (line 8) | CREATE TABLE `recipe-buddy_recipe` (
  type `recipe-buddy_user` (line 16) | CREATE TABLE `recipe-buddy_user` (
  type `recipe-buddy_user_username_unique` (line 23) | CREATE UNIQUE INDEX `recipe-buddy_user_username_unique` ON `recipe-buddy...
  type `username_idx` (line 24) | CREATE INDEX `username_idx` ON `recipe-buddy_user` (`name`)

FILE: src/server/db/schema.ts
  type Recipe (line 24) | type Recipe = InferSelectModel<typeof recipes>
  type InsertRecipe (line 25) | type InsertRecipe = InferInsertModel<typeof recipes>
  type Ingredient (line 42) | type Ingredient = InferSelectModel<typeof ingredients>
  type InsertIngredient (line 43) | type InsertIngredient = InferInsertModel<typeof ingredients>

FILE: src/trpc/react.tsx
  function TRPCReactProvider (line 19) | function TRPCReactProvider(props: {

FILE: src/trpc/shared.ts
  function getBaseUrl (line 7) | function getBaseUrl() {
  function getUrl (line 13) | function getUrl() {
  type RouterInputs (line 22) | type RouterInputs = inferRouterInputs<AppRouter>
  type RouterOutputs (line 29) | type RouterOutputs = inferRouterOutputs<AppRouter>

FILE: src/types/index.d.ts
  type NavItem (line 3) | type NavItem = {
  type MainNavItem (line 9) | type MainNavItem = NavItem
  type SidebarNavItem (line 11) | type SidebarNavItem = {
  type SiteConfig (line 27) | type SiteConfig = {
  type DocsConfig (line 38) | type DocsConfig = {
  type MarketingConfig (line 43) | type MarketingConfig = {
  type DashboardConfig (line 47) | type DashboardConfig = {
  type SubscriptionPlan (line 52) | type SubscriptionPlan = {
Condensed preview — 149 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (230K chars).
[
  {
    "path": ".dockerignore",
    "chars": 111,
    "preview": "Dockerfile\n.dockerignore\nnode_modules\nnpm-debug.log\nREADME.md\n.next\n.git\nknip.json\nsqlite.db\n.env\n.env.example\n"
  },
  {
    "path": ".eslintrc.json",
    "chars": 1009,
    "preview": "{\n  \"$schema\": \"https://json.schemastore.org/eslintrc\",\n  \"root\": true,\n  \"extends\": [\n    \"next/core-web-vitals\",\n    \""
  },
  {
    "path": ".github/actions/build-setup/action.yml",
    "chars": 402,
    "preview": "name: 'Prepare'\ndescription: 'Sets up the build for NodeJS and cache'\n\nruns:\n  using: \"composite\"\n  steps:\n    - uses: p"
  },
  {
    "path": ".github/actions/format/action.yml",
    "chars": 166,
    "preview": "name: 'Format'\ndescription: 'Ensures the repo matches Prettier rules'\nruns:\n  using: \"composite\"\n  steps:\n    - name: Fo"
  },
  {
    "path": ".github/actions/lint/action.yml",
    "chars": 143,
    "preview": "name: 'Lint'\ndescription: 'Lints the repository'\n\nruns:\n  using: \"composite\"\n  steps:\n    - name: Lint\n      shell: bash"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 615,
    "preview": "name: CI\n\non:\n  pull_request:\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true"
  },
  {
    "path": ".github/workflows/code-style.yml",
    "chars": 506,
    "preview": "name: Code Style Check\non:\n  workflow_call:\n\njobs:\n  lint:\n    runs-on: ubuntu-20.04\n    timeout-minutes: 5\n    steps:\n "
  },
  {
    "path": ".github/workflows/release.yaml",
    "chars": 1429,
    "preview": "name: Create and publish Docker image\n\non:\n  release:\n    types: [ published ]\n\nenv:\n  REGISTRY: ghcr.io\n\njobs:\n  build-"
  },
  {
    "path": ".gitignore",
    "chars": 602,
    "preview": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pn"
  },
  {
    "path": ".idea/.gitignore",
    "chars": 239,
    "preview": "# Default ignored files\n/shelf/\n/workspace.xml\n# Editor-based HTTP Client requests\n/httpRequests/\n# Datasource local sto"
  },
  {
    "path": ".idea/aws.xml",
    "chars": 479,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"accountSettings\">\n    <option name=\"acti"
  },
  {
    "path": ".idea/codeStyles/Project.xml",
    "chars": 2778,
    "preview": "<component name=\"ProjectCodeStyleConfiguration\">\n  <code_scheme name=\"Project\" version=\"173\">\n    <HTMLCodeStyleSettings"
  },
  {
    "path": ".idea/codeStyles/codeStyleConfig.xml",
    "chars": 142,
    "preview": "<component name=\"ProjectCodeStyleConfiguration\">\n  <state>\n    <option name=\"USE_PER_PROJECT_SETTINGS\" value=\"true\" />\n "
  },
  {
    "path": ".idea/dataSources.xml",
    "chars": 877,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"DataSourceManagerImpl\" format=\"xml\" mult"
  },
  {
    "path": ".idea/git_toolbox_blame.xml",
    "chars": 171,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"GitToolBoxBlameSettings\">\n    <option na"
  },
  {
    "path": ".idea/git_toolbox_prj.xml",
    "chars": 480,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"GitToolBoxProjectSettings\">\n    <option "
  },
  {
    "path": ".idea/inspectionProfiles/Project_Default.xml",
    "chars": 251,
    "preview": "<component name=\"InspectionProjectProfileManager\">\n  <profile version=\"1.0\">\n    <option name=\"myName\" value=\"Project De"
  },
  {
    "path": ".idea/jsLibraryMappings.xml",
    "chars": 187,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"JavaScriptLibraryMappings\">\n    <include"
  },
  {
    "path": ".idea/misc.xml",
    "chars": 178,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"MarkdownSettingsMigration\">\n    <option "
  },
  {
    "path": ".idea/modules.xml",
    "chars": 282,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n   "
  },
  {
    "path": ".idea/prettier.xml",
    "chars": 287,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"PrettierConfiguration\">\n    <option name"
  },
  {
    "path": ".idea/recipe-buddy-v2.iml",
    "chars": 535,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module type=\"WEB_MODULE\" version=\"4\">\n  <component name=\"NewModuleRootManager\">\n"
  },
  {
    "path": ".idea/recipe-buddy.iml",
    "chars": 458,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module type=\"WEB_MODULE\" version=\"4\">\n  <component name=\"NewModuleRootManager\">\n"
  },
  {
    "path": ".idea/runConfigurations/Front_and_Back.xml",
    "chars": 317,
    "preview": "<component name=\"ProjectRunConfigurationManager\">\n  <configuration default=\"false\" name=\"Front and Back\" type=\"CompoundR"
  },
  {
    "path": ".idea/runConfigurations/Front_end_dev__back_end_docker.xml",
    "chars": 357,
    "preview": "<component name=\"ProjectRunConfigurationManager\">\n  <configuration default=\"false\" name=\"Front end dev, back end docker\""
  },
  {
    "path": ".idea/runConfigurations/recipe_buddy__Compose_Deployment.xml",
    "chars": 478,
    "preview": "<component name=\"ProjectRunConfigurationManager\">\n  <configuration default=\"false\" name=\"recipe-buddy: Compose Deploymen"
  },
  {
    "path": ".idea/sqldialects.xml",
    "chars": 170,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"SqlDialectMappings\">\n    <file url=\"PROJ"
  },
  {
    "path": ".idea/vcs.xml",
    "chars": 167,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping dire"
  },
  {
    "path": ".prettierrc.cjs",
    "chars": 645,
    "preview": "/** @type {import('prettier').Config} */\nmodule.exports = {\n  endOfLine: 'lf',\n  semi: false,\n  singleQuote: false,\n  ta"
  },
  {
    "path": "Dockerfile",
    "chars": 2643,
    "preview": "FROM node:18-alpine AS base\n\n# mostly inspired from https://github.com/BretFisher/node-docker-good-defaults/blob/main/Do"
  },
  {
    "path": "LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 2755,
    "preview": "# Recipe Buddy\n\n[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direc"
  },
  {
    "path": "SECURITY.md",
    "chars": 345,
    "preview": "# Security Policy\n\n## Supported Versions\n\nUse this section to tell people about which versions of your project are\ncurre"
  },
  {
    "path": "components.json",
    "chars": 348,
    "preview": "{\n  \"$schema\": \"https://ui.shadcn.com/schema.json\",\n  \"style\": \"default\",\n  \"rsc\": true,\n  \"tsx\": true,\n  \"tailwind\": {\n"
  },
  {
    "path": "drizzle.config.ts",
    "chars": 299,
    "preview": "import { type Config } from \"drizzle-kit\"\n\nimport { env } from \"./src/env\"\n\nexport default {\n  schema: \"./src/server/db/"
  },
  {
    "path": "knip.json",
    "chars": 252,
    "preview": "{\n  \"$schema\": \"https://unpkg.com/knip@5/schema.json\",\n  \"entry\": [\n    \"src/server/db/drizzle-migrate.mjs\"\n  ],\n  \"igno"
  },
  {
    "path": "next.config.js",
    "chars": 268,
    "preview": "/**\n * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful\n * for Docker b"
  },
  {
    "path": "package.json",
    "chars": 3196,
    "preview": "{\n  \"name\": \"recipe-buddy\",\n  \"version\": \"2.0.8\",\n  \"private\": true,\n  \"type\": \"module\",\n  \"scripts\": {\n    \"build\": \"ne"
  },
  {
    "path": "postcss.config.cjs",
    "chars": 107,
    "preview": "const config = {\n  plugins: {\n    tailwindcss: {},\n    autoprefixer: {},\n  },\n};\n\nmodule.exports = config;\n"
  },
  {
    "path": "scripts/run.sh",
    "chars": 1122,
    "preview": "#!/bin/sh\n\n## Check if DATABASE_URL is not set\n#if [ -z \"$DATABASE_URL\" ]; then\n#    # Check if all required variables a"
  },
  {
    "path": "src/app/(dashboard)/recipes/[id]/loading.tsx",
    "chars": 488,
    "preview": "import { Skeleton } from \"~/components/ui/skeleton\"\nimport { DashboardShell } from \"~/components/shell\"\n\nexport default "
  },
  {
    "path": "src/app/(dashboard)/recipes/[id]/page.tsx",
    "chars": 527,
    "preview": "import { unstable_noStore as noStore } from \"next/dist/server/web/spec-extension/unstable-no-store\"\n\nimport { env } from"
  },
  {
    "path": "src/app/(dashboard)/recipes/[id]/recipeForm.tsx",
    "chars": 3586,
    "preview": "\"use client\"\n\nimport Link from \"next/link\"\nimport { useRouter } from \"next/navigation\"\nimport { zodResolver } from \"@hoo"
  },
  {
    "path": "src/app/(dashboard)/recipes/layout.tsx",
    "chars": 308,
    "preview": "import { ReactNode } from \"react\"\n\nexport default function Layout({ children }: { children: ReactNode }) {\n  return (\n  "
  },
  {
    "path": "src/app/(dashboard)/recipes/loading.tsx",
    "chars": 671,
    "preview": "import { CardSkeleton } from \"~/components/card-skeleton\"\nimport { DashboardHeader } from \"~/components/header\"\nimport {"
  },
  {
    "path": "src/app/(dashboard)/recipes/page.tsx",
    "chars": 1251,
    "preview": "\"use client\"\n\nimport { api } from \"~/trpc/react\"\n\nimport { EmptyPlaceholder } from \"~/components/empty-placeholder\"\nimpo"
  },
  {
    "path": "src/app/(dashboard)/settings/layout.tsx",
    "chars": 308,
    "preview": "import { ReactNode } from \"react\"\n\nexport default function Layout({ children }: { children: ReactNode }) {\n  return (\n  "
  },
  {
    "path": "src/app/(dashboard)/settings/loading.tsx",
    "chars": 463,
    "preview": "import { CardSkeleton } from \"~/components/card-skeleton\"\nimport { DashboardHeader } from \"~/components/header\"\nimport {"
  },
  {
    "path": "src/app/(dashboard)/settings/page.tsx",
    "chars": 814,
    "preview": "import { redirect } from \"next/navigation\"\nimport { authOptions } from \"~/server/auth\"\n\nimport { getCurrentUser } from \""
  },
  {
    "path": "src/app/(setup)/setup/page.tsx",
    "chars": 3496,
    "preview": "\"use client\"\n\nimport { useEffect } from \"react\"\nimport { useRouter } from \"next/navigation\"\nimport { zodResolver } from "
  },
  {
    "path": "src/app/api/auth/[...nextauth]/route.ts",
    "chars": 159,
    "preview": "import { authOptions } from \"~/server/auth\"\nimport NextAuth from \"next-auth\"\n\nconst handler = NextAuth(authOptions)\nexpo"
  },
  {
    "path": "src/app/api/trpc/[trpc]/route.ts",
    "chars": 994,
    "preview": "import { type NextRequest } from \"next/server\"\nimport { fetchRequestHandler } from \"@trpc/server/adapters/fetch\"\nimport "
  },
  {
    "path": "src/app/layout.tsx",
    "chars": 2408,
    "preview": "import \"~/styles/globals.css\"\n\nimport { Inter } from \"next/font/google\"\nimport { cookies } from \"next/headers\"\nimport { "
  },
  {
    "path": "src/app/page.tsx",
    "chars": 451,
    "preview": "import { redirect } from \"next/navigation\"\nimport { checkIsSetup } from \"~/server/api/modules/users/service/checkIsSetup"
  },
  {
    "path": "src/components/card-skeleton.tsx",
    "chars": 475,
    "preview": "import { Card, CardContent, CardFooter, CardHeader } from \"~/components/ui/card\"\nimport { Skeleton } from \"~/components/"
  },
  {
    "path": "src/components/delete-recipe-button.tsx",
    "chars": 569,
    "preview": "\"use client\"\n\nimport { api } from \"~/trpc/react\"\n\nimport { Button } from \"~/components/ui/button\"\n\ntype DeleteRecipeButt"
  },
  {
    "path": "src/components/empty-placeholder.tsx",
    "chars": 1858,
    "preview": "import * as React from \"react\"\n\nimport { cn } from \"~/lib/utils\"\nimport { Icons } from \"~/components/icons\"\n\ninterface E"
  },
  {
    "path": "src/components/grocy-product-combobox.tsx",
    "chars": 3648,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { api } from \"~/trpc/react\"\nimport { ChevronsUpDown, PlusCircleIcon "
  },
  {
    "path": "src/components/grocy-status.tsx",
    "chars": 1203,
    "preview": "\"use client\"\n\nimport { api } from \"~/trpc/react\"\nimport { CheckCircle } from \"lucide-react\"\n\nimport { Alert, AlertDescri"
  },
  {
    "path": "src/components/grocy-unit-combobox.tsx",
    "chars": 2061,
    "preview": "import * as React from \"react\"\nimport { api } from \"~/trpc/react\"\nimport { ChevronsUpDown } from \"lucide-react\"\n\nimport "
  },
  {
    "path": "src/components/header.tsx",
    "chars": 577,
    "preview": "import { cn } from \"~/lib/utils\"\n\ninterface DashboardHeaderProps {\n  heading: string\n  text?: string\n  children?: React."
  },
  {
    "path": "src/components/icons.tsx",
    "chars": 2437,
    "preview": "import {\n  AlertTriangle,\n  ArrowRight,\n  Check,\n  ChevronLeft,\n  ChevronRight,\n  CookingPot,\n  CreditCard,\n  File,\n  Fi"
  },
  {
    "path": "src/components/ingredient-group-combobox.tsx",
    "chars": 2937,
    "preview": "import * as React from \"react\"\nimport { useState } from \"react\"\nimport { ChevronsUpDown, PlusCircleIcon } from \"lucide-r"
  },
  {
    "path": "src/components/ingredient-note-dialog.tsx",
    "chars": 982,
    "preview": "import { useState } from \"react\"\nimport { DialogBody } from \"next/dist/client/components/react-dev-overlay/internal/comp"
  },
  {
    "path": "src/components/ingredient-table.tsx",
    "chars": 5912,
    "preview": "\"use client\"\n\nimport { useState } from \"react\"\nimport { CreateRecipeInGrocyCommand } from \"~/server/api/modules/grocy/pr"
  },
  {
    "path": "src/components/main-nav.tsx",
    "chars": 1903,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport Link from \"next/link\"\nimport { useSelectedLayoutSegment } from \"next"
  },
  {
    "path": "src/components/mobile-nav.tsx",
    "chars": 1473,
    "preview": "import * as React from \"react\"\nimport Link from \"next/link\"\nimport { MainNavItem } from \"~/types\"\n\nimport { siteConfig }"
  },
  {
    "path": "src/components/mode-toggle.tsx",
    "chars": 1403,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { useTheme } from \"next-themes\"\n\nimport { Button } from \"~/component"
  },
  {
    "path": "src/components/new-recipe-dialog.tsx",
    "chars": 3061,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { useState } from \"react\"\nimport { DialogBody } from \"next/dist/clie"
  },
  {
    "path": "src/components/new-user-dialog.tsx",
    "chars": 4168,
    "preview": "\"use client\"\n\nimport { useState } from \"react\"\nimport { DialogBody } from \"next/dist/client/components/react-dev-overlay"
  },
  {
    "path": "src/components/recipe-card.tsx",
    "chars": 1038,
    "preview": "import Link from \"next/link\"\nimport { Recipe } from \"~/server/db/schema\"\n\nimport { ROUTES } from \"~/lib/routes\"\nimport {"
  },
  {
    "path": "src/components/recipe-title-input.tsx",
    "chars": 345,
    "preview": "\"use client\"\n\nimport { cn } from \"~/lib/utils\"\nimport { Input, InputProps } from \"~/components/ui/input\"\n\ninterface Reci"
  },
  {
    "path": "src/components/shell.tsx",
    "chars": 358,
    "preview": "import * as React from \"react\"\n\nimport { cn } from \"~/lib/utils\"\n\ninterface DashboardShellProps extends React.HTMLAttrib"
  },
  {
    "path": "src/components/sign-in-button.tsx",
    "chars": 195,
    "preview": "\"use client\"\n\nimport { signIn } from \"next-auth/react\"\n\nimport { Button } from \"~/components/ui/button\"\n\nexport const Si"
  },
  {
    "path": "src/components/site-footer.tsx",
    "chars": 1299,
    "preview": "import * as React from \"react\"\n\nimport { siteConfig } from \"~/config/site\"\nimport { cn } from \"~/lib/utils\"\nimport { Mod"
  },
  {
    "path": "src/components/theme-provider.tsx",
    "chars": 322,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider as NextThemesProvider } from \"next-themes\"\nimport { "
  },
  {
    "path": "src/components/ui/accordion.tsx",
    "chars": 1990,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { Ch"
  },
  {
    "path": "src/components/ui/alert.tsx",
    "chars": 1584,
    "preview": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"~/"
  },
  {
    "path": "src/components/ui/avatar.tsx",
    "chars": 1409,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AvatarPrimitive from \"@radix-ui/react-avatar\"\n\nimport { cn } fr"
  },
  {
    "path": "src/components/ui/button.tsx",
    "chars": 2305,
    "preview": "import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { cva, type VariantProps } from \"class"
  },
  {
    "path": "src/components/ui/card.tsx",
    "chars": 2155,
    "preview": "import * as React from \"react\"\n\nimport { cn } from \"~/lib/utils\"\n\nconst Card = React.forwardRef<\n  HTMLDivElement,\n  Rea"
  },
  {
    "path": "src/components/ui/command.tsx",
    "chars": 4821,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { type DialogProps } from \"@radix-ui/react-dialog\"\nimport { Command "
  },
  {
    "path": "src/components/ui/dialog.tsx",
    "chars": 3848,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\"\nimport { X } from"
  },
  {
    "path": "src/components/ui/dropdown-menu.tsx",
    "chars": 7292,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\"\nimpo"
  },
  {
    "path": "src/components/ui/form.tsx",
    "chars": 4087,
    "preview": "import * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/r"
  },
  {
    "path": "src/components/ui/input.tsx",
    "chars": 824,
    "preview": "import * as React from \"react\"\n\nimport { cn } from \"~/lib/utils\"\n\nexport interface InputProps\n  extends React.InputHTMLA"
  },
  {
    "path": "src/components/ui/label.tsx",
    "chars": 724,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { cva, type "
  },
  {
    "path": "src/components/ui/popover.tsx",
    "chars": 1244,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\"\n\nimport { cn } "
  },
  {
    "path": "src/components/ui/scroll-area.tsx",
    "chars": 1646,
    "preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\"\n\nimport "
  },
  {
    "path": "src/components/ui/skeleton.tsx",
    "chars": 261,
    "preview": "import { cn } from \"~/lib/utils\"\n\nfunction Skeleton({\n  className,\n  ...props\n}: React.HTMLAttributes<HTMLDivElement>) {"
  },
  {
    "path": "src/components/ui/sonner.tsx",
    "chars": 894,
    "preview": "\"use client\"\n\nimport { useTheme } from \"next-themes\"\nimport { Toaster as Sonner } from \"sonner\"\n\ntype ToasterProps = Rea"
  },
  {
    "path": "src/components/ui/table.tsx",
    "chars": 2765,
    "preview": "import * as React from \"react\"\n\nimport { cn } from \"~/lib/utils\"\n\nconst Table = React.forwardRef<\n  HTMLTableElement,\n  "
  },
  {
    "path": "src/components/ui/textarea.tsx",
    "chars": 772,
    "preview": "import * as React from \"react\"\n\nimport { cn } from \"~/lib/utils\"\n\nexport interface TextareaProps\n  extends React.Textare"
  },
  {
    "path": "src/components/user-account-nav.tsx",
    "chars": 1478,
    "preview": "\"use client\"\n\nimport { User } from \"next-auth\"\nimport { signOut } from \"next-auth/react\"\n\nimport {\n  DropdownMenu,\n  Dro"
  },
  {
    "path": "src/components/user-avatar.tsx",
    "chars": 514,
    "preview": "import { AvatarProps } from \"@radix-ui/react-avatar\"\nimport { User } from \"next-auth\"\n\nimport { Icons } from \"./icons\"\ni"
  },
  {
    "path": "src/components/user-table.tsx",
    "chars": 1311,
    "preview": "\"use client\"\n\nimport { api } from \"~/trpc/react\"\n\nimport { Button } from \"~/components/ui/button\"\nimport {\n  Table,\n  Ta"
  },
  {
    "path": "src/config/dashboard.ts",
    "chars": 426,
    "preview": "import { DashboardConfig } from \"~/types\"\n\nexport const dashboardConfig: DashboardConfig = {\n  mainNav: [\n    {\n      ti"
  },
  {
    "path": "src/config/site.ts",
    "chars": 390,
    "preview": "import { SiteConfig } from \"~/types\"\n\nexport const siteConfig: SiteConfig = {\n  name: \"Recipe Buddy\",\n  description: \"A "
  },
  {
    "path": "src/env.js",
    "chars": 2055,
    "preview": "import { createEnv } from \"@t3-oss/env-nextjs\"\nimport { z } from \"zod\"\n\nexport const env = createEnv({\n  /**\n   * Specif"
  },
  {
    "path": "src/hooks/use-lock-body.ts",
    "chars": 371,
    "preview": "import * as React from \"react\"\n\n// @see https://usehooks.com/useLockBodyScroll.\nexport function useLockBody() {\n  React."
  },
  {
    "path": "src/lib/logger.ts",
    "chars": 54,
    "preview": "import pino from \"pino\"\n\nexport const logger = pino()\n"
  },
  {
    "path": "src/lib/routes.ts",
    "chars": 141,
    "preview": "export const ROUTES = {\n  recipes: {\n    root: \"/recipes\",\n    details: (id: number | string) => `/recipes/${id}`,\n  },\n"
  },
  {
    "path": "src/lib/session.ts",
    "chars": 216,
    "preview": "import { authOptions } from \"~/server/auth\"\nimport { getServerSession } from \"next-auth/next\"\n\nexport async function get"
  },
  {
    "path": "src/lib/utils.ts",
    "chars": 166,
    "preview": "import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: Cla"
  },
  {
    "path": "src/server/api/modules/grocy/procedures/checkGrocyConnection.ts",
    "chars": 499,
    "preview": "import { grocyFetch } from \"~/server/api/modules/grocy/service/client\"\nimport { protectedProcedure } from \"~/server/api/"
  },
  {
    "path": "src/server/api/modules/grocy/procedures/createRecipeInGrocy.ts",
    "chars": 3659,
    "preview": "import {\n  CreateRecipeInGrocyCommandSchema,\n  UnignoredIngredient,\n} from \"~/server/api/modules/grocy/procedures/create"
  },
  {
    "path": "src/server/api/modules/grocy/procedures/createRecipeInGrocySchema.ts",
    "chars": 1241,
    "preview": "import z from \"zod\"\n\nconst IgnoredIngredientSchema = z.object({\n  scrapedName: z.string(),\n  ignored: z.literal(true),\n}"
  },
  {
    "path": "src/server/api/modules/grocy/procedures/getGrocyProducts.ts",
    "chars": 229,
    "preview": "import { getGrocyProducts } from \"~/server/api/modules/grocy/service/getGrocyProducts\"\nimport { protectedProcedure } fro"
  },
  {
    "path": "src/server/api/modules/grocy/procedures/getGrocyQuantityUnits.ts",
    "chars": 488,
    "preview": "import { grocyFetch } from \"~/server/api/modules/grocy/service/client\"\nimport { protectedProcedure } from \"~/server/api/"
  },
  {
    "path": "src/server/api/modules/grocy/service/client.ts",
    "chars": 284,
    "preview": "import { env } from \"~/env\"\n\nconst headers = {\n  \"GROCY-API-KEY\": env.GROCY_API_KEY,\n}\n\nexport const grocyFetch = (suffi"
  },
  {
    "path": "src/server/api/modules/grocy/service/getGrocyProducts.ts",
    "chars": 503,
    "preview": "import { grocyFetch } from \"~/server/api/modules/grocy/service/client\"\nimport z from \"zod\"\n\nconst grocyProductSchema = z"
  },
  {
    "path": "src/server/api/modules/recipes/procedures/deleteRecipe.ts",
    "chars": 338,
    "preview": "import { deleteRecipe } from \"~/server/api/modules/recipes/service/deleteRecipe\"\nimport { protectedProcedure } from \"~/s"
  },
  {
    "path": "src/server/api/modules/recipes/procedures/getById.ts",
    "chars": 482,
    "preview": "import { protectedProcedure } from \"~/server/api/trpc\"\nimport { db } from \"~/server/db\"\nimport { recipes as recipeTable "
  },
  {
    "path": "src/server/api/modules/recipes/procedures/listRecipes.ts",
    "chars": 568,
    "preview": "import { protectedProcedure } from \"~/server/api/trpc\"\nimport { db } from \"~/server/db\"\nimport { recipes as recipeTable "
  },
  {
    "path": "src/server/api/modules/recipes/procedures/scrapeRecipe.ts",
    "chars": 919,
    "preview": "import { hydrateRecipe } from \"~/server/api/modules/recipes/service/scraper\"\nimport { protectedProcedure } from \"~/serve"
  },
  {
    "path": "src/server/api/modules/recipes/procedures/scrapeRecipeSchema.ts",
    "chars": 196,
    "preview": "import z from \"zod\"\n\nexport const ScrapeRecipeSchema = z.object({\n  url: z.string().url({ message: \"Please enter a valid"
  },
  {
    "path": "src/server/api/modules/recipes/service/deleteRecipe.ts",
    "chars": 319,
    "preview": "import { db } from \"~/server/db\"\nimport { recipes } from \"~/server/db/schema\"\nimport { eq } from \"drizzle-orm\"\n\nimport {"
  },
  {
    "path": "src/server/api/modules/recipes/service/schemas.ts",
    "chars": 1510,
    "preview": "import z from \"zod\"\n\nconst StepSchema = z.object({\n  text: z.string(),\n})\n\nconst beautifyInstructions = (input: string):"
  },
  {
    "path": "src/server/api/modules/recipes/service/scraper.ts",
    "chars": 3977,
    "preview": "import { TRPCError } from \"@trpc/server\"\nimport {\n  ExtractNumberSchema,\n  JsonLdRecipeSchema,\n  RecipeImageUrlSchema,\n "
  },
  {
    "path": "src/server/api/modules/users/procedures/checkIsSetup.ts",
    "chars": 205,
    "preview": "import { checkIsSetup } from \"~/server/api/modules/users/service/checkIsSetup\"\nimport { publicProcedure } from \"~/server"
  },
  {
    "path": "src/server/api/modules/users/procedures/createUser.ts",
    "chars": 502,
    "preview": "import { CreateUserSchema } from \"~/server/api/modules/users/procedures/createUserSchema\"\nimport { createUser } from \"~/"
  },
  {
    "path": "src/server/api/modules/users/procedures/createUserSchema.ts",
    "chars": 194,
    "preview": "import z from \"zod\"\n\nexport const CreateUserSchema = z.object({\n  name: z.string(),\n  username: z.string(),\n  password: "
  },
  {
    "path": "src/server/api/modules/users/procedures/listUsers.ts",
    "chars": 543,
    "preview": "import { protectedProcedure } from \"~/server/api/trpc\"\nimport { db } from \"~/server/db\"\nimport { users as userTable } fr"
  },
  {
    "path": "src/server/api/modules/users/procedures/setupUser.ts",
    "chars": 681,
    "preview": "import { TRPCError } from \"@trpc/server\"\nimport { CreateUserSchema } from \"~/server/api/modules/users/procedures/createU"
  },
  {
    "path": "src/server/api/modules/users/service/checkIsSetup.ts",
    "chars": 459,
    "preview": "import { db } from \"~/server/db\"\nimport { users } from \"~/server/db/schema\"\nimport { count } from \"drizzle-orm\"\n\nimport "
  },
  {
    "path": "src/server/api/modules/users/service/createUser.ts",
    "chars": 500,
    "preview": "import { db } from \"~/server/db\"\nimport { users as userTable } from \"~/server/db/schema\"\nimport bcrypt from \"bcrypt\"\n\nty"
  },
  {
    "path": "src/server/api/root.ts",
    "chars": 540,
    "preview": "import { grocyRouter } from \"~/server/api/routers/grocy\"\nimport { recipeRouter } from \"~/server/api/routers/recipe\"\nimpo"
  },
  {
    "path": "src/server/api/routers/grocy.ts",
    "chars": 713,
    "preview": "import { checkGrocyConnectionProcedure } from \"~/server/api/modules/grocy/procedures/checkGrocyConnection\"\nimport { crea"
  },
  {
    "path": "src/server/api/routers/recipe.ts",
    "chars": 943,
    "preview": "import { deleteRecipeProcedure } from \"~/server/api/modules/recipes/procedures/deleteRecipe\"\nimport { getRecipeByIdProce"
  },
  {
    "path": "src/server/api/routers/user.ts",
    "chars": 581,
    "preview": "import { checkIsSetupProcedure } from \"~/server/api/modules/users/procedures/checkIsSetup\"\nimport { createUserProcedure "
  },
  {
    "path": "src/server/api/trpc.ts",
    "chars": 3088,
    "preview": "/**\n * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS:\n * 1. You want to modify request context (see Part 1).\n * 2. Y"
  },
  {
    "path": "src/server/auth.ts",
    "chars": 2304,
    "preview": "import { db } from \"~/server/db\"\nimport { users } from \"~/server/db/schema\"\nimport bcrpyt from \"bcrypt\"\nimport { eq } fr"
  },
  {
    "path": "src/server/db/drizzle/0000_rare_sauron.sql",
    "chars": 869,
    "preview": "CREATE TABLE `recipe-buddy_ingredient` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`scrapedName` text NOT NULL,"
  },
  {
    "path": "src/server/db/drizzle/0001_worthless_aqueduct.sql",
    "chars": 58,
    "preview": "ALTER TABLE `recipe-buddy_recipe` ADD `servings` integer;\n"
  },
  {
    "path": "src/server/db/drizzle/meta/0000_snapshot.json",
    "chars": 3734,
    "preview": "{\n  \"version\": \"5\",\n  \"dialect\": \"sqlite\",\n  \"id\": \"6d9f7961-4666-469a-bc84-92afae7f2c60\",\n  \"prevId\": \"00000000-0000-00"
  },
  {
    "path": "src/server/db/drizzle/meta/0001_snapshot.json",
    "chars": 3918,
    "preview": "{\n  \"version\": \"5\",\n  \"dialect\": \"sqlite\",\n  \"id\": \"ce10c78c-b332-4765-b5d1-932f1db6cf33\",\n  \"prevId\": \"6d9f7961-4666-46"
  },
  {
    "path": "src/server/db/drizzle/meta/_journal.json",
    "chars": 348,
    "preview": "{\n  \"version\": \"5\",\n  \"dialect\": \"sqlite\",\n  \"entries\": [\n    {\n      \"idx\": 0,\n      \"version\": \"5\",\n      \"when\": 1711"
  },
  {
    "path": "src/server/db/drizzle-migrate.mjs",
    "chars": 393,
    "preview": "import Database from \"better-sqlite3\"\nimport { drizzle } from \"drizzle-orm/better-sqlite3\"\nimport { migrate } from \"driz"
  },
  {
    "path": "src/server/db/index.ts",
    "chars": 241,
    "preview": "import Database from \"better-sqlite3\"\nimport { drizzle } from \"drizzle-orm/better-sqlite3\"\n\nimport * as schema from \"./s"
  },
  {
    "path": "src/server/db/migrate.ts",
    "chars": 429,
    "preview": "import { dirname, join } from \"path\"\nimport { fileURLToPath } from \"url\"\nimport { migrate } from \"drizzle-orm/better-sql"
  },
  {
    "path": "src/server/db/schema.ts",
    "chars": 1837,
    "preview": "import { InferInsertModel, InferSelectModel, relations } from \"drizzle-orm\"\nimport {\n  index,\n  integer,\n  sqliteTableCr"
  },
  {
    "path": "src/server/db/tsconfig.json",
    "chars": 234,
    "preview": "{\n  \"compilerOptions\": {\n    \"target\": \"es2022\",\n    \"module\": \"esnext\",\n    \"esModuleInterop\": true,\n    \"forceConsiste"
  },
  {
    "path": "src/styles/globals.css",
    "chars": 1577,
    "preview": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n@layer base {\n  :root {\n    --background: 0 0% 100%;\n    --f"
  },
  {
    "path": "src/trpc/react.tsx",
    "chars": 2245,
    "preview": "\"use client\"\n\nimport { useState } from \"react\"\nimport {\n  MutationCache,\n  QueryCache,\n  QueryClient,\n  QueryClientProvi"
  },
  {
    "path": "src/trpc/server.ts",
    "chars": 1911,
    "preview": "import \"server-only\"\n\nimport { cache } from \"react\"\nimport { cookies } from \"next/headers\"\nimport {\n  createTRPCProxyCli"
  },
  {
    "path": "src/trpc/shared.ts",
    "chars": 802,
    "preview": "import { type inferRouterInputs, type inferRouterOutputs } from \"@trpc/server\"\nimport { type AppRouter } from \"~/server/"
  },
  {
    "path": "src/types/index.d.ts",
    "chars": 876,
    "preview": "import { Icons } from \"~/components/icons\"\n\nexport type NavItem = {\n  title: string\n  href: string\n  disabled?: boolean\n"
  },
  {
    "path": "tailwind.config.js",
    "chars": 2143,
    "preview": "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  darkMode: [\"class\"],\n  content: [\n    './pages/**/*.{ts"
  },
  {
    "path": "tsconfig.json",
    "chars": 857,
    "preview": "{\n  \"compilerOptions\": {\n    /* Base Options: */\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true,\n    \"target\": \"e"
  }
]

About this extraction

This page contains the full source code of the georgegebbett/recipe-buddy GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 149 files (204.9 KB), approximately 56.3k tokens, and a symbol index with 108 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!