cmd/server | ||
internal | ||
.gitignore | ||
flake.lock | ||
flake.nix | ||
go.mod | ||
go.sum | ||
query_draft.sql | ||
README.md | ||
shell.nix |
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?
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 )
- Setting environment variables:
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