Initial commit

This commit is contained in:
2025-11-29 16:59:02 -06:00
commit da4f051282
25 changed files with 1144 additions and 0 deletions

80
Justfile Normal file
View File

@@ -0,0 +1,80 @@
# Load environment variables from .env
set dotenv-load
# Default recipe to display help
default:
@just --list
# Run the application
run:
go run cmd/api/main.go
# Build the application
build:
go build -o bin/api cmd/api/main.go
# Start the project with file watchers
dev: db-up migrate-up
air
# Run tests
test:
go test -v ./...
# Clean build artifacts
clean:
rm -rf bin/
# Start the database
db-up:
docker-compose up -d
@echo "Waiting for database to be ready..."
@sleep 2
# Stop the database
db-down:
docker-compose down
# Reset the database (WARNING: deletes all data)
db-reset:
docker-compose down -v
docker-compose up -d
@echo "Waiting for database to be ready..."
@sleep 2
just migrate-up
# Run all database migrations
migrate-up: db-up
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path migrations -database "${DATABASE_URL}" up
# Rollback last migration
migrate-down:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path migrations -database "${DATABASE_URL}" down 1
# Create a new migration
migrate-create NAME:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest create -ext sql -dir migrations -seq {{NAME}}
# Connect to the database with pgcli
db-connect:
pgcli "${DATABASE_URL}"
# Run seed data
db-seed:
@echo "Seeding database..."
psql "${DATABASE_URL}" -f seeds/exercise_categories.sql
psql "${DATABASE_URL}" -f seeds/exercises.sql
psql "${DATABASE_URL}" -f seeds/users.sql
psql "${DATABASE_URL}" -f seeds/workouts.sql
@echo "Seed data loaded!"
# Reset database and run seeds
db-fresh: db-reset db-seed
# View database logs
db-logs:
docker-compose logs -f postgres
# Check database status
db-status:
docker-compose ps