Install the following on your machine.
- Go version 1.21+
- Postgres 16.1+
- XCode on your Mac from the App Store
- Flutter fpr mobile development
- Postman for API access
Add the following line in your ~/.zshrc
. In the terminal, run the following command
grep 'export PATH=$PATH:$(go env GOPATH)/bin' ~/.zshrc || echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc
Clone this repository
git clone https://github.com/bigpanther/billton.git
Open the code in Visual Studio Code
Install the atlas
tool for database migrations
brew install ariga/tap/atlas
git checkout main
git pull --rebase
git checkout <your-branch>
git rebase main
# Make changes and commit the code
# Push the changes to github
git push origin <your-branch>
You can use the VSCode git extension to run the same steps from the UI instead of the terminal.
To run the program, use
make run-dev
Open a new terminal and run
curl --location 'http://localhost:8080/warranties' \
--header 'Content-Type: application/json' \
--data '{
"transaction_time": "2023-06-29T20:52:20.015924-07:00",
"expiry_time": "2024-07-03T20:52:20.015924-07:00",
"brand_name": "Samsung",
"amount": 100000,
"store_name": "Costco"
}'
Expect to get back a response with a generated ID
curl --location 'http://localhost:8080/warranties/<replace this with the ID from the previous step>'
soda generate fizz create_users
In the migration up file, add the new table schema
create_table("users") {
t.Column("id", "uuid", {primary: true})
t.Column("name", "string", {})
t.Timestamps()
}
In the down migration file, add the reverse
drop_table("users")
See db migrations and fizz for details on migrations.
Create a model under the models
directory to map the DB table
package models
import (
"time"
"github.com/google/uuid"
)
type User struct {
ID uuid.UUID `json:"id" db:"id" rw:"r"`
Name string `json:"name" db:"name"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}