Skip to content

perf: optimize main route rendering by caching parsed projects.json structure #1375

Description

@komalharshita

Description

The application reads and parses projects.json repeatedly across route contexts. Parsing JSON from the filesystem on every request wastes CPU cycles and adds I/O overhead. We should load and parse the file once on application start and cache the Python structure in memory.

Current Behavior

projects.json is re-read and parsed repeatedly.

Proposed Solution

  1. In src/utils/data_loader.py, introduce a global cache variable _projects_cache protected by a thread lock.
  2. Fetch from the cache if it is initialized, otherwise read the file, validate it, and store it.
  3. Expose a clear_projects_cache() function for testing.

Implementation Guidance

  • Modify src/utils/data_loader.py.

Acceptance Criteria

  • Parsing is executed only once per process lifecycle.
  • Pytest suite can invalidate/reset the cache between test classes.
  • Application behaves correctly and serves correct results.

Contributor Guidelines

Interested in working on this issue?

  1. Comment /assign to request assignment.
  2. Wait until the issue shows you as the assignee.
  3. Create a new branch for your changes.
  4. Submit a Pull Request referencing this issue.

Please do not begin working on an issue already assigned to another contributor unless a maintainer confirms it is available.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions