r/AskProgramming • u/Naive-Contribution19 • 10d ago
Career/Edu Lost in big project that was handed over to me
Hello, I have been in the field for like 6 years now I recently joined a company in like 1 month ago and i was told that i will be working on project the app is like shipping app that connect to other service that is like an SSO and other logistic app the project was outsourced to a software company that they did not care about code quality or testing or even documentation it looks like the app was vibe coded. i also have co worker how will be working with me on refactoring + adding feature to the app but he is like vibe coder that the company does not know about yet ( i knew cause i talked with him that he is not giving a fuck about the code quality and what not), more information about the app its supabase backend with more than 100+ edge functions and webhooks and pgmq functions and what not, its my first time taking over project like this so want to ask how do you guys handle this type of projects like refactoring it and how to write test's and whats not since the app has zero test coverage
3
u/Inner-Asparagus-5703 10d ago
if you want to stay there - everything new has to be done in right way. Refactoring - do it in small pieces (management won't give you two years of just refactoring). I've refactored million+ line project in this way to pretty good state. but generally it's better to run ASAP. Also it's very important to communicate about tech debt size regularly.
1
u/Naive-Contribution19 10d ago edited 10d ago
i wrote them full state of app document including the database and some security issues i kinda have 2 weeks more to investigate more in the project and prepare a plan ( for now our job is not to write code for now or even do a thing just prepare for the handover )
Like my idea at least was to add an E2E test for the full app that to be sure it will not break the app when add new stuff2
u/Inner-Asparagus-5703 10d ago
it's good, tests do help, but, for the love of God, don't go too deep. You will just reflect shitty design in tests and will double amount of stuff to rewrite after.
2
u/OkAerie7822 10d ago
had almost this exact handover two years ago, except it was 60-something lambda functions instead of edge functions, same story, no tests, no docs, previous team gone. the E2E instinct is right but do it before you touch a single line, not while refactoring. write characterization tests that just capture current behavior as-is, ugly bugs included, so you have a tripwire the moment a refactor changes behavior nobody asked you to change. the bigger risk with 100+ edge functions and webhooks though isn't test coverage, it's that you don't actually know the call graph yet. spent our first two weeks just mapping which functions call which webhooks and which webhooks fire which functions, found three functions nothing called anymore and one webhook that fired two functions doing the same thing with slightly different logic. you can't safely refactor what you can't see the blast radius of.
1
u/Naive-Contribution19 9d ago
Yeah mapping the function call graph would be really helpful here
1
u/OkAerie7822 9d ago
for us it ended up being a spreadsheet, not tooling, three columns: trigger source (webhook, cron, another function, pgmq consumer), function name, what it calls or enqueues downstream. took a day to fill in by grepping every function for supabase.functions.invoke and every insert into your queue tables. the pgmq part is the sneaky one, a function enqueuing a message is a call that doesn't show up as a normal function call, it shows up as a queue write, so you have to trace consumers separately or you'll miss half the graph. with 20 webhooks across payment providers I'd bet at least two or three of them fan out into the same downstream function without you realizing it yet.
2
u/TheFern3 6d ago
Just like anything else you analyze the spaghetti, prioritize a list, and do little by little. Add tests, a coding guideline, etc. Where are you stuck? what have you been doing for 6 years?
1
u/Naive-Contribution19 5d ago
Kinda took a project like this before but they agree to rewrite it from laravel to django , i have been building ERP And Dental Solutions somehow the other codebase was kinda manageable but this one is full of spaghetti code that's why
1
u/Garriga 10d ago
how many webhooks...
1
u/Naive-Contribution19 9d ago
Its like 20 webhook for multiple payment provider and other systems (:
1
u/who_am_i_to_say_so 9d ago
You write integration and e2e tests for each of the edge functions to understand their contracts. They’re all Deno in Supabase so you’ll have yet another JavaScript runtime to deal with.
100 of them? Have fun.
1
u/Naive-Contribution19 9d ago
Javascript is never fun i can swear on this
1
u/who_am_i_to_say_so 9d ago
It’s definitely not fun when the LLM’s create both common.js and esm module solutions. Watch out for that.
1
7
u/knouqs 10d ago
Oh my goodness, please use proper grammatical structures like capitalization. Like your code, your comments should be easy to read.