Skip to main content

Module map

marketplace-fleapoai-service/src/ directory listing, annotated.

Top-level files

FileRole
app.module.tsRoot module; wires middleware, global pipes, all feature modules
main.tsBootstrap, global pipes/interceptors/CORS, listens on PORT
seed.tsStandalone — creates initial platform admin via better-auth

Cross-cutting modules

PathRolePublic surface
config/AppConfigService — typed env vars, @Global() moduleinjected token AppConfigService
common/Shared types, interceptors, error mappingApiResponse<T>, error codes
db/Drizzle module providing DRIZZLE + PG_POOL tokens@Inject(DRIZZLE)
auth/better-auth wrapper, controllers, guards, permissions/api/auth/*, PlatformAdminGuard, etc.
logging/Audit log middleware + service + PostHog batcher(middleware)
stripe/Stripe SDK module — DI-provided Stripe clientinjected STRIPE
health//health controllerGET /health

Feature modules

agents

FileRole
agents.controller.tsCRUD endpoints
agents.service.tsBusiness logic; creates OAuth client at create time
dto/CreateAgentDto, UpdateAgentDto, QueryAgentDto, AgentDto

Endpoints (all under /agents): list, by-slug, by-id, create, update, delete, demo-request. See Concept: Agent.

capabilities

CRUD on agent_capabilities under /agents/:agentId/capabilities.

steps

CRUD on agent_steps under /agents/:agentId/steps.

changelog

CRUD on agent_changelog under /agents/:agentId/changelog.

pricing

FileRole
pricing.controller.tsTier CRUD + checkout
pricing.service.tsCreates Stripe Product+Price for paid tiers; archives on delete
tier-quotas.controller.tsPer-tier quota matrix endpoints
tier-quotas.service.tsReads/writes tier_metric_quotas
dto/CreateTierDto, etc.

Endpoints: /agents/:agentId/pricing/*, /agents/:agentId/pricing/:tierId/checkout, /agents/:agentId/pricing/:tierId/quotas/*.

metric-definitions

CRUD on agent_metric_definitions under /agents/:agentId/metric-definitions. slug and kind immutable.

subscriptions

FileRole
subscriptions.controller.ts/me/subscriptions/*, /agents/.../checkout
subscriptions.service.tsCheckout, list, get, cancel, webhook handlers helpers, returnUrl validation, interaction recording

usage

/me/agents/:agentId/usage[*]/consume/release + admin addon endpoints. Atomic transactional logic for quota arithmetic. See Concept: Metric & Quota.

webhooks

FileRole
stripe-webhook.controller.tsPOST /webhooks/stripe (raw body, signature header)
stripe-webhook.service.tsSignature verify, idempotent dispatch via stripe_events, per-event handlers

installs

POST /agents/:agentId/install. Idempotent UPSERT.

interactions

FileRole
interactions.controller.ts/admin/interactions/*
interactions.service.tsrecord() + recipient mgmt
interactions.singleton.tsApp-wide service singleton for fan-out emails

Despite the name, NOT runtime — see Concept: Interaction.

reviews

/agents/:agentId/reviews (list, upsert) + /reviews/:id (delete). Upsert via unique (agentId, userId).

tags

/tags list/create/delete. M:N via agent_tags.

waitlist

/agents/:agentId/waitlist + /agents/:agentId/waitlist/me. Idempotent email capture + auto-fans into interactions.

upload

File upload endpoint. Storage provider configured via env.

metrics

Public agent metrics aggregations (agent_metrics_daily). Read-only.

Module registration order

AppModule imports in this order:

  1. ConfigModule (global)
  2. DrizzleModule (global)
  3. AuthModule (provides AUTH token, requires DRIZZLE + AppConfigService)
  4. LoggingModule (audit batching)
  5. All feature modules
  6. WebhooksModule (depends on SubscriptionsModule)

Adding a new module

See Contribution → Adding a backend module.