Skip to content

Latest commit

 

History

History
108 lines (70 loc) · 3.8 KB

File metadata and controls

108 lines (70 loc) · 3.8 KB


Trassenscout (Beta)

Trassenscout (Beta) aids administrations in evaluating and developing cycle highways and other similar route-based infrastructure.

Please contact hello@fixmycity.de to learn more.


Architecture

This project is built with TanStack Start, React, Vite, and Bun. Data is stored in PostgreSQL via Prisma.

Development

For starting developing, the following steps could be helpful for getting started:

  • Install dependencies: bun install
  • Start the development environment: bun run dev (opens http://127.0.0.1:4000)
  • Run nvm use for Prisma and Playwright (they spawn Node; bun run dev uses Bun)
  • Run all checks: bun run check (check migrations, check TypeScript, run linter, run formatter, run tests)
  • Use bun run build and bun run start to test the production bundle locally
  • Husky: We run our checks on push. Use git push --no-verify to force-skip them

Local development uses a gitignored .env file (see .env.example). Production servers get .env from the deploy workflow.

TanStack Start

  • File routes live in src/routes.
  • Shared UI lives in src/components.
  • Server-only code lives in src/server.
  • Authentication is handled by Better Auth.

Supported browsers

Market-share queries in package.json browserslist; wired to vite.config.mts (client build) and oxlint.config.mjs (client API lint).

How it works: browser-target skill

Getting Started

  1. Setup .env:
    This will set up environment variables for PostgreSQL and other services.

    cp .env.example .env
    
  2. Install Docker and open it once to finish the setup:

    brew install --cask docker
    
  3. Start the PostgreSQL Server
    This is done automatically with bun run dev.

    docker compose up -d
    
  4. Seed your database:
    Which will also apply migrations.

    bun run seed
    
  5. Run your app in the development mode:

    bun run dev
    
  6. Open http://127.0.0.1:4000.

Tests

Runs your tests using Jest.

bun run test

Blitz comes with a test setup using Vitest and react-testing-library.

Working with data, database

Follow these steps to add a model with forms and pages:

  1. Add or update the Prisma model in prisma/schema.prisma.

  2. Check prisma/schema.prisma if all was "translated".

  3. Use bun run migrate-create (bun prisma migrate dev --create-only) to create the migration but not run it directly.

  4. Double check the migration. For example, column renames are handled by deleting the column and adding a new one which we do not always want.

  5. Use bun run migrate (bun prisma migrate dev) to apply the migration.

  6. Schema:

    • Add a shared Zod schema (Docs) in src/shared/<domain>/ and use it for client-side validations.
    • Update the Zod schema to match the Prisma schema.
      • You can use type UserType = z.infer<typeof UserSchema> to create a TS schema from Zod that can be compared to the prisma schema (which are located in node_modules/.prisma/client/index.d.ts)
      • You can use https://github.com/CarterGrimmeisen/zod-prisma to generate a starting point for this based on the prisma schema. Use it in a separate branch when experimenting with generated schemas.
  7. Add seed data in prisma/seed.ts and prisma/seeds/ - all models should have good seed data.