A data transformation tool that fetches content from the Jesus Film API and builds local databases for offline use in iOS and Android applications.
JFP App Cache Builder is a Node.js application that:
- Connects to the Jesus Film API Gateway (
https://api-gateway.central.jesusfilm.org) - Fetches various types of content data (languages, media items, countries, etc.)
- Transforms the data into a structured format
- Stores it in a local database file:
- iOS: Realm database (
apps/tool/assets/ios/cache.realm) - Android: SQLite database (
apps/tool/assets/android/cache.db)
- iOS: Realm database (
This database can then be used by iOS and Android applications to provide offline access to Jesus Film content.
- Node.js 18+
- pnpm (recommended) or npm
- Access to the Jesus Film API Gateway
-
Install dependencies:
pnpm install
-
Run the data transformation:
# Using Nx commands for iOS pnpm nx run tool:cli -- --target ios # Using Nx commands for Android pnpm nx run tool:cli -- --target android
This will:
- Fetch data from the Jesus Film API
- Transform it into the required format
- Save it to the appropriate database file based on the target
pnpm build- Build all applicationspnpm test- Run all testspnpm lint- Check code for linting issues across all appspnpm lint:fix- Fix linting issues automaticallypnpm format- Format code with Prettierpnpm format:check- Check if code is properly formattedpnpm type-check- Type check all applications
pnpm nx run tool:cli -- --target ios- Run CLI tool for iOSpnpm nx run tool:cli -- --target android- Run CLI tool for Androidpnpm nx run tool:export-dbs- Export database contents to JSON filespnpm nx run tool:prisma-generate- Generate Prisma clientpnpm nx run tool:test- Run the test suite for the toolpnpm nx run tool:lint- Lint the tool codepnpm nx run tool:type-check- Type check the tool code
pnpm nx run website:build- Build the Next.js site for productionpnpm nx run website:serve- Start the development serverpnpm nx run website:export- Export static websitepnpm nx run website:test- Run tests for the websitepnpm nx run website:lint- Lint the website codepnpm nx run website:type-check- Type check the website code
This is an Nx monorepo with two applications:
apps/
├── tool/ # CLI tool for building databases
│ ├── src/ # Source code
│ ├── assets/ # Database files
│ ├── prisma/ # Database schema
│ ├── scripts/ # Export scripts
└── website/ # Next.js database browser
├── app/ # Next.js app directory
├── components/ # React components
└── public/ # Static assets
This project uses GitHub Actions for continuous integration and deployment:
Runs on every push to main and pull request:
- Code Formatting: Checks if code follows Prettier formatting standards
- Linting: Runs ESLint to check for code quality issues
- Build: Compiles TypeScript and generates build artifacts
- Testing: Runs the complete test suite
- Artifact Verification: Ensures build artifacts are created correctly
Runs on pushes to main and manual triggers:
- iOS Cache Build: Generates iOS Realm database with all content
- Android Cache Build: Generates Android SQLite database with all content
- Artifact Upload: Uploads cache files as GitHub artifacts
- ✅ CI: All checks must pass before cache builds
- ✅ Build: Cache builds only run if CI passes
- ✅ Parallel: iOS and Android builds run in parallel
- ✅ Caching: Uses pnpm and Node.js caching for faster builds
The tool generates database files containing:
- Bible Codes - Bible book information and metadata
- Languages - Language data with audio previews and speaker counts
- Countries - Country information and relationships
- Media Items - Video content with descriptions, images, and metadata
- Media Categories - Content categorization
- Reading Language Data - Language-specific content bundles
- Suggested Languages - Recommended languages for different regions
The tool uses the following default configuration:
- Language ID:
529(English) - API Endpoint:
https://api-gateway.central.jesusfilm.org - Database Path:
apps/tool/assets/cache.realm(iOS) orapps/tool/assets/cache.db(Android)
-
API Connection Errors
- Ensure you have network access to
https://api-gateway.central.jesusfilm.org - Check if the API is available and responding
- Ensure you have network access to
-
Database Write Errors
- Ensure the
apps/tool/assets/directory exists and is writable - Check if the database file is not locked by another process
- Ensure the
-
Memory Issues
- The tool processes large amounts of data; ensure sufficient RAM is available
- Consider running with
--max-old-space-size=4096if needed
The application uses structured logging with Pino. Logs include:
- Transformation progress
- Data counts
- Error details
- Performance metrics
The project includes a Next.js web application for browsing the generated database contents:
- Interactive Database Browser: Explore Android SQLite and iOS Realm database contents
- Table/Schema Navigation: Left sidebar with all available tables and schemas
- Data Visualization: Responsive table view with search and pagination
- Binary Data Handling: Special handling for iOS Realm Buffer fields with download functionality
- Modern UI: Built with Next.js, TypeScript, and Tailwind CSS
The database browser is automatically deployed to GitHub Pages when the build workflow runs. You can access it at your GitHub Pages URL.
To run the database browser locally:
-
Build the databases first:
pnpm nx run tool:cli -- --target ios pnpm nx run tool:cli -- --target android
-
Export database data:
pnpm nx run tool:export-dbs
-
Start the development server:
pnpm nx run website:serve
-
Open your browser: Navigate to
http://localhost:3000
The database browser uses pre-processed JSON files generated at build time:
- Android Data:
apps/website/public/data/android/- Contains all SQLite table data - iOS Data:
apps/website/public/data/ios/- Contains all Realm schema data
These files are automatically generated by the export scripts and included in the GitHub Pages deployment.
For issues or questions:
- Check the logs for error details
- Ensure all prerequisites are met
- Verify API access and network connectivity
- Contact the development team for additional support