Set up a developer environment
Set up your local development environment to start developing and testing the Metadata Capture application.
In this guide
Prerequisites
Clone the repository
Set up the backend environment
Set up the frontend environment
Run the app locally
Prerequisites
Ensure you have the following tools installed on your development machine:
- Git: Version control system for cloning the repository
- Python 3.12: For running the backend services
- Node.js 20.x: For frontend development and build tools
- Docker: For running local services (database, authentication)
- Redis (optional but required for background jobs): Task queue broker/back-end
Clone the repository
-
Clone the Metadata Capture repository to your local machine:
git clone git@gitlab.com:lnds-lu/service-library/dca-metadata-capture.git
cd dca-metadata-capture -
Install pre-commit hooks to maintain code quality:
pre-commit install
Set up the backend environment
The backend is built with Python.
-
Install Python 3.12 using pyenv:
pyenv install 3.12 -
Create and activate a virtual environment in the backend directory:
python -m venv venv
source venv/bin/activate -
Install backend dependencies:
pip install -r requirements.txt -
Configure environment variables:
cp .env.<example> .envFor first-time setup, edit the
.envfile to include:LOAD_INITIAL_DATA=TrueInitial data loadingThe
LOAD_INITIAL_DATAflag loads initial data into the database during the first migration. Make sure you disable this flag in your subsequent migrations to prevent data conflicts. Read more about seeding initial data. -
Initialise the database:
alembic upgrade head
Run background jobs
Some features rely on Celery workers. To run background jobs locally you need Redis and two Celery processes (worker + beat scheduler).
-
Install and start Redis
-
macOS (Homebrew)
brew install redis
brew services start redis -
Windows (Chocolatey, PowerShell as Administrator)
choco install redis-64
Start-Service redis
-
-
Start Celery worker and beat
cd app
source venv/bin/activate
# Load environment variables
export CELERY_BROKER_URL=redis://localhost:6379/0
export CELERY_RESULT_BACKEND=redis://localhost:6379/1
# Start worker (processes tasks)
celery -A jobs worker --loglevel=infoIn a second terminal:
cd app
source venv/bin/activate
export CELERY_BROKER_URL=redis://localhost:6379/0
export CELERY_RESULT_BACKEND=redis://localhost:6379/1
# Start Beat scheduler (separate process)
celery -A jobs beat --loglevel=info
Set up the frontend environment
The frontend is built with React, TypeScript, and Vite.
Install frontend dependencies:
cd app/client/
npm install
Run the app locally
Run the Metadata Capture app locally to verify that your development environment is correctly configured:
-
Start the backend server:
python main.pyThe backend starts on
http://localhost:8000. -
In a new terminal, start the frontend development server:
cd app/client/
npm run devThe frontend starts on
http://localhost:5173. Open this URL in your browser to access the Metadata Capture application.
Your development environment is now set up. Next, set up local authentication for the app to function fully.