Skip to content

Add repository memory/speed audit and upgrade plan#2

Open
schartrand77 wants to merge 1 commit intomainfrom
codex/audit-for-memory-and-speed-improvements
Open

Add repository memory/speed audit and upgrade plan#2
schartrand77 wants to merge 1 commit intomainfrom
codex/audit-for-memory-and-speed-improvements

Conversation

@schartrand77
Copy link
Owner

@schartrand77 schartrand77 commented Feb 17, 2026

Motivation

  • Provide a focused performance and memory audit for the app/ backend (FastAPI + SQLModel) and app/static/app.js frontend so maintainers have prioritized, actionable recommendations to reduce CPU, network, and browser memory usage.

Description

  • Add docs/performance_audit.md containing findings (refresh fan-out/report duplication, unbounded list APIs, potential N+1 relation loads, expensive client-side filtering/sorting, and DB/index opportunities) and a prioritized set of recommendations (single-pass report rendering, pagination and envelope responses, eager loading/lightweight DTOs, indexing/SQLite PRAGMA tuning, background sync/caching, HTTP caching, and observability suggestions).

Testing

  • Ran python -m compileall app to validate the Python codebase compiled successfully.

Codex Task

Summary by Sourcery

Documentation:

  • Add a performance and memory audit document detailing current bottlenecks, recommended backend/frontend optimizations, and a suggested implementation order.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 17, 2026

Reviewer's Guide

Adds a new performance and memory audit document for the StockWorks app, outlining current frontend/backend bottlenecks and a prioritized implementation plan for performance-related improvements.

Sequence diagram for optimized frontend refresh and single-pass report rendering

sequenceDiagram
    actor User
    participant UI as Browser_UI
    participant API as Backend_API

    User->>UI: Click Refresh
    UI->>UI: refreshAll()
    activate UI

    UI->>API: GET /materials?suppressReports=true
    UI->>API: GET /inventory?suppressReports=true
    UI->>API: GET /hardware?suppressReports=true
    UI->>API: GET /models?suppressReports=true

    API-->>UI: materials JSON
    API-->>UI: inventory JSON
    API-->>UI: hardware JSON
    API-->>UI: models JSON

    UI->>UI: Update in-memory stores
    UI->>UI: Debounced renderReports() (single call)
    UI-->>User: Updated dashboards and tables
    deactivate UI
Loading

ER diagram for indexed inventory and movement relationships

erDiagram
    MATERIAL {
        int id PK
        string name
        string category
    }

    INVENTORYITEM {
        int id PK
        int material_id FK
        string location
        int quantity
    }

    STOCKMOVEMENT {
        int id PK
        int inventory_item_id FK
        datetime created_at
        int quantity_delta
    }

    HARDWAREITEM {
        int id PK
        string category
        string name
    }

    HARDWAREMOVEMENT {
        int id PK
        int hardware_item_id FK
        datetime created_at
        int quantity_delta
    }

    PRINTMODEL {
        int id PK
        string name
    }

    PRINTMODELSALE {
        int id PK
        int model_id FK
        datetime sold_at
        int quantity
    }

    MATERIAL ||--o{ INVENTORYITEM : has
    INVENTORYITEM ||--o{ STOCKMOVEMENT : tracks

    HARDWAREITEM ||--o{ HARDWAREMOVEMENT : tracks

    PRINTMODEL ||--o{ PRINTMODELSALE : sells
Loading

File-Level Changes

Change Details Files
Introduce a written performance and memory audit with concrete recommendations and implementation order.
  • Document current frontend refresh behavior and recommend consolidating report rendering to a single pass with optional debouncing.
  • Identify unbounded list endpoints and recommend paginated, envelope-style responses with indexed sorting.
  • Describe potential N+1 relationship loading issues and suggest eager loading plus lightweight DTOs for list views.
  • Highlight costly client-side filter/sort and full-table rerenders, recommending cached view-models, incremental DOM updates, and optional virtualization.
  • Propose specific database indexes and SQLite PRAGMA tuning for better query performance.
  • Outline performance-oriented feature upgrades: background sync + caching, materialized reporting tables, HTTP caching/conditional requests, observability instrumentation, and scale-ready API contracts.
  • Provide a prioritized quick-win implementation order for the above recommendations.
docs/performance_audit.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments