Deployment and Setup
This section guides implementers through each step required to configure and deploy the Private Identity® Facial Age Estimation Portal, from initial account setup to performance testing.
Prerequisites
Verifying you have the right tools and accounts is the first step. This subsection ensures your environment is primed for integration.
GCP Account
Ensure you have credentials for Google IAM (or an equivalent JWT token provider).Development Environment
Install Node.js, Docker CLI, Kubernetes (kubectl), and an IDE (e.g., VS Code).
Environment Configuration
Correctly setting up credentials, tokens, and environment variables is vital for a secure and stable system. This subsection details how to do so.
Google IAM Setup
Create a new Service Account with roles/iam.serviceAccountTokenCreator.
Securely store downloaded JSON keys.
JWT Token Generation (Node.js Example)
const { google } = require('google-auth-library');
const generateJwtToken = async () => {
const client = new google.auth.JWT({
keyFile: 'path/to/service_account.json',
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
const token = await client.authorize();
return token.access_token;
};
Environment Variables
export AGE_ESTIMATION_PORTAL_API=https://api.age.privateid.com
export JWT_TOKEN=<YOUR_GENERATED_TOKEN>
Backend Integration
After configuring your environment, you can begin integrating the Portal into your backend. This subsection shows how to create sessions and retrieve results.
Session Creation
const axios = require('axios');
const createSession = async () => {
const response = await axios.post(
`${process.env.AGE_ESTIMATION_PORTAL_API}/session`,
{
redirectUrl: 'https://www.yoursite.com/post-verification',
ageThreshold: 18,
livenessEnabled: true,
metadata: { userId: '12345' },
callback:{
url:"mywebsite-webhook.com",
headers:{
Authorization:"123"
}
}
},
{
headers: {
Authorization: `Bearer ${process.env.JWT_TOKEN}`,
'Content-Type': 'application/json'
}
}
);
// redirect user to provided url
console.log(response.data.url);
};
createSession();
Result retrieval
const getSessionResult = async (sessionToken) => {
const response = await axios.get(
`${process.env.AGE_ESTIMATION_PORTAL_API}/session/${sessionToken}/result`,
{
headers: {
Authorization: `Bearer ${process.env.JWT_TOKEN}`,
'Content-Type': 'application/json'
}
}
);
console.log(response.data);
};
Containerization and Orchestration
Scalable deployments often involve containerizing the Portal services and orchestrating them with Kubernetes. This subsection presents a sample Dockerfile and Kubernetes manifests.
Docker
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
Kubernetes Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: age-estimation-portal
spec:
replicas: 3
selector:
matchLabels:
app: age-portal
template:
metadata:
labels:
app: age-portal
spec:
containers:
- name: age-portal
image: your-registry/age-portal:latest
ports:
- containerPort: 8080
Testing and Validation
A robust quality assurance strategy ensures reliability in production. This subsection covers unit, integration, and performance testing approaches.
- Unit & Integration Tests
Use Jest, Mocha, or PyTest to assert correct API responses.
- End-to-End Tests
Cypress or Selenium for simulating the entire user flow, including camera verification steps.
- Performance Testing
JMeter or Locust to verify system stability and throughput under peak load.