Find a file
2025-04-23 16:29:01 -05:00
cmd/server make get and post endpoints work, update enums to be strings, add log file output 2025-04-23 15:34:19 -05:00
internal organize routes into route groups, add comments 2025-04-23 16:29:01 -05:00
.gitignore add comments, make errors more consistent 2025-04-23 16:23:59 -05:00
flake.lock set up project 2025-03-29 19:06:07 -05:00
flake.nix set up project 2025-03-29 19:06:07 -05:00
go.mod restructure application, add get endpoint 2025-04-21 18:30:12 -05:00
go.sum restructure application, add get endpoint 2025-04-21 18:30:12 -05:00
query_draft.sql restructure application, add get endpoint 2025-04-21 18:30:12 -05:00
README.md add comments, make errors more consistent 2025-04-23 16:23:59 -05:00
shell.nix set up project 2025-03-29 19:06:07 -05:00

Vegan Barcode

The goal of this project is to be a crowd sourced resource to find out if a product is vegan

Project organization

  • handlers: gets query parameters to call service and responds with service output
  • services: takes parameters and performs business logic, calls functions to query database
  • user_claims.go in database package: queries database

Task list

  • figure out how we want to handle database migrations
  • database object models should be separated out from database migration function
  • create main process that runs database migration and then starts api
  • create search api
  • create upload api
  • create workers
    • barnivore lookup
    • alergen ingredient database lookup?
  • create mobile and desktop front ends
  • moderation tooling?

Tip

Paste this to log the SQL queries in stdout. ctx = ksql.InjectLogger(ctx, ksql.Logger)

How to start database

  • Run brew services start postgresql
  • Create database
    • Setting environment variables:
      • PGHOST=localhost
      • DB_NAME=veganDB (Can be arbitrary)
    • Run createdb veganDB (To delete in future just run dropdb )

Troubleshooting

Error: 2025/04/17 16:21:21 ERROR: relation "idx_user_claims_product_id" already exists (SQLSTATE 42P07) Explanation: The database tables already exist and the program was trying to create them again.

Fix: Either don't create the databases again in the code, or run dropdb veganDB to allow it to recreate it.

Error: psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: database "<user>" does not exist Explanation: Postgres automatically tryes to connect to a database with the same name as the user. Specify user and database: psql -U username databaseName