Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Paramount-Intelligence/HR_Monitoring_System/llms.txt

Use this file to discover all available pages before exploring further.

The Workforce Intelligence & Execution OS local development environment consists of three concurrently running processes — the FastAPI backend, the Next.js 15 frontend, and the Celery background worker — backed by either a local SQLite database or PostgreSQL, and a Redis instance. This guide covers every step from prerequisites through environment configuration, service startup, database management, and resolving common development errors.

Prerequisites

Ensure the following are installed before proceeding:
ToolRequired VersionNotes
Node.jsv18.x or v20.xnode --version to verify
Python3.10 or 3.11python --version to verify
RedisLatest stableCan be run via Docker or as a local service
GitAny recent versionFor cloning and version control
PostgreSQL14+ (optional)SQLite is used by default locally
If you don’t want to install Redis locally, you can start it with a single Docker command: docker run -d -p 6379:6379 --name redis redis:latest

Environment Configuration

All configuration is managed via a single .env file in the repository root. Start by copying the example:
cp .env.example .env
The following table documents every variable in .env.example:

Frontend Variables (apps/web)

VariableDefaultDescription
NEXT_PUBLIC_APP_NAMEWorkforce Intelligence & Execution OSDisplay name shown in the browser tab and UI header
NEXT_PUBLIC_API_URL/api/v1Public-facing API base URL; Next.js proxies this to API_PROXY_URL locally
API_PROXY_URLhttp://localhost:8080/api/v1Internal proxy target — the FastAPI server address as seen by the Next.js server

Backend Variables (apps/api)

VariableDefaultDescription
APP_ENVdevelopmentRuntime environment; controls debug mode and logging verbosity
APP_HOST0.0.0.0Host binding for the Uvicorn server
APP_PORT8080Port for the FastAPI server
APP_SECRET_KEYchange-me-locallyRequired. Secret used to sign and verify JWT tokens. Must be a long random string.
ACCESS_TOKEN_EXPIRE_MINUTES15Lifetime of short-lived JWT access tokens
REFRESH_TOKEN_EXPIRE_DAYS7Lifetime of JWT refresh tokens
ONLINE_PRESENCE_TTL_SECONDS90User is considered online if a heartbeat was received within this window (seconds)

Database Variables

VariableDefaultDescription
DATABASE_URLpostgresql://postgres:postgres@localhost:5432/workforce_intelligence_utf8SQLAlchemy connection string. Comment out to use the SQLite fallback.
DATABASE_PUBLIC_URL(empty)Public-facing database URL for Railway or other cloud deployments
PGDATABASEworkforce_intelligence_utf8PostgreSQL database name
PGHOSTlocalhostPostgreSQL host
PGPORT5432PostgreSQL port
PGUSERpostgresPostgreSQL user
PGPASSWORDpostgresPostgreSQL password
PostgreSQL databases must use UTF-8 encoding to support emoji and Unicode content in messages. Create the database with:
CREATE DATABASE workforce_intelligence_utf8
  WITH ENCODING 'UTF8'
  TEMPLATE template0
  LC_COLLATE='C'
  LC_CTYPE='C';
To use SQLite for local development with zero database setup, comment out the DATABASE_URL line in your .env file. The backend automatically falls back to a local workforce_intelligence.db file.

Redis & Celery

VariableDefaultDescription
REDIS_URLredis://localhost:6379/0Redis connection string used by Celery as its message broker

CORS & Frontend Origin

VariableDefaultDescription
FRONTEND_BASE_URLhttp://localhost:3002Base URL of the frontend, used for generating links in emails
CORS_ORIGINShttp://localhost:3000,...Comma-separated list of allowed CORS origins for the FastAPI backend

Email (Optional Locally)

VariableDefaultDescription
SMTP_TLSTrueEnable TLS for SMTP connections
SMTP_PORT587SMTP server port
SMTP_HOST(empty)SMTP server hostname (leave empty to disable email locally)
SMTP_USER(empty)SMTP authentication username
SMTP_PASSWORD(empty)SMTP authentication password
EMAILS_FROM_EMAIL[email protected]Sender address for outgoing emails
EMAILS_FROM_NAMEWorkforce OSSender display name for outgoing emails

Bootstrap Admin

VariableDefaultDescription
BOOTSTRAP_ADMIN_EMAIL[email protected]Email address of the auto-created first admin user
BOOTSTRAP_ADMIN_PASSWORDchange-this-passwordPassword for the bootstrap admin. Change this before any shared deployment.
BOOTSTRAP_ADMIN_NAMEHR AdminDisplay name for the bootstrap admin user

Profile Storage

VariableDefaultDescription
PROFILE_IMAGE_STORAGElocalStorage backend for profile pictures. local stores files on disk.
PROFILE_IMAGE_UPLOAD_DIRstorage/profile-picturesLocal directory path for uploaded profile images
PROFILE_IMAGE_PUBLIC_BASE_URL(empty)Public base URL for serving stored profile images

Attendance & Timezone

VariableDefaultDescription
BUSINESS_TIMEZONEAsia/KarachiIANA timezone used for shift windows, roster management, and end-of-day processing

Web Push (Optional)

VariableDefaultDescription
VAPID_PUBLIC_KEY(empty)VAPID public key for browser push notifications
VAPID_PRIVATE_KEY(empty)VAPID private key for browser push notifications
VAPID_SUBJECT(empty)Contact email for VAPID, e.g. mailto:[email protected]
Generate VAPID keys with:
npx web-push generate-vapid-keys

Backend Setup

1

Navigate to the API directory

cd apps/api
2

Create and activate a virtual environment

python -m venv venv
source venv/bin/activate
3

Install Python dependencies

pip install -r requirements.txt
This installs all backend packages including fastapi, uvicorn, sqlalchemy, alembic, celery, redis, psycopg2-binary, and pydantic v2.
4

Start the API server

uvicorn app.main:app --host 0.0.0.0 --port 8080
The API is available at http://localhost:8080. Swagger UI is at http://localhost:8080/docs.

Database Initialisation & Seeding

1

Run Alembic migrations

From the apps/api directory with your virtual environment active:
alembic upgrade head
This creates all database tables and applies any pending schema migrations.
2

Seed the database (optional)

Load reference and sample data:
python seed.py
3

Bootstrap admin auto-creation

The API automatically seeds permissions and creates the bootstrap admin user on first startup using the BOOTSTRAP_ADMIN_EMAIL and BOOTSTRAP_ADMIN_PASSWORD values in your .env file. No manual step is needed.

Frontend Setup

1

Install dependencies from the monorepo root

# From the repository root
npm install
npm workspaces installs dependencies for apps/web and all shared packages/ in one command.
2

Start the Next.js development server

npm run dev:web
The web application is available at http://localhost:3000.

Worker Setup (Celery)

1

Ensure Redis is running

redis-server
2

Start the Celery worker

From the apps/api directory with your virtual environment active:
celery -A app.worker worker --loglevel=info
The --pool=solo flag is required on Windows because Celery’s default prefork multiprocessing pool is not fully supported. On macOS and Linux, omit this flag.

Useful Development Commands

Frontend

CommandWhat it does
npm run dev:webStart Next.js dev server (from repo root)
npm run build:webProduction build of the web app
cd apps/web && npm run lintRun ESLint on the frontend codebase
cd apps/web && npm testRun the frontend test suite

Backend

CommandWhat it does
uvicorn app.main:app --host 0.0.0.0 --port 8080Start the FastAPI server (from apps/api)
alembic upgrade headApply all pending migrations (from apps/api)
alembic revision --autogenerate -m "description"Generate a new migration from model changes
flake8Run Python linting (from apps/api)

Database Reset (SQLite)

To fully reset the local SQLite database:
# From apps/api
rm workforce_intelligence.db
alembic upgrade head
# Restart the API — bootstrap admin is recreated on startup

Common Errors and Fixes

Always ensure all three services (API, worker, Redis) are running before testing end-to-end flows. Many errors are caused by a partially started stack.

ChunkLoadError in the Browser

Symptom: The Next.js frontend throws a ChunkLoadError after a code change or interrupted build. Cause: Stale or corrupted .next build cache. Fix:
cd apps/web
rm -rf .next
npm run dev

Redis Connection Refused

Symptom: The Celery worker fails to start or background jobs are not processed. Error message includes redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Cause: The Redis server is not running, or REDIS_URL in .env is incorrect. Fix:
  1. Start Redis: redis-server or docker run -d -p 6379:6379 redis
  2. Verify the REDIS_URL in your .env matches where Redis is listening:
    REDIS_URL=redis://localhost:6379/0
    

Database Locked (SQLite)

Symptom: SQL errors mentioning database is locked when performing write operations. Cause: SQLite does not support concurrent writes. When both the API server and the Celery worker attempt to write simultaneously, one process will be blocked. Fix: Restart both the API server and the Celery worker. For persistent concurrent write needs, switch to PostgreSQL by setting DATABASE_URL in your .env.

APP_SECRET_KEY Not Set

Symptom: JWT token signing fails; login returns 500 errors immediately after startup. Cause: APP_SECRET_KEY is still set to the placeholder value change-me-locally or is missing. Fix: Set a strong, unique secret in your .env:
APP_SECRET_KEY=a-long-random-string-at-least-32-characters

CORS Errors in the Browser

Symptom: API requests from the frontend fail with Access-Control-Allow-Origin errors in the browser console. Cause: The frontend’s origin (http://localhost:3000) is not listed in CORS_ORIGINS. Fix: Ensure the frontend URL is included in .env:
CORS_ORIGINS=http://localhost:3000,http://localhost:3001,http://localhost:3002,http://127.0.0.1:3000

Build docs developers (and LLMs) love