# rajsoni23/shree-rch-template-api architecture

> Architecture diagram of the GitHub repository rajsoni23/shree-rch-template-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajsoni23/shree-rch-template-api
- Repository: https://github.com/rajsoni23/shree-rch-template-api

## Overview

This is a Vercel serverless API that turns a mother or child template request and Base64-encoded location data into an XLSX download. The workflow is request parsing, input validation and location-data decoding, workbook generation, then binary response. Workbook generation includes the documented Health Facility, SubCentre, and Village dropdowns, with dependent selections and no auto-filter. The sampled source supports these links; internal helper-level calls are grouped because they are all implemented in one file.

Main entry points: [`api/template.js`](https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js) (Template handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["Request handling"]
  node_handler["Template handler<br/>[template.js]"]
  node_body["Body parser<br/>[template.js]"]
  node_decoder["Input validation and decoder<br/>[template.js]"]
end

subgraph group_generation["Workbook generation"]
  node_workbook["Workbook generator<br/>[template.js]"]
  node_exceljs["ExcelJS"]
end

subgraph group_delivery["Response delivery"]
  node_xlsx["XLSX attachment<br/>[template.js]"]
end

node_caller(("API caller"))

node_caller -->|"sends request"| node_handler
node_handler -->|"reads body"| node_body
node_handler -->|"validates and decodes"| node_decoder
node_handler -->|"generates workbook"| node_workbook
node_workbook -->|"creates workbook"| node_exceljs
node_handler -->|"sends attachment"| node_xlsx
node_caller -->|"downloads result"| node_xlsx

click node_handler "https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js"
click node_body "https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js"
click node_decoder "https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js"
click node_workbook "https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js"
click node_xlsx "https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_handler,node_body,node_decoder toneBlue
class node_workbook,node_exceljs toneAmber
class node_xlsx,node_caller toneMint
```

## Components

### Request handling

- [Template handler](https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js): `api/template.js`
- [Body parser](https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js): `api/template.js`
- [Input validation and decoder](https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js): `api/template.js`

### Workbook generation

- [Workbook generator](https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js): `api/template.js`
- **ExcelJS**

### Response delivery

- [XLSX attachment](https://github.com/rajsoni23/shree-rch-template-api/blob/main/api/template.js): `api/template.js`

### Other components

- **API caller**

## Connections

- API caller → Template handler: sends request (evidence: `README.md`)
- Template handler → Body parser: reads body (evidence: `api/template.js`)
- Template handler → Input validation and decoder: validates and decodes (evidence: `api/template.js`)
- Template handler → Workbook generator: generates workbook (evidence: `api/template.js`)
- Workbook generator → ExcelJS: creates workbook (evidence: `api/template.js`)
- Template handler → XLSX attachment: sends attachment (evidence: `api/template.js`)
- API caller → XLSX attachment: downloads result (evidence: `README.md`)
