Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
labels:
- "dependencies"
- "go"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
commit-message:
prefix: "ci"
labels:
- "dependencies"
- "ci"
6 changes: 0 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: Documentation

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write
Expand Down Expand Up @@ -47,7 +42,6 @@ jobs:
run: mkdocs build

- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
Expand Down
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Environment variables
include .env
export

# Helpers
GO_CMD=go
GO_RUN=$(GO_CMD) run
GO_TEST=$(GO_CMD) test
GO_BUILD=$(GO_CMD) build
MIGRATE_CMD=$(GO_RUN) ./cmd/migrate/main.go

# Database Connection (for psql)
DB_DSN=$(DATABASE_URL)

.PHONY: all build run test clean lint migrate-up migrate-down migrate-status docker-up docker-down help

help: ## Show this help message
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

all: lint test build ## Run linter, tests, and build

build: ## Build the API binary
@echo "Building API..."
$(GO_BUILD) -o bin/api ./cmd/api

run: ## Run the API locally
@echo "Starting API..."
$(GO_RUN) ./cmd/api

test: ## Run unit tests with coverage
@echo "Running tests..."
$(GO_TEST) -v -coverprofile=coverage.out ./...
$(GO_CMD) tool cover -func=coverage.out

lint: ## Run golangci-lint
@echo "Running linter..."
golangci-lint run

# database
migrate-up: ## Apply all pending migrations
$(MIGRATE_CMD) -cmd=up

migrate-down: ## Rollback the last migration
$(MIGRATE_CMD) -cmd=down

migrate-status: ## Show migration status
$(MIGRATE_CMD) -cmd=status

migrate-reset: ## Reset database (DOWN all then UP all)
$(MIGRATE_CMD) -cmd=reset

# docker
docker-up: ## Start PostgreSQL container
docker compose up postgres -d

docker-down: ## Stop containers
docker compose down

docker-logs: ## View container logs
docker compose logs -f

# docs
docs-serve: ## Serve documentation locally (pkgsite)
@echo "Opening http://localhost:6060/github.com/off-by-2/sal"
pkgsite -http=:6060

docs-generate: ## Generate API Reference markdown (requires gomarkdoc)
gomarkdoc --output docs/reference.md ./...
57 changes: 17 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,36 @@ docker compose up postgres -d

### 3. Initialize Schema (Migrations)

Run the migration tool to create tables:

```bash
go run ./cmd/migrate -cmd=up
make migrate-up
```

This applies the schema from `migrations/`.

Verify it's working:
### 4. Run the API

```bash
docker exec sal-postgres-1 psql -U salvia -d salvia -c '\dt'
make run
```

You should see 19 tables listed.

### 4. Run the API
### 5. Verify

```bash
go run ./cmd/api
make test
```

The API will be available at `http://localhost:8000`.
## Development Commands

### 5. Verify
We use `make` for common tasks:

```bash
curl http://localhost:8000/health
```
| Command | Description |
|---------|-------------|
| `make all` | Run linter, tests, and build |
| `make run` | Run API locally |
| `make test` | Run tests with coverage |
| `make lint` | Run code quality checks |
| `make migrate-up` | Apply database migrations |
| `make migrate-down` | Rollback last migration |
| `make docker-up` | Start local Postgres |
| `make docs-serve` | View local documentation |

## Environment Variables

Expand All @@ -80,30 +81,6 @@ docker compose up postgres -d
go run ./cmd/migrate -cmd=up
```

### Tables

| Table | Purpose |
|-------|---------|
| `users` | User accounts and authentication |
| `organizations` | Multi-tenant organizations |
| `staff` | Staff membership with role-based permissions (JSONB) |
| `staff_invitations` | Token-based staff invite flow |
| `groups` | Departments/wards within an org |
| `staff_group_assignments` | Staff ↔ group membership |
| `beneficiaries` | Patients/clients |
| `beneficiary_group_assignments` | Patient admission tracking |
| `form_templates` | Versioned clinical form templates |
| `template_group_visibility` | Template access control per group |
| `document_flows` | Multi-step form workflows |
| `document_flow_steps` | Individual steps in a flow |
| `audio_notes` | Voice recordings with offline sync support |
| `audio_note_attachments` | Images/documents attached to recordings |
| `generated_notes` | AI-generated clinical notes (draft → verified → submitted) |
| `note_edit_history` | Audit trail for note edits |
| `timeline_entries` | Patient activity feed |
| `activity_log` | System-wide audit log |
| `deleted_notes_archive` | Soft-delete archive for compliance |

## Docker

Run the full stack (API + database):
Expand Down
Loading