포스트

[TIL] Refining the ERD around the user flow

This note reconnects crew, OCR results, AI feedback, and ranking tables around the actual TodayPoor user flow while refining the ERD.

한국어 원문은 여기에서 볼 수 있습니다.
[TIL] Refining the ERD around the user flow

What I did today

  • Write the final plan
    • Reflection of feedback from management

    • Reflection of our team’s thoughts on feedback

  • Summary of ERD modifications
    • Reflection of feedback

    • Comparison with wireframe

  • Reflection of ERD modifications

Edit ERD

  • Service direction and ERD structure were reorganized based on the first planning feedback of the TodayPoor project.

  • 1st revision

    image

    Change ItemsExisting structureChange structureReason for change
    Change group terminologyGROUP, GROUP_MEMBERCREW, CREW_MEMBERSince the term “crew” is used in the front wireframe, the FE/BE/plan terminology was changed to unify it.
    Change group FK namegroup_idcrew_idSince the table name was changed to CREW, the FK name was also modified to be consistent.
    Add crew descriptiondoesn’t existAdd CREW.descriptionA description text is needed on the crew card in the wireframe, so add it to store crew introduction/description information.
    Remove POOR_TITLEPOOR_TITLE table existsdelete tableA separate title table is no longer needed because the title is not managed as a fixed value but is generated by AI each time.
    Add AI result fieldsAI_RESULT.output_text centeredAdd title, roast_message, modeAI generates award titles and vitriol/feedback phrases together, so they are added to separate and save the results
    Change AI model name field namemodel_namemodelChanged field names to make them more concise
    Token Usage Separationtoken_usageinput_token, output_tokenChanged to more accurately record AI usage by separating input and output tokens
    Add prompt versiondoesn’t existAdd prompt_versionAdded to keep track of which version of the prompt resulted in the result, even if the prompt is managed in code.
    Add AI call statusdoesn’t existAdd statusAdded to store AI call success/failure
    Add AI error codedoesn’t existAdd error_codeAdded to track and debug the cause when AI call fails
    Change OCR relationshipOCR_RESULT.expense_idEXPENSE.ocr_result_idThe OCR results are generated first, and the final consumption data modified/confirmed by the user is stored in EXPENSE, so EXPENSE is changed to refer to the OCR results.
    Add OCR extracted valueSave only OCR_RESULT.raw_textAdd extracted_merchant, extracted_amountAdded to allow comparison between the merchant/amount initially recognized by OCR and the final value modified by the user
    Remove image URLEXPENSE.image_urldeleteAfter OCR recognition, the original image is no longer needed, so it is removed to avoid saving it to the DB.
    Consumer-crew relationship becomes essentialcrew_id is nullableEXPENSE.crew_id NOT NULLIt is set as a required value because the policy is that users must register consumption records while joining the crew.
    Mandatory ranking-AI result relationshipai_result_id is nullableRANKING_RESULT.ai_result_id NOT NULLCrew members’ MVP rankings are set to NOT NULL because they necessarily include AI results.
    Clarification of ranking cycleOnly ranking_date existsUse ranking_date on a daily basisSince the service provides MVP/ranking on a daily basis, ranking date is managed on a daily basis.
    • In this ERD revision, the front wireframe terminology and backend domain name are aligned, and POOR_TITLE is removed to match the structure in which AI generates titles and feedback.

    • In addition, the relationship between OCR_RESULT and EXPENSE was reorganized to separate the OCR initial recognition result and the final consumption data modified by the user.

    • Through this, we improved the data structure to be more suitable for MVP service flow.

  • 2nd revision

    image

    Change ItemsExisting structureChange structureReason for change
    Add ranking typeThere is no ranking type distinction in RANKING_RESULTAdd ranking_typeAdded to distinguish between date-based ranking results and random topic-based ranking results
    Ranking type enum definitiondoesn’t existDAILY, RANDOM_TOPICFront wireframe shows both daily and random topic results to clearly distinguish between result types
    Add consent to member informationNo consent to USERAdd is_agreeedAdded to store personal information and consent regarding service use when registering as a member
    Add AI mode for each crewAI mode exists only in result tableAdd CREW.ai_modeAdded to allow setting AI feedback mood/intensity for each crew
    Stay in AI Results ModeAI_RESULT.mode existsstay the sameMaintain a record of what mode the AI ​​results were created in
    Specify enum valueDisplays only the type like enum provider and enum visibilitySpecify enum candidate values ​​as strings in MermaidAdded to help you understand which enum values ​​are used just by looking at the ERD
    • additionally
      • At first, since the AI mode is set at the CREW level, I was wondering whether AI_RESULT should also refer to CREW’s ai_mode like FK.
        • However, the roles of the two values were different.

        • CREW.ai_mode is the ‘AI mode value currently set by the crew’,

        • AI_RESULT.mode is ‘the mode value actually used when the AI result was generated’

        → In other words, the crew’s ai_mode may be changed later, but already generated AI results must remain in whatever mode they were created at the time of creation.

        • Therefore, rather than AI_RESULT directly referencing (FK) CREW.ai_mode, it was judged more appropriate to store the mode value used when generating AI results in AI_RESULT.

Lessons learned

  • We found that a proper ERD can be created by not only drawing tables, but also considering actual user flow, FE screen structure, data responsibility, AI result management, operation and debugging, and future expansion possibilities.- At first, it seemed like the more tables you created, the better, but I felt that a clear structure with clear responsibility and flow of data was more important.

  • Based on what we discussed today, we will have to consider connecting API design and actual service flow in the future.