[Repository data] Preserve language breakdown across GitHub, database, ML, and feed DTOs
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
GitHub metadata produces `language_breakdown` as an array of objects containing name, color, size, and percentage:
- https://github.com/ACM-VIT/gh-social/blob/49073fc71423aa8e10334158d70ac6d41be1dbc0/backend/services/githubService.ts#L224-L257
That array is stored directly in `language_used`:
- https://github.com/ACM-VIT/gh-social/blob/49073fc71423aa8e10334158d70ac6d41be1dbc0/backend/controllers/repoController.ts#L43-L55
The ML payload builder accepts only string elements, so it discards the language objects and sends an empty language list:
- https://github.com/ACM-VIT/gh-social/blob/49073fc71423aa8e10334158d70ac6d41be1dbc0/backend/services/mlService.ts#L181-L202
Feed enrichment calls `Object.keys()` on any object, including arrays, which can turn languages into `["0", "1", ...]`:
- https://github.com/ACM-VIT/gh-social/blob/49073fc71423aa8e10334158d70ac6d41be1dbc0/backend/services/feedService.ts#L47-L66
This damages both recommendation features and the language labels shown by the app.
## Proposed change
Define one canonical repository language representation, for example:
- `languages: Array<{ name, color, size, percentage }>`
- derived `language_names: string[]`
- explicit `primary_language: string | null`
Normalize GitHub responses at the ingestion boundary and use typed conversion functions for database, ML, and client payloads.
## Acceptance criteria
- Imported repositories retain language names and percentages end-to-end.
- ML receives non-empty language names when GitHub supplied them.
- Feed responses never contain numeric array indexes as languages.
- Primary language is preserved explicitly.
- Contract tests cover array-of-object, legacy object-map, string-array, null, and empty representations.
- Existing malformed rows have a documented migration/backfill strategy.
Contributor guide
Research direction
Start with backend/services/githubService.ts, backend/controllers/repoController.ts, backend/services/mlService.ts, and backend/services/feedService.ts to trace the language representations between ingestion, storage, ML, and feed responses. Define and test the canonical conversions described in the issue, including legacy and empty inputs. Done means names and percentages survive end-to-end, primary language is explicit, numeric indexes never appear, and malformed rows have a documented migration or backfill strategy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, data
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100