The Mautic Marketplace is a robust system engineered to enhance the Mautic ecosystem, offering a scalable platform for discovering, rating and reviewing Mautic plugins and themes.
At its core, this backend leverages the Packagist API for comprehensive package data acquisition, persisting it within a Supabase (PostgreSQL) database. This architecture is designed to overcome direct Packagist API rate limits and structural constraints, enabling real-time data synchronization, sophisticated filtering capabilities and the foundational elements for future community-driven features like ratings and reviews.
Ensure the following tools are installed on your system:
- Git
- Deno:
For macOS (Homebrew):
For other platforms (Shell Script):
brew install deno
curl -fsSL [https://deno.land/install.sh](https://deno.land/install.sh) | sh
- Supabase CLI:
For macOS (Homebrew):
(For other platforms, refer to the Supabase CLI Installation Guide.)
brew install supabase/tap/supabase
- Docker Desktop: Ensure Docker Desktop is running as it's required for Supabase Edge Function deployment and local services.
- Create a new project on Supabase.com. Securely note your database password.
- Retrieve your Project ID (Reference ID) from
Project Settings
>General Settings
. - Copy your API Keys (
anon public
,service_role
) fromProject Settings
>API
.
- Clone the repository and navigate into it:
git clone https://github.com/mautic/mautic-marketplace.git
- Go to the project directory
cd mautic-marketplace
- Configure local environment variables. These are crucial for local Deno execution.
Edit the
cp .env.dist .env
.env
file to setSUPABASE_URL
(e.g.,https://your-project-id.supabase.co
) andSUPABASE_SERVICE_ROLE_KEY
.
- Authenticate the Supabase CLI with your account:
supabase login
- Initialize the local Supabase project structure:
supabase init
- Update
supabase/config.toml
by setting theproject_id
field. - Link your local project to your cloud project. Before copying, replace
YOUR_ACTUAL_PROJECT_ID
with your Supabase Project ID.Provide your database password if prompted.supabase link --project-ref YOUR_ACTUAL_PROJECT_ID
- Deploy the
fetch_package
Edge Function to your Supabase project. Ensure Docker Desktop is active.supabase functions deploy fetch_package
- Push local database schema migrations to your remote Supabase database:
supabase db push
Automate the execution of your fetch_package
Edge Function using PostgreSQL's built-in pg_cron
extension for continuous data updates.
- In your Supabase Dashboard, navigate to
Database
>Extensions
and Enable bothpg_cron
andpg_net
. - Retrieve your
fetch_package
Edge Function Invoke URL and your project's Service Role Key. - Schedule the cron job in Supabase Dashboard >
SQL Editor
. Before copying, ensure you replaceYOUR_EDGE_FUNCTION_URL
andYOUR_SERVICE_ROLE_KEY
within the SQL.-- To temporarily stop or remove the schedule: -- SELECT cron.unschedule('invoke-function-every-minute'); SELECT cron.schedule( 'invoke-function-every-minute', '* * * * *', -- Schedule: Runs every minute (adjust for production needs) $$ SELECT net.http_post( url:='YOUR_EDGE_FUNCTION_URL', headers:='{"Content-Type": "application/json", "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY"}'::jsonb, body:=concat('{"time": "', now(), '"}')::jsonb ) AS request_id; $$ );
- Confirm execution by checking for new log entries under Supabase Dashboard >
Edge Functions
>fetch_package
>Logs
.
Execute the fetch_package
function directly on your machine for debugging or one-off data processing. Before copying, replace YOUR_PROJECT_ID
and YOUR_SERVICE_ROLE_KEY
with your actual values.
SUPABASE_URL="https://YOUR_PROJECT_ID.supabase.co" \
SUPABASE_SERVICE_ROLE_KEY="YOUR_SERVICE_ROLE_KEY" \
deno run --allow-env --allow-read --allow-net supabase/functions/fetch_package/index.ts
Run unit tests for your Deno functions. The --no-check
flag skips TypeScript type-checking for faster execution.
🔧 Replace
YOUR_PROJECT_ID
andYOUR_SERVICE_ROLE_KEY
with your actual Supabase credentials.
SUPABASE_URL="https://YOUR_PROJECT_ID.supabase.co" \
SUPABASE_SERVICE_ROLE_KEY="YOUR_SERVICE_ROLE_KEY" \
deno test --allow-env --allow-read --allow-net --no-check supabase/functions/tests/index_test.ts
Get the Anon key from Project Settings > API.
You can find the Database Functions under Database > Database Functions
GET https://PROJECT_ID.supabase.co/rest/v1/rpc/get_view?apikey=ANON_KEY&_limit=30&_offset=0&_orderby=name&_orderdir=asc&_type=&_query=
GET https://PROJECT_ID.supabase.co/rest/v1/rpc/get_pack?apikey=ANON_KEY&packag_name=acquia/mc-cs-plugin-custom-objects