> ## Documentation Index
> Fetch the complete documentation index at: https://foundry.awaaz.de/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents Prompt Library

> Build a full-stack prompt management system to replace our Google Docs-based workflow for storing, versioning, and testing agent prompts.

## The Problem

At Awaaz.AI, our voice agents are powered by carefully crafted prompts — system instructions that define how an agent behaves on a call. Today, these prompts live in **Google Docs and Drive folders**. This creates real problems:

* **No version history you can actually use** — Google Docs tracks character-level edits, not meaningful prompt versions. Rolling back to "the version that worked well last Tuesday" is a nightmare.
* **No structure** — Prompts have variables like `{{user_name}}`, `{{language}}`, `{{loan_amount}}` but there's no way to test them with real values without copy-pasting into a playground.

You're going to fix this.

***

## Your Mission

Build a **Prompt Library** — a full-stack web app where the team can:

1. **Create and organize** prompt templates with metadata
2. **Fill in variables** and preview the rendered prompt
3. **Test prompts** against an LLM and see the response instantly
4. **Track versions** so we know what changed and when

***

## Time Budget

You have **4 hours**.

***

## Technical Requirements

### Database Layer (PostgreSQL)

Design a schema that stores:

```
prompts
├── id (uuid)
├── name (e.g., "Loan Reminder Agent — Hindi")
├── description
├── category (e.g., "collections", "onboarding", "survey", "verification")
├── language (e.g., "hi", "en", "es", "mr")
├── template_body (the prompt text with {{variables}})
├── variables (JSON array of variable definitions)
├── version (integer, auto-incrementing per prompt)
├── is_active (boolean)
├── created_at
└── updated_at

prompt_versions
├── id (uuid)
├── prompt_id (foreign key)
├── version (integer)
├── template_body (snapshot of the prompt at this version)
├── change_note (e.g., "Made tone more polite for rural users")
├── created_by
└── created_at
```

### Backend Layer

Build the following API endpoints:

**CRUD**

* `GET /prompts` — List all prompts (with filters: category, language, search by name)
* `GET /prompts/:id` — Get a single prompt with its version history
* `POST /prompts` — Create a new prompt
* `PUT /prompts/:id` — Update a prompt (auto-creates a new version)
* `DELETE /prompts/:id` — Soft delete (set `is_active = false`)

**Render & Test**

* `POST /prompts/:id/render` — Accept variable values, return the rendered prompt with all `{{variables}}` filled in
* `POST /prompts/:id/test` — Render the prompt, send it to an LLM API, return the model's response

**Versions**

* `GET /prompts/:id/versions` — List all versions of a prompt
* `GET /prompts/:id/versions/:version` — Get a specific version
* `POST /prompts/:id/rollback/:version` — Rollback to a previous version (creates a new version with the old body)

### Frontend Layer (React or HTML + JS)

Build a single-page app with these views:

**Prompt List Page**

* Searchable, filterable table/grid of all prompts
* Show name, category, language, version number, last updated
* Filter by category and language

**Prompt Editor Page**

* Text editor for the prompt template body
* Auto-detect `{{variables}}` from the template and show input fields for each
* Live preview panel showing the rendered prompt as you type variable values
* "Save" button that creates a new version with an optional change note

**Test Panel**

* Fill in variables → click "Test with LLM" → see the model's response
* Show latency and token count of the LLM response

**Version History**

* List of past versions with timestamps and change notes
* Click to view any version
* "Rollback to this version" button

***

## Example Prompt Template

Here's what a prompt in the library might look like:

**Name:** Loan Reminder — Hindi

**Category:** Collections

**Language:** hi

**Template:**

```
You are a polite loan reminder agent for {{company_name}}.
You are calling {{user_name}} regarding their pending EMI payment.

Details:
- Loan ID: {{loan_id}}
- EMI Amount: ₹{{emi_amount}}
- Due Date: {{due_date}}
- Days Overdue: {{days_overdue}}

Instructions:
- Speak in Hindi (Hinglish is okay)
- Be polite but firm
- If the user says they will pay, ask for a specific date
- If the user says they cannot pay, ask about their situation empathetically
- Never threaten or use aggressive language
```

**Variables:**

```json theme={null}
[
  {"name": "company_name", "type": "string", "default": "Awaaz Financial"},
  {"name": "user_name", "type": "string"},
  {"name": "loan_id", "type": "string"},
  {"name": "emi_amount", "type": "number"},
  {"name": "due_date", "type": "date"},
  {"name": "days_overdue", "type": "number"}
]
```

***

## Constraints & Ground Rules

| Constraint     | Requirement                                                              |
| -------------- | ------------------------------------------------------------------------ |
| **Backend**    | Python + FastAPI/Django                                                  |
| **Database**   | PostgreSQL                                                               |
| **Frontend**   | React or Angular                                                         |
| **LLM API**    | Use OpenAI or Gemini API for the test feature (API key will be provided) |
| **Auth**       | Skip authentication                                                      |
| **Deployment** | Run locally. No need to deploy.                                          |

***

## Evaluation Criteria

| Criteria               | Weight | What We're Looking For                                                                  |
| ---------------------- | ------ | --------------------------------------------------------------------------------------- |
| **Working CRUD**       | 25%    | Can you create, read, update, and list prompts end-to-end?                              |
| **Variable Rendering** | 20%    | Does the template engine correctly fill in `{{variables}}`? Live preview works?         |
| **LLM Test Feature**   | 20%    | Can you render a prompt and get an LLM response from the UI?                            |
| **Version History**    | 15%    | Are versions tracked? Can you view and rollback?                                        |
| **UI/UX**              | 10%    | Is the interface clean and usable? (Doesn't need to be pretty — needs to be functional) |
| **Code Quality**       | 10%    | Clean structure, error handling, separation of concerns                                 |

***

## Bonus Challenges 🏆

* **Diff View:** Show a side-by-side diff between two prompt versions (use a library like `diff-match-patch` or `jsdiff`)
* **Prompt Duplication:** "Clone this prompt" button to quickly create a variant (e.g., same prompt but for a different language)
* **Tag System:** Add freeform tags to prompts for more flexible organization
* **Response Rating:** After testing with an LLM, let the user rate the response (👍/👎) and store it — helps track which prompt versions perform best
* **Export:** Export a prompt as JSON or Markdown for sharing

***

<Card icon="trophy" title="🏆 Hackathon Prize">
  The winner receives a **USD \$20 one-time credit** towards a course or book of their choice.
</Card>
