# Ensign Bug Tracker

A unified internal bug tracking tool for Ensign's product suite, designed for fast triage, centralised reporting, and multi-product visibility. Built as a standalone Next.js + Postgres app with ensign-sso integration for access control and audit trails. Features Linear-inspired UX, GitHub version context, and client-specific issue tracking.

## Goals

- Reduce average time-to-resolution for internal bug reports
- Centralise bug tracking across all Ensign products in one self-hosted tool
- Enforce access control and audit logging via ensign-sso integration

## Features

- **Bug Creation** — Submit new bugs with title, description, product, version, priority, status, and optional client association.
- **Bug Assignment & Triage** — Assign bugs to internal users, update priority/status, and sort by product/version/team.
- **Commenting** — Threaded comments on bugs for discussion and progress updates.
- **Search & Filtering** — Full-text search and filters by product, status, priority, assignee, and client.
- **GitHub Integration (Read-only)** — Pull version/branch/release context from GitHub for accurate bug-product linkage.
- **Client Tracking** — Associate bugs with client entities and track metrics like issue count and reply rate.
- **Audit Trail** — Log creation, updates, assignment, and status changes with user, timestamp, and diff.
- **Dashboarding** — View bug trends, resolution times, open counts, and team workload.
- **File Attachments** — Upload and store screenshots/logs via S3-compatible object storage.

## Milestones

1. **Core Domain & Auth** — Establish multi-tenant bug tracking entities, ensign-sso integration, and audit logging.
2. **Bug Lifecycle** — Implement CRUD, assignment, status/priority updates, and commenting.
3. **Search & GitHub Linking** — Enable full-text search and populate version context from GitHub repos.
4. **Client Metrics & Dashboards** — Introduce client entity, link bugs, and surface key metrics via dashboards.
5. **Attachments & Polish** — Add S3-backed file uploads and refine UX for mobile/tablet responsiveness.

## Tasks

### Core Domain & Auth

- **Set up Next.js + Drizzle project with multi-tenancy** _(Urgent · 1d)_
- **Create Bug, Client, and related Drizzle schemas** _(Urgent · 1d)_
- **Integrate ensign-sso JWT verification and RequestContextService** _(Urgent · 1d)_
- **Implement audit trail middleware for bug entity changes** _(High · 1d)_

### Bug Lifecycle

- **Build Bug CRUD API endpoints** _(Urgent · 2d)_
- **Implement server actions for bug creation and updates** _(Urgent · 1d)_
- **Add UI for bug creation/editing using React Hook Form + Zod** _(Urgent · 2d)_
- **Implement comment threading on bug detail view** _(High · 1d)_

### Search & GitHub Linking

- **Build TanStack Table-based bug list with sorting/filtering** _(Urgent · 2d)_
- **Add full-text search to bug listing query** _(High · 1d)_
- **Integrate GitHub API read-only client for repo/version lookup** _(High · 2d)_
- **Design and seed fixed taxonomy for status/priority enums** _(Medium · 0.5d)_

### Client Metrics & Dashboards

- **Create Client entity with issue count and reply rate fields** _(High · 1d)_
- **Link Bugs to Clients and expose via API** _(High · 1d)_
- **Build dashboard view with Recharts for bug trends** _(High · 2d)_

### Attachments & Polish

- **Implement S3-compatible file upload endpoint and storage** _(Medium · 2d)_
- **Add file attachment UI on bug creation/view** _(Medium · 1d)_
- **Optimise layout for mobile/tablet responsiveness** _(Medium · 1d)_

## Out of scope

- Email alerts or notifications
- Configurable status/priority taxonomies (fixed only in v1)
- Offline submission support
- GitHub issue auto-creation or commit linkage
- Third-party bug reporter integrations (e.g. crash logs)
- Advanced role-based permissions beyond ensign-sso
