> For the complete documentation index, see [llms.txt](https://docs.wallid.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wallid.io/certishop-on-prem/datalayer.md).

# Datalayer

## Data Layer

The Data Layer is the only component you, as the client, must implement. This layer stores and manages credential data securely within your infrastructure. The Client-Gateway communicates with the Data Layer over HTTP.

### Responsibilities

Your implementation should support the following operations:

1. **Create:** Add a new credential to the database.
2. **Import:** Import an existing credential from external systems.
3. **Revoke:** Mark a credential as revoked.
4. **Verify:** Validate the status of a credential.

### Example Implementation

You can implement the Data Layer using any database technology. Below is an example using MongoDB.

#### Setting Up MongoDB

1. Install MongoDB on your infrastructure or use a managed service.
2. Create a `credentials` collection.

#### Example Code

Here is an example of a simple Node.js service for the Data Layer:

```javascript
const express = require('express');
const mongoose = require('mongoose');

const app = express();
app.use(express.json());

const CredentialSchema = new mongoose.Schema({
  credential_id: String,
  name: String,
  type: String,
  status: String,
  expires_at: Date,
});

const Credential = mongoose.model('Credential', CredentialSchema);

app.post('/create', async (req, res) => {
  const credential = new Credential(req.body);
  await credential.save();
  res.status(201).json({ success: true });
});

app.listen(5000, () => console.log('Data Layer service running on port 5000'));
```

Client should setup the datalayer URL on dashboard in order to gateway forward requests to the Data Layer for processing.
