Interactive GraphQL API documentation with playground and AI assistant.
Key Features:
- Interactive Schema Explorer - Browse all queries, mutations, and types
- GraphiQL Playground - Test queries with full autocompletion
- AI Query Assistant - Natural language to GraphQL query generation (powered by Knowledge Base)
- Comprehensive Guides - Quickstart, authentication, rate limits, pagination, error handling
┌─────────────────────────────────────────────────────────────────────────────┐
│ MEDIAJEL DOCS ARCHITECTURE │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ mediajel-gql-service│ │ knowledge-sync │ │ Notion KB │
│ │ │ │ │ │
│ schema.graphql │ │ Fetches pages │◄────│ Company, Product, │
│ prisma.graphql │ │ Extracts content │ │ Technical, Ops... │
│ │ │ │ Uploads to OpenAI │ │ │
│ ▼ │ │ │ │ └─────────────────────┘
│ generate-public-api│ │ ▼ │
│ │ │ │ OpenAI Vector Store│
│ ▼ │ │ OpenAI Assistant │
│ public-schema.graphql │ │ │
│ public-api-config.json └─────────┼───────────┘
│ │ │ │
└─────────┼───────────┘ │
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ mediajel-gql-docs (Next.js) │
├─────────────────────────────────────────────────────────────────────────────┤
│ src/content/ │ src/app/api/chat/ │
│ ├── public-schema.graphql │ └── Queries OpenAI Assistant │
│ └── public-api-config.json │ with file_search (RAG) │
├─────────────────────────────────────────────────────────────────────────────┤
│ Schema Explorer │ GraphiQL Playground │ AI Assistant │ Guides │
└─────────────────────────────────────────────────────────────────────────────┘
The system has two parallel pipelines that feed into the docs app:
mediajel-gql-service S3 Bucket mediajel-gql-docs
│ │ │
▼ │ │
generate-public-api │ │
│ │ │
▼ ▼ ▼
public-schema.graphql ──────► mj-creatives/ src/content/public-schema.graphql
public-api-config.json ──────► public-api-schema/ ──────► src/content/public-api-config.json
(upload) (yarn sync-schema)
Purpose: Powers Schema Explorer, GraphiQL Playground, and query autocompletion.
S3 Bucket Details:
- Dojo Bucket:
mj-creatives→s3://mj-creatives/public-api-schema/ - Production Bucket:
mj-creatives-production→s3://mj-creatives-production/public-api-schema/ - Files:
public-schema.graphql,public-api-config.json
Notion KB ──────► knowledge-sync ──────► OpenAI Vector Store
│
▼
OpenAI Assistant (GPT-4 + RAG)
│
▼
/api/chat route
│
▼
AI Query Assistant UI
Purpose: Powers the AI assistant with company/product knowledge for contextual responses.
The GraphQL API uses AWS Cognito for authentication. Here's the flow:
┌─────────────────────────────────────────────────────────────────────────────┐
│ AUTHENTICATION FLOW │
└─────────────────────────────────────────────────────────────────────────────┘
1. User calls authSignIn mutation with username/password
│
▼
2. gql-service authenticates with AWS Cognito
│
▼
3. Returns: accessToken, idToken, refreshToken
│
▼
4. All subsequent requests use:
• Header: Authorization: Bearer <accessToken>
• Header: Key: <organizationId>
mutation {
authSignIn(input: {
username: "user@example.com"
password: "yourPassword"
}) {
accessToken
idToken
refreshToken
}
}| Header | Value | Description |
|---|---|---|
Authorization |
Bearer <accessToken> |
JWT token from sign in |
Key |
<organizationId> |
Organization context for queries |
The GraphiQL playground can be embedded in other applications (e.g., mediajel-dashboard) via iframe with automatic authentication.
┌─────────────────────────────────────────────────────────────────────────────┐
│ EMBEDDABLE USAGE FLOW │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ mediajel-dashboard (localhost:3000) │
│ │
│ ┌───────────────────────────────────────┐ │
│ │ ApiDocsView Component │ │
│ │ │ │
│ │ • Fetch JWT from Auth.currentSession │ │
│ │ • Build iframe URL with params │ │
│ │ • Render iframe │ │
│ └───────────────────────────────────────┘ │
│ │ │
└─────────────────────┼───────────────────────┘
│
▼
┌──────────────────────────────┐
│ iframe (full viewport) │
│ │
│ src: http://localhost:3006 │
│ /playground? │
│ embedded=true& │
│ token=JWT& │
│ orgId=ORG_ID │
└──────────────┬───────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ mediajel-gql-docs (localhost:3006) │
│ │
│ 1. Middleware detects ?embedded=true │
│ → Sets mediajel_embedded=true cookie │
│ │
│ 2. EmbedAuthBridge reads URL params │
│ → Injects token + orgId into localStorage │
│ │
│ 3. Playground auto-authenticates │
│ → Reads from localStorage │
│ → No login form shown │
│ │
│ 4. Full UI rendered (header, sidebar, etc.) │
└─────────────────────────────────────────────────────────────────────────────┘
| Parameter | Required | Description |
|---|---|---|
embedded |
Yes | Set to true to enable embedded mode |
token |
Yes | JWT access token from parent app |
orgId |
Yes | Organization ID for API context |
<iframe
src="http://localhost:3006/playground?embedded=true&token=JWT_TOKEN&orgId=ORG_ID"
style="width: 100%; height: 100vh; border: none;"
title="API Playground"
/>const ApiDocsView = () => {
const [iframeUrl, setIframeUrl] = useState<string | null>(null);
useEffect(() => {
const buildUrl = async () => {
const session = await Auth.currentSession();
const token = session.getAccessToken().getJwtToken();
const orgId = getCurrentOrgId();
const url = new URL('http://localhost:3006/playground');
url.searchParams.set('embedded', 'true');
url.searchParams.set('token', token);
url.searchParams.set('orgId', orgId);
setIframeUrl(url.toString());
};
buildUrl();
}, []);
if (!iframeUrl) return <Loading />;
return (
<iframe
src={iframeUrl}
style={{ width: '100%', height: '100vh', border: 'none' }}
title="API Playground"
/>
);
};Follow these phases in order. Each phase must complete before the next begins.
Time: ~2 minutes | Prerequisite: Node 18
cd mediajel-gql-service
nvm use 18
yarn install
# For dojo environment (default)
yarn generate-public-api
# For staging environment
yarn generate-public-api:staging
# For production environment
yarn generate-public-api:productionThis runs four steps:
generate-public-schema.ts→public-schema.graphqlgenerate-public-config.ts→public-api-config.jsongenerate-org-scope-config.ts→org-scope-config.tsupload-to-s3.ts→ Uploads files to S3
Output files (in src/webapp/public-api/):
public-schema.graphql- All public queries/mutations/types (~15,000 lines)public-api-config.json- Category mappings, descriptions, examples
S3 Upload: Files are automatically uploaded to the appropriate bucket:
- Dojo:
s3://mj-creatives/public-api-schema/ - Production:
s3://mj-creatives-production/public-api-schema/
Time: ~5 minutes | Prerequisite: Notion & OpenAI API keys
Skip this phase if you only need Schema Explorer and Playground without AI features.
cd knowledge-sync
yarn install
cp .env.example .env
# Edit .env with:
# NOTION_SECRET=<your-notion-integration-key>
# NOTION_ROOT_PAGE_ID=<your-kb-root-page-id>
# OPENAI_API_KEY=<your-openai-key>
yarn syncOutput (save these for Phase 3):
OPENAI_ASSISTANT_ID- Printed to consoleOPENAI_VECTOR_STORE_ID- Printed to console
Time: ~2 minutes | Prerequisite: Node 18, Phases 1 & 2 complete
cd mediajel-gql-docs
nvm use 18
yarn install
cp .env.example .env.localEdit .env.local:
# Required
NEXT_PUBLIC_GQL_ENDPOINT=http://localhost:4000
OPENAI_API_KEY=sk-your-api-key
# From Phase 2 (required for AI assistant)
OPENAI_ASSISTANT_ID=asst_xxxxx
OPENAI_VECTOR_STORE_ID=vs_xxxxx
# Optional - for KB sync scripts
NOTION_SECRET=secret_xxxxx
NOTION_ROOT_PAGE_ID=xxxxxSync the schema from S3:
# Environment-specific sync (recommended)
yarn sync-schema:dojo # Sync from mj-creatives bucket
yarn sync-schema:production # Sync from mj-creatives-production bucket
yarn sync-schema:local # Sync from local filesystem
# Or use base command with env vars (for CI/CD)
yarn sync-schemayarn devAccess at: http://localhost:3006
| Requirement | Version | Used For |
|---|---|---|
| Node.js | 18+ | mediajel-gql-service & mediajel-gql-docs (use nvm use 18) |
| Yarn | 1.x | Package manager for all projects |
| OpenAI API Key | - | AI assistant feature |
| Notion API Key | - | Knowledge Base sync (optional) |
| AWS Credentials | - | S3 schema sync (read access to mj-creatives bucket) |
| Variable | Required | Description | Example |
|---|---|---|---|
NEXT_PUBLIC_GQL_ENDPOINT |
Yes | GraphQL API URL for playground | http://localhost:4000 |
OPENAI_API_KEY |
Yes | OpenAI API key for AI assistant | sk-... |
OPENAI_ASSISTANT_ID |
For AI | Assistant ID from knowledge-sync | asst_... |
OPENAI_VECTOR_STORE_ID |
For AI | Vector store ID from knowledge-sync | vs_... |
NOTION_SECRET |
For KB sync | Notion integration API key | secret_... |
NOTION_ROOT_PAGE_ID |
For KB sync | Root KB page ID in Notion | Page ID |
NOTION_PARENT_PAGE_ID |
For KB build | Parent page for new KB creation | Page ID |
| Variable | Required | Description | Example |
|---|---|---|---|
SCHEMA_SOURCE |
No | Schema source: s3 (default) or local |
s3 |
CREATIVE_BUCKET_NAME |
For S3 | S3 bucket name (mj-creatives for dojo, mj-creatives-production for prod) |
mj-creatives |
CREATIVE_BUCKET_REGION |
For S3 | AWS region | us-east-1 |
PUBLIC_API_SCHEMA_NAME |
For S3 | S3 directory name | public-api-schema |
| Environment | Endpoint |
|---|---|
| Local Development | http://localhost:4000 |
| Dojo (Staging) | https://api-dojo.mediajel.io |
| Production | https://api.mediajel.com |
The AI assistant uses a Knowledge Base synced from Notion to OpenAI for contextual, accurate responses.
┌──────────────┐ ┌──────────────┐ ┌──────────────────────────┐
│ │ │ │ │ │
│ mediajel.com │──────▶│ Notion │──────▶│ OpenAI Vector Store │
│ (Source) │ scrape│ Knowledge Base│ sync │ (File Search Index) │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └────────────┬─────────────┘
│
▼
┌───────────────────────┐
│ OpenAI Assistant │
│ (GPT-4 + RAG) │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ /api/chat Route │
│ (mediajel-gql-docs) │
└───────────────────────┘
| Section | Content |
|---|---|
| Company | Mission, values, leadership team |
| Product | DemoGraph, MediaJel Buyer, DataJel, Search Lights pricing |
| Technical | Attribution methodology, advertising channels, integrations |
| Operations | Cannabis compliance playbook, FAQs |
| Sales & Marketing | Target industries, case studies, competitive analysis |
| Services | Dispensary marketing, agency services |
# Option 1: Edit content in Notion, then sync
yarn sync:knowledge
# Option 2: Rebuild entire KB from scratch
yarn build:kb
# Copy the outputted NOTION_ROOT_PAGE_ID to .env.local
yarn sync:knowledge| Command | Description |
|---|---|
yarn dev |
Start dev server on port 3006 |
yarn start:watch |
Dev server + auto-sync schema on file changes |
yarn build |
Sync schema + build production bundle |
yarn start |
Start production server |
yarn sync-schema |
Sync schema from S3 (requires env vars) |
yarn sync-schema:dojo |
Sync schema from dojo bucket (mj-creatives) |
yarn sync-schema:production |
Sync schema from production bucket (mj-creatives-production) |
yarn sync-schema:local |
Sync schema from local filesystem |
yarn sync:knowledge |
Sync Notion KB to OpenAI |
yarn build:kb |
Create KB structure in Notion |
yarn lint |
Run ESLint |
mediajel-workspace/
├── mediajel-gql-service/ # GraphQL API backend (source of truth)
│ └── src/webapp/public-api/
│ ├── public-schema.graphql # Auto-generated
│ ├── public-api-config.json # Auto-generated
│ └── scripts/
│ ├── run-generation.ts # Main runner script
│ └── upload-to-s3.ts # Uploads to S3
│
├── knowledge-sync/ # Notion → OpenAI sync scripts
│ ├── .env # API keys
│ └── scripts/
│
└── mediajel-gql-docs/ # This repo - Documentation portal
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── schema/ # Schema explorer
│ │ ├── playground/ # GraphiQL playground
│ │ ├── assistant/ # AI chat (full page)
│ │ ├── guides/ # Static documentation
│ │ └── api/chat/ # AI chat API route
│ ├── components/ # React components
│ ├── lib/ # Utilities
│ └── content/ # Synced schema files
│ ├── public-schema.graphql
│ └── public-api-config.json
├── scripts/
│ └── sync-schema.js
└── .env.local # Environment config
Cause: AWS credentials not configured or missing S3 read access.
Solution:
# Check AWS credentials
aws sts get-caller-identity
# Test S3 access
aws s3 ls s3://mj-creatives/public-api-schema/Cause: Missing S3 environment variables.
Solution:
export CREATIVE_BUCKET_NAME=mj-creatives
export CREATIVE_BUCKET_REGION=us-east-1
export PUBLIC_API_SCHEMA_NAME=public-api-schemaError: Source file not found: .../mediajel-gql-service/src/webapp/public-api/public-schema.graphql
Cause: Using local mode but schema not generated, or S3 mode not configured.
Solution:
# Option 1: Generate schema locally
cd mediajel-gql-service
nvm use 18
yarn generate-public-api
# Option 2: Use S3 mode (default)
unset SCHEMA_SOURCE
yarn sync-schemaSolution: Run the complete update workflow:
# 1. Regenerate and upload to S3 in gql-service
cd mediajel-gql-service && yarn generate-public-api
# 2. Sync from S3 in docs app
cd ../mediajel-gql-docs && yarn sync-schema
# 3. Restart dev server
yarn devCheck:
OPENAI_API_KEYis set in.env.localOPENAI_ASSISTANT_IDis set (from Phase 2)OPENAI_VECTOR_STORE_IDis set (from Phase 2)- API key has sufficient credits
- Browser console for specific errors
lsof -i :3006
kill -9 <PID>| Technology | Purpose |
|---|---|
| Next.js 14 | App Router, React framework |
| Tailwind CSS | Styling |
| shadcn/ui | UI components |
| GraphiQL v3 | Interactive playground |
| Vercel AI SDK | AI chat integration |
| OpenAI GPT-4 | AI assistant |
| graphql | Schema parsing |
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY |
Yes | OpenAI API key for AI assistant |
OPENAI_ASSISTANT_ID |
Yes | Required for AI features |
OPENAI_VECTOR_STORE_ID |
Yes | Required for AI features |
NEXT_PUBLIC_GQL_ENDPOINT |
Yes | GraphQL API endpoint for target environment |
CREATIVE_BUCKET_NAME |
Yes | S3 bucket name (mj-creatives for dojo, mj-creatives-production for prod) |
CREATIVE_BUCKET_REGION |
Yes | AWS region (e.g., us-east-1) |
PUBLIC_API_SCHEMA_NAME |
No | S3 directory (default: public-api-schema) |
The build process requires S3 read access to the appropriate bucket:
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": [
"arn:aws:s3:::mj-creatives/public-api-schema/*",
"arn:aws:s3:::mj-creatives-production/public-api-schema/*"
]
}# Build (syncs schema from S3 automatically)
yarn build
# Start
yarn startNode Version: 18+
- Vercel (recommended) - Auto-detects Next.js
- Docker - Use Node 18 base image
- AWS/GCP - Any Node.js hosting
Proprietary - MediaJel Inc.