Google Document AI Setup
Step-by-step guide to create a GCP project, enable Document AI, generate a service account key, and wire everything into DocuWealth.
Open the Google Cloud Console and sign in with your Google account.
โ console.cloud.google.comClick the project dropdown at the top of the page (next to the Google Cloud logo).
Click New Project in the top-right of the dialog.
Enter a Project Name (e.g. docuwealth-ai) and click Create.
Note the Project ID shown below the name โ it looks like docuwealth-ai-123456. You'll need this later.
Wait for project creation (15โ30 seconds), then select the new project from the dropdown.
In the Cloud Console, go to APIs & Services โ Library (left sidebar).
โ API LibrarySearch for "Document AI" and click the result.
Click Enable. Wait a few seconds for the API to activate.
You may be prompted to enable billing. Document AI has a free tier of 1,000 pages/month โ more than enough for personal use.
Go to IAM & Admin โ Service Accounts in the left sidebar.
โ Service AccountsClick + Create Service Account.
Fill in the details:
Click Create and Continue.
On the Grant this service account access step, click Select a role and choose:
Click Continue, then Done.
Click on the service account you just created to open it.
Go to the Keys tab โ Add Key โ Create new key.
Select JSON and click Create. A JSON file downloads automatically โ this is your credentials file.
Keep this file secret. It grants full Document AI access to your GCP project. Never commit it to Git or share it publicly.
Upload the JSON file to your server (e.g. via SCP) and place it at a secure path:
Go to Document AI โ Overview in the Cloud Console.
โ Document AI ConsoleClick + Create Processor.
Choose a processor type. For DocuWealth (passports, Aadhaar, PAN, driving licences), the best options are:
| Processor | Best for | Recommendation |
|---|---|---|
| Identity Document Parser | Passports, driving licences, national IDs | โ Best choice |
| Form Parser | General structured forms, insurance docs | Good fallback |
| Document OCR | Plain text extraction from any document | Basic |
Tip: Start with Identity Document Parser. It extracts structured fields (name, doc number, issue/expiry dates, nationality) directly from identity documents without needing custom training.
Fill in processor details:
Click Create.
After creation you'll see the processor detail page. Note the Processor ID โ it looks like a1b2c3d4e5f6a7b8 (a 16-character hex string).
The full processor path shown in the UI is:projects/{PROJECT_ID}/locations/{LOCATION}/processors/{PROCESSOR_ID}
You only need the last segment as DOCUMENT_AI_PROCESSOR_ID.
SSH into your server and open the .env file in the project root:
Find the Document AI section (already added) and uncomment + fill in your values:
LOCATION must match the processor region. If you created the processor in us, set DOCUMENT_AI_LOCATION=us. Using eu with a us processor will fail with a 404.
Restart the server to pick up the new env vars:
Check the server log to confirm AI is active:
When you upload a document now, you'll see AI field extraction working in the upload flow โ confidence bar appears and fields are pre-filled.
Open DocuWealth and go to Documents โ Upload Document.
Upload a passport or driving licence (PDF or JPG). After upload, the confirm form should appear with:
- A confidence bar showing the AI confidence percentage
- Pre-filled fields (name, document number, expiry date, etc.) with an AI badge next to each AI-filled field
If confidence is below 70%, the form shows an amber warning and the document will be saved with status review_needed, appearing in the AI Review filter on the documents list.
You can also test the API directly using curl:
-H "Authorization: Bearer <your-token>" \
-F "file=@/path/to/passport.pdf"
| Variable | Where to find it | Example |
|---|---|---|
| GOOGLE_APPLICATION_CREDENTIALS | Path on your server where you placed the downloaded JSON key file | /var/docuwealth/docai-key.json |
| DOCUMENT_AI_PROJECT_ID | GCP Console โ project dropdown โ the ID (not name) shown below the project name | docuwealth-ai-123456 |
| DOCUMENT_AI_LOCATION | Region you selected when creating the processor โ must match exactly | us or eu |
| DOCUMENT_AI_PROCESSOR_ID | Document AI โ your processor โ Processor ID field on the detail page | a1b2c3d4e5f6a7b8 |
Firebase Cloud Messaging Setup
Push notifications for the DocuWealth Android app โ property alerts, insurance renewals, EMI reminders delivered directly to your phone.
Go to the Firebase Console and sign in with your Google account.
โ console.firebase.google.comClick Add project (or Create a project).
Enter a project name: DocuWealth and click Continue.
You can link it to an existing GCP project (the one you created for Document AI) โ Firebase will reuse the same project ID.
Google Analytics step โ you can disable it for a personal project. Click Create project.
Wait for the project to be created (~30 seconds), then click Continue.
In your Firebase project dashboard, click the Android icon (or go to Project settings โ Add app โ Android).
Fill in the registration form:
Click Register app.
Package name must be exact: online.justsimple.wealth โ this matches the android.package in apps/mobile/app.json.
Click Download google-services.json to download the config file.
This file contains your Firebase project config, API keys, and sender ID. It is not secret โ it can be committed to Git. It's referenced in app.json via android.googleServicesFile.
Place the file in the mobile app directory:
Click Next โ Next โ Continue to console (the SDK installation steps are handled by Expo automatically).
In Firebase Console, go to Project Settings (gear icon โ top-left).
Click the Cloud Messaging tab.
Under Firebase Cloud Messaging API (V1), click the 3-dot menu โ Manage service accounts.
The old FCM Server Key (Legacy) is deprecated. Use the V1 API with a service account JSON instead.
In the IAM Service Accounts page, find the Firebase service account (it ends in @firebase-adminsdk-*.iam.gserviceaccount.com).
Click the service account โ Keys tab โ Add Key โ Create new key โ JSON โ Create.
Download the JSON file and place it securely on your server:
chmod 600 /var/docuwealth/fcm-key.json
Add the path to your server .env:
Then restart the API:
Confirm apps/mobile/google-services.json exists in the repo.
Install EAS CLI if not already installed:
eas login
Build a preview APK (internal distribution):
eas build --platform android --profile preview
EAS handles signing automatically. The APK download link is shown in the EAS dashboard when the build finishes (~10 min).
Install the APK on your Android device, open the app, log in โ you should be prompted to allow notifications. After granting permission, the device token is automatically sent to the server (PUT /api/users/fcm-token).
In Firebase Console go to Engage โ Messaging โ New campaign โ Firebase Notification messages.
Fill in Notification title and Text, then click Send test message.
Paste your device's FCM token (find it in the server DB) into the test field:
Click Test โ the notification should appear on your Android device within a few seconds.
Once working, all DocuWealth alerts (insurance renewals, EMI dues, FD maturity, etc.) will be delivered as push notifications automatically when the daily cron job runs at 08:00 IST.
| Item | What it is | Where it goes |
|---|---|---|
| google-services.json | Android app config โ downloaded from Firebase Console after registering the Android app | apps/mobile/google-services.json |
| fcm-key.json | Server service account key โ allows the API to send push messages via FCM V1 API | /var/docuwealth/fcm-key.json |
| FCM_SERVICE_ACCOUNT_PATH | Path to fcm-key.json โ read by the server at startup | .env on server |
| fcm_token (DB column) | Device token โ registered automatically when the user logs in on Android and grants notification permission | users.fcm_token in PostgreSQL |