{"id":23248340,"url":"https://github.com/ghkrishna/medera-backend","last_synced_at":"2026-05-16T06:38:35.670Z","repository":{"id":268662365,"uuid":"899824555","full_name":"GHkrishna/medera-backend","owner":"GHkrishna","description":"Backend for project medera participating in hedera future hackathon 2.0  ######To-ensure the demo works seamlessly, head over to the below link \u0026 ensure the app is up and running by observing the response for these 3 endpoints /doctor/agentDetails, /agent/agentDetails and /pharmacy/agentDetails to ensure the app is cached by the hosting provider","archived":false,"fork":false,"pushed_at":"2025-10-28T10:51:06.000Z","size":780,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T12:29:12.166Z","etag":null,"topics":["credo-ts","hackathon","hedera","hedera-hashgraph","nestjs"],"latest_commit_sha":null,"homepage":"https://medera-backend.onrender.com/api#","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GHkrishna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-07T05:35:28.000Z","updated_at":"2025-10-28T10:51:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"23b74169-736f-4602-ad9d-2c40a41395ce","html_url":"https://github.com/GHkrishna/medera-backend","commit_stats":null,"previous_names":["ghkrishna/medera-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GHkrishna/medera-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GHkrishna%2Fmedera-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GHkrishna%2Fmedera-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GHkrishna%2Fmedera-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GHkrishna%2Fmedera-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GHkrishna","download_url":"https://codeload.github.com/GHkrishna/medera-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GHkrishna%2Fmedera-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33092856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["credo-ts","hackathon","hedera","hedera-hashgraph","nestjs"],"created_at":"2024-12-19T08:13:31.047Z","updated_at":"2026-05-16T06:38:35.664Z","avatar_url":"https://github.com/GHkrishna.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003chr/\u003e\n\n# Note:\n- **The main repo including all the different components**: https://github.com/GHkrishna/medera\n\n\u003chr\u003e\n\n# Medera Backend\n\n![Medera Logo](./public/medera.png)  \n**Medera** - Backend Service for the Hedera Hackathon\n\nThis repository contains the backend service for the **Medera** project, a healthcare solution built using the [Hedera Hashgraph](https://hedera.com/) platform. The application is developed using [NestJS](https://nestjs.com/), providing a scalable, efficient, and modular backend framework.\n\n## Project Overview\n**Medera** aims to revolutionize healthcare by leveraging the power of distributed ledger technology (DLT). Using the Hedera network, we ensure secure, transparent, and decentralized healthcare solutions.\n\nThis project was built for the **Hedera Hackathon**, showcasing the integration of cutting-edge technologies for a transformative healthcare application.\n\n## Features\n- **DLT Integration**: Secure and transparent data storage on Hedera.\n- **Modular Architecture**: Built with NestJS for maintainability and scalability.\n- **API-First Approach**: Provides robust and documented RESTful APIs.\n- **Enhanced Security**: Uses Hedera for tamper-proof data integrity.\n\n## Table of Contents\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Environment Variables](#environment-variables)\n- [Getting started locally](#getting-started-locally)\n- [Project Structure](#project-structure)\n- [Contributing](#contributing)\n\n---\n\n## Getting Started\n\n### Prerequisites\nBefore running the project, ensure you have the following installed:\n\n- [Node.js](https://nodejs.org/) (v18.x or higher)\n- [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/)\n- A Hedera testnet/mainnet account ([Get one here](https://portal.hedera.com/))\n\n### Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/GHkrishna/medera-backend.git\n   cd medera-backend\n   ```\n\n2. Install dependencies:\n   ```bash\n   yarn install\n   ```\n\n3. Run the application:\n   ```bash\n   yarn start\n   ```\n\n4. For development mode with hot-reloading:\n   ```bash\n   yarn start:dev\n   ```\n\n### Environment Variables\nCreate a `.env` file in the root directory and add the following variables:\n\n```env\n# Agent Configuration\nAgentLabel=medera\nAgentWalletID=medera\nAgentWalletKey=medera\nAGENT_PROTOCOL=http\nAGENT_ENDPOINT=http://ip-address:3000\nSHORT_URL_DOMAIN=http://ip-address:3000\n\n# Doctor Tenant and Schema\nDOCTOR_TENANT_ID=\nDOCTOR_DID=\nPRESCRIPTION_SCHEMA=https://ghkrishna.github.io/schemas/Prescription.json\n\n# Connect to a local postgres instance or neon db(https://neon.tech):\nNEON_DB_PASS=postgres\nNEON_DB=medera\nNEON_DB_ROLE=postgres\nNEON_DB_URL=postgresql://postgres:postgres@localhost:5432/medera\nNEON_DB_HOST=localhost:5432\n\n# Pharmacy Configuration\nPHARMACY_RECEIPT_SCHEMA=https://ghkrishna.github.io/schemas/PharmacyReceipt.json\nPRARMACY_TENANT_ID=\nPHARMACY_DID=\n\n# Hedera Account\nPRIVATE_KEY=\nACCOUNT_ID=\n```\n\nReplace placeholders with the respective values:\n- **Hedera credentials**: `PRIVATE_KEY` and `ACCOUNT_ID`.\n- **Database details**: `NEON_DB_PASS`, `NEON_DB_ROLE`, and `NEON_DB_URL`.\n- **Tenant-specific IDs**: `DOCTOR_TENANT_ID`, `PHARMACY_TENANT_ID`, and `DOCTOR_DID`.\n\n## Getting started locally\nStart the application initially without tenant id and DIDs. Howver, Agent details, database details and hedera account(of type `ED25519`) details created from [Hedera portal](https://portal.hedera.com/) are required.\n\n### Database details\n\u003e Note: eventhough the variable details are `NEON_DB` specific you can connect to any postgress instance\n1. Start postgres locally\n2. Now, enter the appropriated details in the `.env` for your db\n\n**Note**: In case you are connecting to a hosted DB, you'll need to create a wallet for your tenant by adding the following code in your `./src/agent/agent.ts` before `await agent.initialize()`\n\n```typescript\n      // Add this before await agent.initialize();\n      await agent.wallet.create({\n        id: process.env.AgentWalletID,\n        key: process.env.AgentWalletKey,\n        storage: {\n          type: 'postgres',\n          config: {\n            host: process.env.NEON_DB_HOST,\n            connectTimeout: 10,\n            maxConnections: 1000,\n            idleTimeout: 30000,\n          },\n          credentials: {\n            account: process.env.NEON_DB_ROLE,\n            password: process.env.NEON_DB_PASS,\n            adminAccount: process.env.NEON_DB_ROLE,\n            adminPassword: process.env.NEON_DB_PASS,\n          },\n        },\n      });\n\n      await agent.initialize();\n\n```\n\n### Tenant ID's:\nTo set the tenant id, \n1. Start the application initially without tenant id\n2. Headover to the hosted application (http://localhost:3000) and create a tenant using the /agent/createTenant\n3. Not you will need to create two tenants for Doctor and Pharmacy. After creating the tenant add them to their respective `env` variables\n\n### Creating did:hedera\nThe application intends to support did creation on hedera:testnet. To create a `did:hedera:testnet` follow the following steps.\n\u003e Note: We will create a `did:hedera:testnet` for both Doctor and Pharmacy. However we won't be including them into the `env` directly(This is due to an issue with difference in resolving \u0026 signing of a created and imported DID). Instead we'll be creating a DID for each tenant and them import the created DID into alternative agents. So in our case, the doctor(tenant) will create a did, which will then be imported by the pharmacy(tenant) and vice versa.\n\n1. Create a DID as a doctor(tenant-id) from the endpoint /agent/createHederaDid\n2. Once a DID is created, copy the seed used and created did received from response. Now we will import this DID into the Pharmacy tenant/wallet\n\u003e Note: The seed must be unique 32 characters for each new DID creation\n3. Import the did into pharmacy(tenant-id) from endpoint /importHederaDid\n4. Once import is successful with statusCode `201`. You can save this DID into the `PHARMACY_DID`\n5. We will once again repeat the same process to get a DID for Doctor.\n\u003e Note: In this case the Pharmacy will create the did and the doctor will import it. Once this is completed we will have the value for `DOCTOR_DID`\n\n### API Documentation\nNow that you have all the details required to start, you can restart your service with the updated `.env`. \u003cBr/\u003e\nThe API endpoints are documented using Swagger.\n\n1. Start the application.\n2. Navigate to the API docs at: `http://localhost:3000/api`\n\u003e Note: To ensure the demo works seamlessly, head over to the backend (http://your-ip:port/api#/) and ensure the application is up and running by observing the response for these three endpoints /agent/agentDetails(http://localhost:3000/api#/agent), /doctor/agentDetails and(http://localhost:3000/api#/doctor) /pharmacy/agentDetails(http://localhost:3000/api#/pharmacy) to ensure the backend is brought into cache by the hosting provider\n\nExplore and test the endpoints directly from the Swagger UI.\n\n---\n\n## Project Structure\n```\nmedera-backend/\n├── src/\n│   ├── modules/         # Feature-based modules\n│   ├── controllers/     # API controllers\n│   ├── services/        # Business logic\n│   ├── entities/        # Database entities (if applicable)\n│   ├── utils/           # Utility functions\n│   ├── main.ts          # Entry point of the application\n├── test/                # Unit and integration tests\n├── .env                 # Environment configuration\n├── package.json         # Dependencies and scripts\n└── README.md            # Project documentation\n```\n\n---\n\n## Contributing\nWe welcome contributions! To contribute:\n\n1. Fork the repository.\n2. Create a new branch:\n   ```bash\n   git checkout -b feature-name\n   ```\n3. Commit your changes:\n   ```bash\n   git commit -m \"Add new feature\"\n   ```\n4. Push to your branch:\n   ```bash\n   git push origin feature-name\n   ```\n5. Submit a pull request.\n\n---\n\n## Acknowledgments\n- **Hedera**: For providing a secure and efficient DLT platform.\n- **NestJS**: For the robust backend framework.\n- **Hackathon Team**: Sai Ranjit, Tipu Singh, Pranali Dhanavade\n\n---\n\n**Project Links:**\n- [Frontend Repo Clinic](https://github.com/pranalidhanavade/medera-clinic-frontend) - [Frontend Clinic Live Demo](https://medera-clinic-frontend.vercel.app/)\n- [Frontend Repo Pharmacy](https://github.com/pranalidhanavade/medera-pharmacy-frontend) - [Frontend Pharmacy Live Demo](https://medera-pharmacy-frontend.vercel.app/)\n- [Backend Live Demo](https://github.com/GHkrishna/medera-backend/api)\n\u003e Note: To ensure the demo works seamlessly, head over to the [hosted backend](https://medera-backend.onrender.com/api#/) and ensure the application is up and running by observing the response for these three endpoints [/agent/agentDetails](https://medera-backend.onrender.com/api#/Agent), [/doctor/agentDetails](https://medera-backend.onrender.com/api#/Doctor) and [/pharmacy/agentDetails](https://medera-backend.onrender.com/api#/Pharmacy) to ensure the backend is brought into cache by the hosting provider \n\n---\n\n**Contact:**  \nFor queries or support, reach out to us at: [waskekrishna@gmail.com]\n\n### Thank you,\n![Hedera Logo](./public/hedera.png) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghkrishna%2Fmedera-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghkrishna%2Fmedera-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghkrishna%2Fmedera-backend/lists"}