MyFinances icon indicating copy to clipboard operation
MyFinances copied to clipboard

idea: Add new prefixes and resource IDs

Open TreyWW opened this issue 1 year ago • 6 comments

Companies like Stripe and AWS use prefixed resource IDs to allow users and developers to much more easily identify resources.

For example, our current system has ids like 1235, whereas stripe has inv_3LKQhvGUcADgqkAd5bd6pslE or AWS has like i-12dNk2354asdhsa.

The prefixes inv-, i-, cl_ etc all help with identifying the object type without needing to know extra details, useful for debugging and being human readable for users.

I think it'd be ideal for us to move to this design too, but it'll need a bit of rethinking and model changes.

We'd need a random character based string for IDs rather than integers, like UUIDs, so they can't be guessed - this is generally good in general for any public facing things anyways. And then we'd append the prefix via a model manager or something of the kind.

Seems like a waste of storage (even though only a few bytes) to append the prefix in DB, so I feel like it should be done on the backend.

All items should still have their NORMAL autoincrement ID, but this will never be publicly facing. I believe this is ideal to still have as it is good for efficiency in DB lookups and indexing - correct me if i'm wrong though.

TreyWW avatar Nov 15 '24 11:11 TreyWW

A possible django solutionwould be something like:


resource_id_raw = UUID()

@property
def resource_id(self)
    return f'prefix_{self.resource_id_raw}'

Then you just use invoice.resource_id or x.resource_id and that becomes a globally used thing instead of number IDs.

We could have shorter aliases such as rid too, as long as it's not confusing.

Any thoughts?

TreyWW avatar Nov 15 '24 15:11 TreyWW

Hi! My name is Lamia and I’ve never contributed to an open source project before, but I’d like to try working on this issue! Is it still available?

lamia-alam avatar Nov 21 '24 16:11 lamia-alam

Hello, we are a group of university students working on an open-source contribution assignment. We'd like to work on this issue—can it be assigned to me?

reenu153 avatar Mar 31 '25 17:03 reenu153

Hello, I am student and looking to contribute to an open-source project. is anyone working on this issue, if not can I work on this issue.

ngawa-tafe avatar Jun 05 '25 03:06 ngawa-tafe

Hi both, unfortunately this issue is paused for a while as there are more complications than I realised and would require changes in almost every file.

If you'd like to discuss it let me know, but implementation isn't useful until we've thought it through and came up with a decision

TreyWW avatar Jun 05 '25 09:06 TreyWW

hey,let me know your issue and I'll help you out . i have experience of building finance platform. thank you.

nikhilhere7 avatar Oct 22 '25 05:10 nikhilhere7

Hi, here you can check my proposal to the UUIDs issue: https://github.com/TreyWW/MyFinances/pull/613

alvaroMaleno avatar Dec 01 '25 21:12 alvaroMaleno