PROJECT / PRESENTATION

ReturnLoop, the software engineering view

SOFTWARE ENGINEERING · MINI PROJECT

ReturnLoop

A returns and reverse-logistics centre for an e-commerce business: request, pickup, quality check, grading, refurbish / restock / scrap, refund.

PRESENTED BY04

01Chirag Seervi

02Anshuman Singh

03Aryan Singh

04Aadi Srivastava

FLASK · SQLITE · THREE.JS
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
02

AGENDA

What we'll cover

  1. 01 Project planning & managementslide 03
  2. 02 Functional requirementsslide 06
  3. 03 Non-functional requirementsslide 07
  4. 04 Use case diagramslide 08
  5. 05 Class diagramslide 09
  6. 06 Data flow diagram, level 0slide 10
  7. 07 Data flow diagram, level 1slide 11
  8. 08 Activity diagramslide 12
  9. 09 Sequence diagram: gradingslide 13
  10. 10 State diagramslide 14
  11. 11 Sequence diagram: handoffslide 15
  12. 12 Layered architectureslide 16
  13. 13 Architecture: from UI to dataslide 17
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
03

PPM · PRODUCT / PROJECT PLANNING & MANAGEMENT

Vision, scope and stakeholders

Product vision

Give an online store one place to run every return, from the customer's doorstep to a graded item and a correct refund, with every step on record.

Objectives

  • Enforce return rules automatically
  • Grade items A / B / C and route them
  • Compute refunds exactly, once
  • Live tracking for the customer

In scope

  • 6 roles, 13-status workflow
  • Pickup booking, 2 attempts
  • QC checklist, fraud check
  • Refurbish & re-inspection
  • Refund + inventory log
  • Admin dashboard & flags

Out of scope

  • Real payments / payment gateway
  • Passwords & real accounts
  • Courier API integration

Stakeholders

Customerreturns items, tracks refund
Pickup agentcollects parcels
Warehousechecks parcels in
QC inspectorgrades items
Refurbisherrepairs grade B
Adminmonitors, flags

Team

Chirag Seervi, Anshuman Singh, Aryan Singh, Aadi Srivastava

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
04

PPM · PROCESS MODEL & PLAN

Incremental delivery in seven increments

Each increment was built, tested with pytest, run, and committed to Git before the next one started. Definition of done: all tests green and the app runs.

  1. INC ACoreModels, config, services, unit tests
  2. INC BDataSeed data through real services
  3. INC CCustomerOrders, return, pickup, tracking
  4. INC DOperationsAgent, warehouse, QC, refurbisher
  5. INC EAdminDashboard, charts, flags
  6. INC FExperienceDesign system, 3D scenes, effects
  7. INC GHardeningEdge cases, docs, end-to-end demo

Why incremental?

Business rules first, UI later: the riskiest logic (state machine, refunds) was tested before any screen existed.

Work breakdown

Data model → services → routes → templates → visual design → testing & docs.

Tools

Python, Flask, SQLite, pytest, Git, VS Code, Playwright for screenshot checks.

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
05

PPM · RISK & QUALITY MANAGEMENT

Risks, and how we handled them

RiskImpactMitigation in the product
Invalid status jumps (e.g. refund before QC)HighSingle state machine; every change validated and logged in status_history
Refund paid twiceHighUnique refunds.return_id + service check + one DB transaction
Double-clicks on submitMediumButtons disable on submit; server rejects the repeat via the state machine
Malicious or huge uploadsMediumType, 3 MB size and file-signature checks; random file names
Device without WebGL / slow GPULowStatic fallbacks; particles halve if frame rate < 40 fps
Rules change later (window, fees)LowAll rule constants live in config.py

QUALITY: 109 AUTOMATED TESTS · STATE MACHINE, REFUNDS, ELIGIBILITY, FLAGS, API, PAGES, FULL FLOW

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
06

REQUIREMENTS

Functional requirements

FR01Role switch

Choose any of 6 roles and a user without a password; each page rejects the wrong role (403).

FR02View orders

Customer sees delivered items with eligibility, or the reason it can't be returned.

FR03Eligibility

Return allowed within 7 days of delivery, for returnable products, with no other open return.

FR04Request return

Reason, comment (≤ 300 chars), optional photo (PNG/JPG/WEBP, ≤ 3 MB).

FR05Book pickup

Date from tomorrow to +5 days, slot Morning / Afternoon / Evening; reschedule.

FR06Collect parcel

Agent marks picked up or absent; the 2nd absence cancels the return.

FR07Receive

Warehouse checks the parcel in; it joins the QC queue.

FR08Inspect & grade

QC checklist, suggested grade, A/B/C; a mismatched item is rejected as fraud.

FR09Refurbish

Grade B goes to repair, then re-inspection: pass → restock (70%), fail → scrap.

FR10Refund

final = max(0, base × grade% − pickup fee), damaged/wrong-item exception, created once.

FR11Track

Live status (polled every 5 s), history timeline and refund breakdown.

FR12Dashboard

Totals, reasons and grades charts, frequent-returner flags (> 3 in 30 days).

FR13Hand off

After each step, a card names the next desk and opens its page in one click.

FR14Repair ticket

QC's findings become the fix list; ticked fixes are saved as the notes; past repairs show QC's verdict.

FR15Live feed

The admin sees the latest status changes, newest first, with who made each one.

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
07

REQUIREMENTS

Non-functional requirements

NFR01Performance

60 fps on a mid laptop, 30+ on phones; pixel ratio capped; 3D pauses off-screen.

NFR02Reliability

Refund + inventory log + status change in one transaction; no double refunds.

NFR03Security

Role guard on every blueprint; customers only see their own returns; upload validation.

NFR04Usability

Plain-language errors and empty states; the handoff card always names the next step.

NFR05Accessibility

WCAG AA contrast, keyboard-only use, visible focus, reduced-motion mode, text on every badge.

NFR06Maintainability

Logic in services/, rules in config.py, thin routes; a pytest suite over services, pages and the full flow.

NFR07Portability

Python 3.10+, SQLite, no build step: install, seed, run in 3 commands.

NFR08Robustness

Static fallbacks without WebGL or internet; friendly 403 / 404 / 413 pages.

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
08

UML · USE CASE DIAGRAM

Who does what

ReturnLoop system Customer Admin Pickup agent Warehouse QC inspector Refurbisher View orders Request return Book pickup Track return Close return View dashboard View flagged customers Check eligibility «include» Issue refund View pickups Mark picked up Mark customer absent Receive parcel View inventory Inspect & grade Re-inspect item Reject as fraud Mark repaired «include»
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
09

UML · CLASS DIAGRAM

The domain model (models.py)

classDiagram
  direction TB
  class Customer {
    +name
    +email
    +address
  }
  class Product {
    +name
    +price
    +is_returnable
  }
  class Order {
    +order_date
    +delivered_at
    +total
  }
  class OrderItem {
    +quantity
    +unit_price
  }
  class ReturnRequest {
    +return_code
    +reason
    +status
    +flagged_fraud
  }
  class Pickup {
    +slot_date
    +slot_window
    +attempt_no
  }
  class QCReport {
    +grade
    +item_matches_order
    +is_recheck
  }
  class RefurbishJob {
    +status
    +completed_at
  }
  class Refund {
    +grade_percent
    +pickup_fee
    +final_amount
  }
  class InventoryLog {
    +action
    +quantity
  }
  class StatusHistory {
    +from_status
    +to_status
    +actor_name
  }
  Customer "1" --> "*" Order : places
  Order "1" *-- "1..*" OrderItem : contains
  OrderItem "*" --> "1" Product
  OrderItem "1" --> "*" ReturnRequest : returned in
  ReturnRequest "1" *-- "*" Pickup
  ReturnRequest "1" *-- "*" QCReport
  ReturnRequest "1" *-- "*" RefurbishJob
  ReturnRequest "1" *-- "0..1" Refund
  ReturnRequest "1" *-- "*" StatusHistory
  ReturnRequest "1" --> "*" InventoryLog
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
10

DFD · LEVEL 0 (CONTEXT DIAGRAM)

The system and the people around it

flowchart LR
  C[Customer]
  AG[Pickup agent]
  WH[Warehouse manager]
  QC[QC inspector]
  RF[Refurbisher]
  AD[Admin]
  S(("0
ReturnLoop
System")) C -- "return request, photo, pickup slot" --> S S -- "eligibility, status, refund breakdown" --> C S -- "pickup list, addresses" --> AG AG -- "picked up / absent" --> S WH -- "parcel received" --> S S -- "inbound parcels, inventory" --> WH S -- "QC queue, item details" --> QC QC -- "checklist, grade" --> S S -- "repair jobs" --> RF RF -- "repaired" --> S S -- "stats, charts, flagged customers" --> AD
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
11

DFD · LEVEL 1

Processes and data stores

flowchart LR
  C[Customer]
  AG[Pickup agent]
  WH[Warehouse]
  QC[QC inspector]
  RF[Refurbisher]
  AD[Admin]
  P1(("1.0
Check eligibility
& create return")) P2(("2.0
Schedule
pickup")) P3(("3.0
Collect
parcel")) P4(("4.0
Receive
parcel")) P5(("5.0
Inspect
& grade")) P6(("6.0
Refurbish")) P7(("7.0
Issue
refund")) P8(("8.0
Report
& flag")) D1[("D1 Orders / Products")] D2[("D2 Return requests")] D3[("D3 Pickups")] D4[("D4 QC reports")] D5[("D5 Refunds + Inventory log")] D6[("D6 Status history")] C -- "reason, photo" --> P1 D1 -- "delivery date, returnable" --> P1 P1 -- "new return" --> D2 C -- "date, slot" --> P2 P2 --> D3 D3 -- "pickup list" --> AG AG -- "outcome" --> P3 P3 --> D2 WH -- "check-in" --> P4 P4 --> D2 QC -- "checklist, grade" --> P5 P5 --> D4 P5 -- "grade B" --> P6 D4 -- "QC findings" --> P6 RF -- "repaired" --> P6 P6 -- "re-inspection" --> P5 P5 -- "A / C / recheck" --> P7 P7 --> D5 P5 -. "every status change" .-> D6 D2 & D5 --> P8 D6 -- "latest events" --> P8 P8 -- "stats, flags, live feed" --> AD
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
12

UML · ACTIVITY DIAGRAM

One return, start to finish

Open orders CUSTOMER Eligible? Request return CUSTOMER Book pickup CUSTOMER Customer home? Picked up AGENT Received at centre WAREHOUSE Show reason Rebook next day AGENT Cancel return AGENT noyes no (1st)no (2nd)yes Matches order? Reject as fraud QC Grade Refurbish REFURBISHER Recheck passes? Restock QC Scrap QC Refund +inventory log SYSTEM Customercloses it CUSTOMER noyes ACB yesno
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
13

UML · SEQUENCE DIAGRAM

QC grades a return and the refund is issued

sequenceDiagram
  autonumber
  actor QC as QC inspector
  participant B as Browser
  participant R as qc blueprint
  participant W as services.returns
  participant SM as state_machine
  participant F as services.refund
  participant DB as SQLite
  QC->>B: tick checklist, choose grade A, Stamp it
  B->>R: POST /qc/inspect/RL-2026-0004
  R->>W: submit_inspection(ret, checklist, "A")
  W->>SM: change_status(Received → Inspected)
  W->>SM: change_status(Inspected → Restocked)
  W->>F: issue_refund(ret, "Restocked")
  F->>F: calculate_refund(base, A, reason)
  F->>SM: change_status(Restocked → Refunded)
  F->>DB: INSERT refund, inventory_log, status_history (one COMMIT)
  R-->>B: 302 redirect to queue + toast
  Note over B,DB: Customer's tracking page polls GET /api/return/code/status every 5 s and moves the parcel
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
14

UML · STATE DIAGRAM

Every status a return can be in

Requested entry/ assign RL codeentry/ log reason Pickup Scheduled entry/ create pickup slotdo/ wait for the agent Picked Up entry/ outcome = Pickeddo/ travel to centre Received entry/ join QC queuedo/ wait for inspection Cancelled entry/ log missed pickups Rejected entry/ log why it stopped Inspected entry/ save QC reportentry/ route by grade Refurbishing entry/ open repair jobdo/ repair the item Re-inspection entry/ job = Repaireddo/ second QC check Restocked entry/ back on the shelf Scrapped entry/ write the item off Refunded entry/ save Refund rowentry/ log inventory Closed entry/ customer confirmed requestReturn[eligible] bookPickup /assignAgent markPickedUp markReceived absent [2nd] inspect [mismatch] /flagFraud [not eligible] absent [1st] / rebook,reschedule submitInspection[item matches] [grade A] [grade B] /openJob markRepaired recheck [B] recheck [C] [grade C] / issueRefund / issueRefund closeReturn done well QC / repair stopped or scrapped ARROWS event [guard] / action BOXES entry/ on arrival · do/ while in the state change_status() REFUSES ANY MOVE NOT DRAWN HERE
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
15

UML · SEQUENCE DIAGRAM

Handing a return to the next desk

sequenceDiagram
  autonumber
  actor A as Pickup agent
  participant B as Browser
  participant R as agent blueprint
  participant W as services.returns
  participant H as services.handoff
  participant S as /switch
  participant DB as SQLite
  A->>B: Mark picked up, confirm
  B->>R: POST /agent/pickup/7
  R->>W: mark_picked_up(pickup)
  W->>DB: status Picked Up + history row (COMMIT)
  R->>R: hand_off(ret): remember RL-2026-0004 in the session
  R-->>B: 302 redirect to /agent/pickups
  B->>R: GET /agent/pickups
  R->>H: handoff_for(ret, agent) while rendering
  H-->>R: next desk: warehouse, Ansuman Singh
  R-->>B: page + card "Your part is done"
  A->>B: Continue as warehouse
  B->>S: POST /switch (who, next, code)
  S-->>B: 302 redirect to /warehouse/receive?focus=RL-2026-0004
  Note over B,DB: The warehouse page opens with this parcel highlighted. No menu, no searching.
RETURNLOOP · SOFTWARE ENGINEERING PROJECT
16

ARCHITECTURE · LAYERS

Layered architecture

L1 Presentation Jinja2 templates · main.css · ES modules · Three.js scenes · GSAP · Chart.js templates/, static/
L2 Controller / routing Flask blueprints, one per role + JSON API; role guard on each blueprints/
L3 Business logic Workflow, state machine, eligibility, refund, flags, uploads, stats services/
L4 Configuration Every business rule as a named constant (window, fees, %, limits) config.py
L5 Data access Flask-SQLAlchemy ORM: 11 model classes and their relationships models.py
L6 Persistence SQLite database file, indexes on status, customer, history returnloop.db

RULE: EACH LAYER ONLY TALKS TO THE ONE BELOW · ROUTES NEVER CONTAIN BUSINESS RULES

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
17

ARCHITECTURE · FROM UI TO DATA

One click, layer by layer: “Request return”

  1. UIBrowser

    Form with reason tiles, comment and photo is submitted (button disables itself).

  2. HTTPPOST /customer/return/new

    Multipart request reaches Flask; session holds role + user id.

  3. Guardcustomer blueprint

    before_request checks the role is customer, else friendly 403.

  4. Validateservices.uploads

    Photo type, size ≤ 3 MB and file signature are checked.

  5. Rulesservices.eligibility

    7-day window, returnable product, no open return.

  6. Logicservices.returns

    Generates RL-2026-0004, writes the first status_history row.

  7. ORMmodels.ReturnRequest

    SQLAlchemy turns objects into INSERT statements.

  8. DataSQLite

    Rows committed in one transaction.

  9. Back to UIRedirect + Jinja2

    Pickup page renders; tracking page later polls the JSON API.

RETURNLOOP · SOFTWARE ENGINEERING PROJECT

END OF DECK · QUESTIONS?

Thank you.

Chirag Seervi · Anshuman Singh · Aryan Singh · Aadi Srivastava

pip install -r requirements.txt && python seed.py && python app.py

RETURNLOOP · SOFTWARE ENGINEERING PROJECT
01 / 18 ← → TO MOVE · F FOR FULL SCREEN