Skip to content

refactor(ui): extract modular Jinja2 templates into templates directory - #56

Closed
abhirajadhikary06 wants to merge 1 commit into
OBLIQ-in:mainfrom
abhirajadhikary06:dev/modular-templates
Closed

abhirajadhikary06 wants to merge 1 commit into
OBLIQ-in:mainfrom
abhirajadhikary06:dev/modular-templates

Conversation

@abhirajadhikary06

Copy link
Copy Markdown
Member

Summary

Refactors the Developer Portal frontend by decomposing the monolithic Python string templates into a clean, dedicated src/obliq_api/templates/ directory with individual HTML template files per interface.

This improves maintainability, enables syntax highlighting and linting for frontend templates, and integrates standard fastapi.templating.Jinja2Templates.


Changes by File

1. New Modular Templates (src/obliq_api/templates/)

  • base.html:
    • Contains HTML5 boilerplate, typography (Inter & JetBrains Mono), and Tailwind CSS dark-theme styling.
    • Sticky navigation bar with active route highlighting, OpenAPI docs link, and Bearer token modal prompt (promptAuthToken()).
    • Offline network detection banner (window.addEventListener('offline')).
    • Shared client-side utilities (apiFetch(), token persistence in localStorage, and auth indicators).
  • keys.html:
    • Extends base.html.
    • API Key summary cards (Active, Expiring / Grace Period, Total).
    • Responsive keys table with status badges (Active, Expiring, Revoked), scopes, expiry dates, and action buttons.
    • Interactive modals: Create Key, Copy-Once Secret Reveal, and Rotate Key (with configurable overlap grace period).
  • usage.html:
    • Extends base.html with Chart.js (chart.umd.min.js).
    • Dropdown selector for date range filtering (7, 30, and 90 days).
    • Summary KPI cards (Total OCR Jobs, Pages Processed, Credits Charged, Failed Jobs).
    • Two interactive charts: Daily Request Volume / Pages Extracted and 24-Hour Hourly Traffic Trend.
  • docs.html:
    • Extends base.html.
    • Interactive tab switcher for TypeScript (@obliq/client), Python (httpx), and cURL.
    • Copyable quickstart snippets for document submission, job polling, and programmatic key management.

2. Router Integration (src/obliq_api/api/ui/router.py)

  • Configured fastapi.templating.Jinja2Templates pointing to src/obliq_api/templates/.
  • Updated endpoints (/dashboard/keys, /dashboard/usage, /dashboard/docs) to return TemplateResponse(request=request, name="...").

3. Backward Compatibility Layer (src/obliq_api/api/ui/templates.py)

  • Pre-renders KEYS_PAGE_HTML, USAGE_PAGE_HTML, and DOCS_PAGE_HTML using Jinja2 so that any existing scripts or test fixtures importing these constants continue to function without breaking changes.

Type of Change

  • refactor: Non-breaking code refactoring / frontend cleanup
  • ui: Modular HTML template decomposition

Verification & Testing

  • pytest tests/unit/: All 10 unit tests pass cleanly (2.62s).
  • ruff check .: 100% clean, 0 lint warnings.
  • ruff format --check .: Cleanly formatted.
  • Manual verification: Verified /dashboard, /dashboard/keys, /dashboard/usage, and /dashboard/docs render HTTP 200/307.

@github-actions github-actions Bot added documentation Improvements or additions to documentation or runbooks api Endpoints, request and response contract, versioning labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Endpoints, request and response contract, versioning documentation Improvements or additions to documentation or runbooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant