export interface SystemDesignTopic { id: string; chapter_no: number; chapter_name: string; subtitle: string; level: string; } export interface SystemDesignTopicContent extends SystemDesignTopic { content: any; // Raw JSON object from MongoDB } export async function fetchSystemDesignTopics(): Promise { const res = await fetch('/api/system-design/topics'); if (!res.ok) throw new Error('Failed to fetch topics'); const data = await res.json(); return data.topics || []; } export async function fetchSystemDesignTopicContent(chapterNo: number): Promise { const res = await fetch(`/api/system-design/topics/${chapterNo}`); if (!res.ok) throw new Error('Failed to fetch topic content'); return res.json(); }