ninerlog-api

module
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: AGPL-3.0

README

NinerLog API

RESTful backend for NinerLog — a free, open-source, EASA/FAA compliant digital pilot logbook with multi-license tracking, currency evaluation, and PDF export.

Tech Stack

  • Go / Gin / PostgreSQL
  • JWT (access + refresh tokens) with TOTP 2FA
  • lib/pq (Postgres driver) / golang-migrate (schema migrations)
  • oapi-codegen (OpenAPI server types) / kin-openapi (spec parsing)
  • fpdf (PDF logbook export)

Prerequisites

  • Go
  • PostgreSQL
  • Docker & Docker Compose (recommended)

Quick Start

# Start PostgreSQL
make docker-up

# Run migrations & start server
make run

# Run unit tests
make test

# Run integration tests (spins up test DB via Docker)
make test-integration

Make Targets

Target Description
make run Start the API server
make build Build binary to bin/ninerlog-api
make generate Generate Go types from OpenAPI spec
make test Unit tests with coverage
make test-short Unit tests (skip slow)
make test-integration Integration tests (Docker test DB)
make test-e2e End-to-end tests
make test-all All tests
make coverage Generate HTML coverage report
make lint Run golangci-lint
make fmt Format code
make migrate-up Apply all pending migrations
make migrate-down Roll back last migration
make migrate-create NAME=... Create a new migration
make docker-up / docker-down Manage Docker containers

Project Structure

cmd/api/main.go              # Entry point (config, DI, graceful shutdown)
internal/
├── api/
│   ├── generated/           # OpenAPI codegen output (do not edit)
│   ├── handlers/            # HTTP request handlers
│   └── middleware/          # CORS, request logging
├── airports/                # OurAirports database loader
├── config/                  # Environment configuration
├── models/                  # Domain models
├── repository/
│   ├── interfaces.go        # Repository contracts
│   └── postgres/            # PostgreSQL implementations
├── service/                 # Business logic
│   ├── currency/            # EASA/FAA currency evaluators
│   └── flightcalc/          # Flight time & solar calculations
└── testutil/                # Test helpers & fixtures
pkg/
├── email/                   # SMTP email sender
├── hash/                    # Password hashing (bcrypt)
├── jwt/                     # JWT token management
└── solar/                   # Solar position calculations (night time)
db/migrations/               # SQL migrations (25 total)
test/e2e/                    # End-to-end tests

API Endpoints

Group Endpoints
Auth Register, login, refresh, password reset, 2FA setup/verify
User Profile read/update
Licenses CRUD, set default
Class Ratings CRUD (per license)
Flights CRUD with crew, block times, instrument tracking
Aircraft CRUD
Credentials CRUD (medicals, certificates)
Currency Evaluate recency per license (EASA/FAA)
Notifications List, mark read
Contacts CRUD (crew/people)
Reports Statistics, totals by time period
Maps Airport search & lookup
Import CSV flight log import
Export Logbook PDF export

Environment Variables

See .env.example for a complete list of configuration options including database connection, JWT secrets, CORS settings, SMTP configuration, and TLS settings.

Docker

# Build and run with Docker Compose
docker compose up -d

# Or build the image directly
docker build -t ninerlog-api .

Documentation

Full developer documentation lives in docs/. Start with the Developer Guide.

Running NinerLog

To run your own NinerLog instance, see ninerlog-dockerized for a ready-to-use Docker Compose setup with pre-built images.

Repository Description
ninerlog-frontend React/TypeScript PWA frontend
ninerlog-dockerized Self-hosted deployment (Docker Compose)
ninerlog-website Marketing website

Contributing

See CONTRIBUTING.md for development guidelines.

Security

To report a vulnerability, see SECURITY.md.

License

This project is licensed under the GNU Affero General Public License v3.0. See LICENSE.

Directories

Path Synopsis
cmd
api command
internal
api/generated
Package generated contains auto-generated code from the OpenAPI specification.
Package generated contains auto-generated code from the OpenAPI specification.
service/cloudbackup
Package cloudbackup is the user-facing service for cloud backup destinations.
Package cloudbackup is the user-facing service for cloud backup destinations.
service/cloudbackup/netguard
Package netguard restricts the network destinations the cloud-backup subsystem is allowed to connect to, mitigating server-side request forgery (SSRF).
Package netguard restricts the network destinations the cloud-backup subsystem is allowed to connect to, mitigating server-side request forgery (SSRF).
service/cloudbackup/provider
Package provider defines the contract every cloud backup provider plugin must satisfy.
Package provider defines the contract every cloud backup provider plugin must satisfy.
service/cloudbackup/provider/s3
Package s3 implements the cloud backup provider contract against Amazon S3 and S3-compatible object stores (MinIO, Backblaze B2, Cloudflare R2, Wasabi, etc.) using the minio-go client.
Package s3 implements the cloud backup provider contract against Amazon S3 and S3-compatible object stores (MinIO, Backblaze B2, Cloudflare R2, Wasabi, etc.) using the minio-go client.
service/cloudbackup/provider/sftp
Package sftp implements the cloud backup provider contract against any SSH server with SFTP enabled (OpenSSH, Dropbear, atmoz/sftp, hosting providers offering SFTP-only accounts, etc.) using golang.org/x/crypto/ssh and github.com/pkg/sftp.
Package sftp implements the cloud backup provider contract against any SSH server with SFTP enabled (OpenSSH, Dropbear, atmoz/sftp, hosting providers offering SFTP-only accounts, etc.) using golang.org/x/crypto/ssh and github.com/pkg/sftp.
service/cloudbackup/provider/webdav
Package webdav implements the cloud backup provider contract against any RFC 4918 compliant WebDAV server (Nextcloud, ownCloud, mailbox.org, Box, Apache mod_dav, …) using the studio-b12/gowebdav client.
Package webdav implements the cloud backup provider contract against any RFC 4918 compliant WebDAV server (Nextcloud, ownCloud, mailbox.org, Box, Apache mod_dav, …) using the studio-b12/gowebdav client.
service/flightrules
Package flightrules is the single source of truth for "who/what counts as PIC, Dual, FI, Night, IFR, MP/SP …" across the codebase.
Package flightrules is the single source of truth for "who/what counts as PIC, Dual, FI, Night, IFR, MP/SP …" across the codebase.
pkg
cryptoutil
Package cryptoutil provides symmetric encryption primitives used to protect per-user secrets (currently: cloud backup credentials) at rest.
Package cryptoutil provides symmetric encryption primitives used to protect per-user secrets (currently: cloud backup credentials) at rest.
duration
Package duration provides helpers for converting between flight time representations.
Package duration provides helpers for converting between flight time representations.
jwt
solar
Package solar provides a thin wrapper around github.com/mstephenholl/go-solar for computing sunrise/sunset and determining whether a given UTC instant is during daytime or nighttime.
Package solar provides a thin wrapper around github.com/mstephenholl/go-solar for computing sunrise/sunset and determining whether a given UTC instant is during daytime or nighttime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL