Prerequisites
Before installing BD Scan Face, ensure you have the following installed on your system:Node.js
Version 18.x or higherRequired for running TypeScript and Prisma
Docker
Docker & Docker ComposeFor running PostgreSQL (recommended)
PostgreSQL
Version 15 or higherAlternative to Docker setup
Git
Latest versionFor cloning the repository
This guide covers installation for development environments. For production deployments, ensure you use secure credentials and follow PostgreSQL security best practices.
Installation Methods
Choose the installation method that best fits your workflow:Method 1: With Docker (Recommended)
The easiest way to get started is using Docker Compose, which automatically sets up PostgreSQL with the correct configuration.Install Dependencies
@prisma/client(v6.19.2) - Type-safe database client@prisma/adapter-pg(v7.4.2) - PostgreSQL adapter for Prismaprisma(v7.4.2) - Prisma CLI and migration toolstypescript(v5.9.3) - TypeScript compilertsx(v4.21.0) - TypeScript execution enginedotenv(v17.3.1) - Environment variable management
Configure Environment Variables
Create a
.env file in the project root:.env
These credentials match the Docker Compose configuration. You can customize them in both files if needed.
Start PostgreSQL
Launch the database container:The Docker setup includes:Check database health:
- PostgreSQL 15 on port 5432
- Automatic health checks
- Persistent data storage via Docker volumes
- Network isolation with
prisma-network
Method 2: With Existing PostgreSQL
If you already have PostgreSQL installed, you can connect to it directly.Configure Connection
Create a Replace
.env file with your database connection string:.env
username, password, and database name with your actual PostgreSQL credentials.Docker Compose Configuration
The includeddocker-compose.yml provides a production-ready PostgreSQL setup:
docker-compose.yml
Environment Variables
BD Scan Face uses environment variables for configuration. Here’s a complete reference:| Variable | Description | Required | Default |
|---|---|---|---|
DATABASE_URL | PostgreSQL connection string | Yes | - |
Connection String Format
user- Database usernamepassword- Database passwordhost- Database host (e.g.,localhost)port- Database port (default:5432)database- Database nameschema- PostgreSQL schema (default:public)
Connection Pooling
For production environments, consider adding connection pooling parameters:.env
Prisma Configuration
The project uses a custom Prisma configuration file (prisma.config.ts):
prisma.config.ts
- Automatically loads environment variables from
.env - Sets the schema location to
prisma/schema.prisma - Stores migrations in
prisma/migrations/ - Uses the
DATABASE_URLenvironment variable for connection
Database Schema Overview
After running migrations, your database will have the following structure:Tables Created
user_types - User Classification
user_types - User Classification
Stores different types of users (e.g., employee, visitor, contractor).
users - User Profiles
users - User Profiles
Complete user information with identification and contact details.
faces - Face Encodings
faces - Face Encodings
Stores face recognition encodings for each user.
devices - Access Control Devices
devices - Access Control Devices
Manages physical access control devices and scanners.
access_logs - Audit Trail
access_logs - Audit Trail
Complete history of all access attempts with confidence scores.
Verifying Your Installation
Run through this checklist to ensure everything is set up correctly:Troubleshooting
Database Connection Issues
Error: Can't reach database server
Error: Can't reach database server
Cause: PostgreSQL is not running or not accessible.Solution:
Error: Authentication failed
Error: Authentication failed
Cause: Incorrect database credentials in
.env.Solution:- Verify your
DATABASE_URLmatches the Docker Compose configuration - Ensure no extra spaces in the connection string
- Check that the password is correct
Error: Port 5432 already in use
Error: Port 5432 already in use
Cause: Another PostgreSQL instance is running on port 5432.Solution:
- Stop the other PostgreSQL instance, or
- Change the port in
docker-compose.ymlandDATABASE_URL
Prisma Client Issues
Error: Cannot find module './generated/prisma'
Error: Cannot find module './generated/prisma'
Cause: Prisma Client hasn’t been generated.Solution:
Type errors in TypeScript
Type errors in TypeScript
Cause: Prisma Client is out of sync with schema.Solution:
Next Steps
Quickstart Tutorial
Build your first queries in 5 minutes
Database Schema
Explore the complete schema and relationships
Prisma Client Guide
Learn how to use Prisma Client
Database Migrations
Learn how to modify your schema