Repository navigation
Development Environment Setup
This guide walks through setting up the local development environment for the LCFS project. It combines information from the original "01. Gettings Started" wiki page with current project structure and dependencies.
Before you begin, ensure you have the following installed on your system:
- Git: For cloning the repository and version control.
- Docker and Docker Compose: For running the application services in containers. (Install Docker, Docker Compose is typically included).
-
Node.js 24.21.0 and npm: Required for frontend development. Use
frontend/.nvmrcwith a Node version manager such asnvm;frontend/package.jsonenforces Node.js 24 or newer.- npm (Node Package Manager) is included with Node.js.
-
Python and Poetry: For backend development.
- Python version is specified in
backend/.python-version(e.g., 3.9+). - Poetry is used for Python dependency management. (Install Poetry).
- Python version is specified in
-
OpenShift CLI (
oc): Optional, but required for certain tasks like data transfer to/from OpenShift environments using scripts in theetl/directory. (Install OpenShift CLI).
Clone the LCFS repository to your local machine:
git clone https://github.com/bcgov/lcfs.git
cd lcfsThe main Docker Compose file starts the frontend, backend, PostgreSQL, Redis, and RustFS (S3-compatible object storage) services. A one-off create_bucket job creates the lcfs bucket once RustFS is healthy, and the backend starts after it finishes. Its default host ports are:
| Service | Published port | Override variable |
|---|---|---|
| PostgreSQL | 5432 | LCFS_DB_PUBLISHED_PORT |
| Redis | 6379 | LCFS_REDIS_PUBLISHED_PORT |
| RustFS S3 API | 9000 | LCFS_RUSTFS_PUBLISHED_PORT |
| RustFS console | 9001 | LCFS_RUSTFS_CONSOLE_PUBLISHED_PORT |
| Backend API | 8000 | LCFS_BACKEND_PUBLISHED_PORT |
| Backend debugger | 5678 | LCFS_BACKEND_DEBUG_PUBLISHED_PORT |
| Frontend | 3000 | LCFS_FRONTEND_PUBLISHED_PORT |
Start the default stack and check the API and frontend:
docker compose up --build -d
curl http://localhost:8000/api/health
open http://localhost:3000Follow backend logs from a separate terminal with docker compose logs -f backend.
Stop the default stack with:
docker compose downThe RustFS console (http://localhost:9001/rustfs/console/) signs in with the development access key and secret key from docker-compose.yml.
Local object storage moved from MinIO to RustFS in #5159. Files uploaded to the old MinIO volume are not migrated. After switching, remove that volume with docker volume rm lcfs_s3 (the prefix is your Compose project name).
To run an isolated stack, set alternate published ports in a dedicated terminal. Compose scopes its containers, volumes, and network to the supplied project name:
export LCFS_DB_PUBLISHED_PORT=15432
export LCFS_REDIS_PUBLISHED_PORT=16379
export LCFS_RUSTFS_PUBLISHED_PORT=19000
export LCFS_RUSTFS_CONSOLE_PUBLISHED_PORT=19001
export LCFS_BACKEND_PUBLISHED_PORT=18000
export LCFS_BACKEND_DEBUG_PUBLISHED_PORT=15678
export LCFS_FRONTEND_PUBLISHED_PORT=13000
docker compose -p lcfs-benchmark-1 up --build -d
curl http://localhost:18000/api/health
open http://localhost:13000Follow isolated backend logs with docker compose -p lcfs-benchmark-1 logs -f backend.
Stop only that isolated stack with:
docker compose -p lcfs-benchmark-1 downIf you need to work primarily on the frontend or run it independently:
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
This will also install Husky git hooks if configured (check
npm install
.husky/directory). -
Run the frontend development server:
The frontend will typically be available at
npm run dev
http://localhost:3000(as configured in Vite andpackage.json).
If you need to work primarily on the backend or run it independently:
-
Navigate to the backend directory:
cd backend -
Install dependencies using Poetry:
Ensure Poetry is installed and configured in your shell.
poetry install
-
Set up pre-commit hooks (recommended for code quality checks before committing):
Pre-commit hooks are configured in
poetry run pre-commit install
backend/.pre-commit-config.yamland typically run tools like Black, Flake8, MyPy, and Isort. -
Run the backend development server:
This command executes the
poetry run python -m lcfs
__main__.pyscript in thelcfspackage, which starts the Uvicorn server for the FastAPI application. The backend API will typically be available athttp://localhost:8000.
The ETL subsystem (Apache NiFi and related services) has its own Docker Compose setup for local development.
-
Navigate to the ETL directory:
cd etl -
Run ETL services:
This starts NiFi, NiFi Registry, Zookeeper, and the TFRS source database.
docker-compose up -d
-
Access NiFi UI:
http://localhost:8091/nifi/ -
Access NiFi Registry UI:
http://localhost:18080 - Refer to
etl/readme.mdor Data Migration (TFRS to LCFS) for instructions on loading NiFi templates and configuring database connections within NiFi.
-
VS Code: Recommended extensions for Python (Pylance, Python Test Explorer), JavaScript/React (ESLint, Prettier), Docker.
- Ensure your VS Code settings use the project's Python interpreter (managed by Poetry) and Node.js version.
- Other IDEs: Configure according to their specific instructions for Python/Poetry and Node.js/npm projects.
-
Backend: Core database and service connection details are often set via environment variables in
docker-compose.ymlfor local development. For running the backend separately, you might need to set these in your shell or a.envfile (checkbackend/lcfs/settings.pyfor how Pydantic settings loads them). -
Frontend: Environment variables for the frontend (e.g., API base URL if not relative, Keycloak settings) are typically managed via
.envfiles (e.g.,.env,.env.development) loaded by Vite. Checkfrontend/vite.config.jsand the application code. -
Cypress: E2E tests require
frontend/cypress.env.jsonfor test user credentials and other parameters. Create this by copyingfrontend/cypress.env.example.jsonand filling in the necessary values. Do not commitcypress.env.json.
This setup guide should provide a solid foundation for local development. Refer to specific README files in subdirectories (backend/README.md, frontend/README.md, etl/readme.md) for more detailed information on each component.