---
type: redmine-readme
project: Canofy Process Standardization
subject: End-to-end technical and architecture document for the NSDL SEZ BOE/DTA automation
story_key: nsdl-architecture-documentation
generated_at: 2026-10-15T16:16:51+05:30
story_type: documentation
attachments:
  - file: nsdl-architecture-documentation_20261015-1616__NSDL_SEZ_BOE_Automation_Architecture.md.attach
    description: Architecture document, Markdown version (kept in the repo under docs/)
  - file: nsdl-architecture-documentation_20261015-1616__NSDL_SEZ_BOE_Automation_Architecture.html
    description: Same document as the published single-page HTML (diagrams render in a browser)
---

# End-to-end technical and architecture document for the NSDL SEZ BOE/DTA automation

> One document that lets someone who was not involved understand what was built, how it runs, and what must be configured.

## 1. Summary
The user asked for a complete technical and architectural document with flow charts covering all functions, logic and flows. It was written first as a single-page HTML page (published as an Artifact), then as a Markdown file in the repo. The Markdown copy was later updated twice when the login flow changed. Both versions are attached.

## 2. Requirement
| # | Requirement | Source | Status |
|---|---|---|---|
| R1 | Cover all functions, logic and flows with flow charts | user (2026-09-15) | Done |
| R2 | Readable by anyone: what was built, how it works, what to configure | user | Done |
| R3 | A `.md` version | user: "create one.md file" | Done |
| R4 | Keep the document in step with later login changes | follow-up | Done for the Markdown copy; the HTML page is not confirmed to match (see section 8) |

## 3. Decisions
| Decision | Options considered | Why this one | Date |
|---|---|---|---|
| Format of the first version | Markdown; designed HTML page | HTML page with diagrams for readability; Markdown added on request | 2026-09-15 |
| Diagram type | Static images; text diagrams rendered in the browser | Mermaid text diagrams are versionable and render in the page | 2026-09-15 |
| Honest status | Describe everything as done; mark outstanding items | The setup checklist marks Frappe production deployment, the Frappe config record and alert subscription as outstanding | 2026-09-15 |

## 4. Logic & Workflow
Document sections (the same in both versions):

| # | Section | Content |
|---|---|---|
| 0 | Overview | What the system does; Phase A, Phase B, Watchdog |
| 1 | Architecture | Every resource in the stack and the two external systems |
| 2 | Data model | `StagedRecordsTable` row, status flow STAGED -> PUSHED -> ATTACHED, QC_MISMATCH |
| 3 | Phase A | Trigger, date window, login and export, six QC checks |
| 4 | Phase B | Asynchronous trigger, idempotent push, PDF fetch and attach |
| 5 | Watchdog | Hourly scan for records stuck in STAGED over 24 h |
| 6 | Frappe side | `NSDL Sync Run`, scheduled job, API Configuration record |
| 7 | Configuration reference | Parameters, environment variables, secret shape |
| 8 | Hardening | Table of the defects found when moving from local Docker to real Lambda |
| 9 | Setup checklist | Done and outstanding steps |
| 10 | Open items | Known gaps |

## 5. Files & Components Changed
| File / resource | Type | Change | Purpose |
|---|---|---|---|
| `docs/NSDL_SEZ_BOE_Automation_Architecture.md` | Docs | New, then updated in commits `7213244` and `25d6ea0` | Repo copy |
| Published Artifact (single-page HTML) | Docs | New (2026-09-15) | Readable version with rendered diagrams |

## 6. Configuration & Deployment
No deployment. The Markdown file is committed in the Lambda repo; the HTML page is private to the author unless shared from the Artifact page.

## 7. Testing
| Test | Data / Site | Expected | Actual | Status |
|---|---|---|---|---|
| Render check of the HTML page | Browser pane | Diagrams visible and scale to the page | Diagrams scaled after a `max-width` fix; phone-width view could not be tested exactly in the preview | Pass, with a limitation |
| Doc versus code comparison for the login update | Updated login files | Document matches code | Markdown updated to match (2026-10-12) | Pass |

## 8. Known Limitations & Open Items
- The HTML page's own login, EventBridge and schedule descriptions may be older than the Markdown copy. Not confirmed.
- Both versions still show the original Phase A schedule value `cron(0 9 * * ? *)` in the parameters table; the 06:30 IST schedule and the per-client Phase B schedules are not described in them (see `nsdl-eventbridge-scheduling`).
- The attached `.md` copy shows the repo state at the date of export.

## 9. Status
| Item | Value |
|---|---|
| Branch | `main`, then `feature/AI-TBD-nsdl-otp-login` for the later updates |
| Commits | `2e9ba74`, `7213244`, `25d6ea0` |
| PR | None recorded |
| Deployed to | Not applicable |

## 10. References
Related stories: `nsdl-lambda-core-pipeline`, `nsdl-aws-deploy-lambda-hardening`, `nsdl-frappe-trigger-sync-run`, `nsdl-email-otp-login`, `nsdl-login-otp-captcha-update`.
