Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Priyanshu471/ad-management/llms.txt

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

The Finances panel at /admin/finances is the planned administrative view for monitoring all monetary activity on the Ad Management System. In its current state the route renders a placeholder. Budget data for every campaign is already stored in MongoDB and is accessible through the existing GET /api/campaign endpoint, which will power this panel once the front-end is built.

Route

/admin/finances

Current Implementation

The page component currently renders a single placeholder element:
const Finances = () => {
  return <div>Finances</div>;
};
export default Finances;
The Finances UI is planned for a future iteration. All budget data required to populate it is available through the campaigns API.

Planned Financial Metrics

The following metrics are planned for the Finances panel, derived from fields already present on every campaign document:

Total Ad Spend

The sum of all budget values across every campaign in the database, regardless of status.

Per-Advertiser Breakdown

Budget totals grouped by the user reference on each campaign, showing allocation across each advertiser’s portfolio.

Budget by Campaign Status

Distribution of total budget split across Active, Live, and End campaigns.

Platform Earnings Overview

A high-level revenue summary derived from campaign budget data to support platform-level financial reporting.

Relevant Campaign Data Model Fields

The financial metrics above will be computed from fields on the campaign schema in models/campaign.ts:
FieldTypeDescription
budgetStringThe allocated budget for the campaign
statusStringActive, Live, End, or Deleted — determines spend state
userObjectIdReference to the User document who owns the campaign
durationStringCampaign duration, used to contextualize spend over time

Aggregating Budget Data

Budget figures can be derived from the existing GET /api/campaign endpoint without a dedicated financial endpoint. The pattern below shows how total platform spend can be computed from the response:
const res = await fetch("/api/campaign");
const { campaigns } = await res.json();

// Total spend across all campaigns
const totalBudget = campaigns.reduce(
  (sum: number, c: any) => sum + parseFloat(c.budget),
  0
);

// Per-advertiser spend
const byAdvertiser = campaigns.reduce((acc: any, c: any) => {
  const userId = c.user;
  acc[userId] = (acc[userId] ?? 0) + parseFloat(c.budget);
  return acc;
}, {});

// Spend by status
const byStatus = campaigns.reduce((acc: any, c: any) => {
  acc[c.status] = (acc[c.status] ?? 0) + parseFloat(c.budget);
  return acc;
}, {});
The Finances page (/admin/finances) currently renders a placeholder. All budget data needed to power the financial metrics above is available through GET /api/campaign and is ready to be consumed once the front-end build is complete.

Build docs developers (and LLMs) love