Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/app/docs/api/ai-service/page.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const metadata = {
title: 'AI Service API - NeuroLab Documentation',
description: 'API Reference for the NeuroLab AI and Signal Processing service.',
}

# AI Service API

The AI Service provides endpoints for EEG analysis, mental state classification, and voice processing.
Expand Down
5 changes: 0 additions & 5 deletions src/app/docs/api/backend/page.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const metadata = {
title: 'Backend API - NeuroLab Documentation',
description: 'Current route overview for the NeuroLab Express backend.',
}

# Backend API

The NeuroLab backend is an Express service that owns authentication, user and doctor workflows, appointments, uploads, reports, billing, notifications, and chat orchestration.
Expand Down
49 changes: 49 additions & 0 deletions src/app/docs/api/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Link from 'next/link'
import { ArrowRight, Brain, Server, Code2 } from 'lucide-react'

# API Reference

This section groups the two API surfaces documented in this repository:

- the backend API, which handles platform workflows
- the AI service API, which handles analysis and inference endpoints

If you need a route map first, start with one of the cards below.

<div className='not-prose mt-8 grid gap-4 sm:grid-cols-2'>
<Link href='/docs/api/backend' className='group rounded-2xl border border-zinc-200 bg-white p-6 transition-colors hover:bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-950 dark:hover:bg-zinc-900/50'>
<Server className='mb-4 size-5 text-zinc-700 dark:text-zinc-300' />
<h2 className='flex items-center gap-2 text-xl font-bold'>
Backend API
<ArrowRight className='size-4 opacity-0 transition-transform group-hover:translate-x-1 group-hover:opacity-100' />
</h2>
<p className='mt-2 text-sm text-zinc-600 dark:text-zinc-400'>
Route groups, operational notes, and the current backend surface.
</p>
</Link>

<Link href='/docs/api/ai-service' className='group rounded-2xl border border-zinc-200 bg-white p-6 transition-colors hover:bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-950 dark:hover:bg-zinc-900/50'>
<Brain className='mb-4 size-5 text-zinc-700 dark:text-zinc-300' />
<h2 className='flex items-center gap-2 text-xl font-bold'>
AI Service API
<ArrowRight className='size-4 opacity-0 transition-transform group-hover:translate-x-1 group-hover:opacity-100' />
</h2>
<p className='mt-2 text-sm text-zinc-600 dark:text-zinc-400'>
EEG analysis, voice analysis, and model/status endpoints.
</p>
</Link>
</div>

## What to expect

<div className='not-prose mt-8 rounded-2xl border border-zinc-200 bg-zinc-50 p-6 dark:border-zinc-800 dark:bg-zinc-950/40'>
<div className='flex items-start gap-3'>
<Code2 className='mt-0.5 size-5 text-zinc-700 dark:text-zinc-300' />
<div className='space-y-2'>
<p className='font-semibold text-zinc-950 dark:text-zinc-50'>This section is documentation only.</p>
<p className='text-sm leading-7 text-zinc-600 dark:text-zinc-400'>
The pages here summarize the API surfaces that the wider NeuroLab platform exposes. They do not imply that the service source code lives in this repository.
</p>
</div>
</div>
</div>
92 changes: 34 additions & 58 deletions src/app/docs/architecture/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,137 +4,113 @@ import {
Callout,
} from '@/components/mdx-components'

export const metadata = {
title: 'Architecture - NeuroLab Documentation',
description: 'Documented runtime architecture for the current NeuroLab codebase.',
}

# Architecture

NeuroLab currently spans a backend application, an AI service, client applications, and supporting infrastructure. This page focuses on the runtime shape that is visible in the repository today.
NeuroLab is documented here as a layered system: clients, backend API, AI service, and supporting infrastructure.

<Callout
type='warning'
title='Source Of Truth'
icon='△'
>
This page describes the current documented runtime. If architecture notes elsewhere in the repository disagree, trust the active service entrypoints and route files first.
This page summarizes the architecture model used by the docs site. It does not assert that the service source code lives in this repository.
</Callout>

## System Overview

The current repository is best understood as four operational layers:
The platform is described as four operational layers:

<ArchitectureGrid>
<ArchitectureCard
eyebrow='Client Layer'
title='User-Facing Applications'
stack='Vite and Next.js clients'
title='Client Applications'
stack='User-facing web apps'
icon='network'
>
`platform/`, `webapp/`, `docs/`, and `ecommerce/` sit at the edge of the
system. They consume backend HTTP APIs and expose different product
surfaces: platform workflows, user-facing web experiences, and
documentation.
The docs site sits alongside the platform-facing applications and
describes the supported workflows, setup, and reference surfaces.
</ArchitectureCard>

<ArchitectureCard
eyebrow='Core Layer'
title='Backend API'
stack='Node.js + Express + MongoDB'
stack='Backend service boundary'
icon='backend'
>
The backend owns authentication, user and doctor workflows, appointments,
uploads, reports, notifications, billing, and chat orchestration. It also
exposes Swagger at `/api-docs` and acts as the main application boundary
for most clients.
The backend is the primary HTTP boundary for users, appointments,
uploads, reports, billing, notifications, and related workflows.
</ArchitectureCard>

<ArchitectureCard
eyebrow='Inference Layer'
title='AI Service'
stack='FastAPI + Python + optional RQ/Redis'
stack='Analysis and inference service'
icon='ai'
>
The active AI runtime lives under `AI Service/backend`. It handles EEG
analysis, voice analysis, recommendations, reports, chat workflows, model
calibration, and optional streaming. Versioned routes are exposed under
`/api/v1/*`.
The AI service covers EEG analysis, voice processing, report generation,
and model-related endpoints under a versioned API prefix.
</ArchitectureCard>

<ArchitectureCard
eyebrow='Infrastructure Layer'
title='Data And Messaging'
stack='MongoDB, Redis, object storage, MQTT, gRPC'
title='Supporting Services'
stack='Data, queueing, and storage'
icon='data'
>
MongoDB is the primary application datastore. Redis supports queue-backed
workloads and background processing. MQTT and gRPC exist as integration
mechanisms for device and service-to-service communication in specific
flows.
Supporting services include the datastore, queueing, and object storage
layers that the backend and AI service depend on.
</ArchitectureCard>
</ArchitectureGrid>

## Current Service Boundaries

### Backend Responsibilities

- API surface for `/api/auth`, `/api/users`, `/api/admin`, `/api/doctors`,
`/api/devices`, `/api/sessions`, `/api/analysis`, `/api/uploads`,
`/api/reports`, `/api/appointments`, `/api/calendar`, `/api/notifications`,
`/api/clinics`, `/api/billing`, and `/api/chat`
- auth and token issuance
- authentication and token issuance
- application data persistence
- appointment, billing, and workflow orchestration
- chat conversation persistence and AI job reconciliation
- appointments, uploads, reports, billing, notifications, and chat workflows
- route groups summarized in the backend API reference

### AI Service Responsibilities

- versioned FastAPI routing under `/api/v1`
- versioned API routing
- EEG analysis endpoints
- voice analysis endpoints
- model calibration
- report generation jobs
- chat request processing, including queued background mode
- report generation and model-related workflows

## Integration Patterns

| Mechanism | Current Role | Notes |
| :--- | :--- | :--- |
| **HTTP/REST** | Primary application integration | Main client and service API surface |
| **Swagger/OpenAPI** | Backend schema discovery | Exposed by the backend at `/api-docs` |
| **Versioned FastAPI routes** | AI service contract | Canonical AI surface is `/api/v1/*` |
| **Redis/RQ** | Background processing | Used for queued AI chat and report workflows |
| **gRPC** | Targeted service-to-service context exchange | Present in current backend and AI chat/context paths |
| **MQTT** | Device and notification integration | Present as an optional real-time integration mechanism |
| **OpenAPI/Swagger** | Backend schema discovery | The backend API page points to the generated schema |
| **Versioned API routes** | AI service contract | The AI service API is documented under a versioned prefix |
| **Queue-backed jobs** | Background processing | Used for asynchronous analysis and report workflows |

## Runtime Shape

```text
Client applications
-> Backend API (Express)
-> AI service (FastAPI) for analysis, reports, and chat
-> MongoDB / Redis / storage / optional messaging integrations
-> Backend API
-> AI service for analysis and inference
-> Data, queueing, and storage services
```

## Architectural Notes

<Callout title='Important Distinction' icon='◆'>
The repository also contains older or alternate architectural traces. For
documentation work, treat `AI Service/backend` as the primary AI runtime
unless the goal is explicitly historical or comparative.
Keep the architecture page aligned with the routes and pages that exist in
this docs repository. Avoid adding directory-level claims unless the source
code is actually present here.
</Callout>

### What is stable

- backend route groups and Swagger exposure
- backend route summaries and OpenAPI entrypoints
- AI service versioned API prefix
- Vite-based `platform` and `webapp` clients
- docs app as a separate Next.js application

### What is integration-sensitive

- MQTT-dependent flows
- gRPC-dependent context exchange
- Redis-backed async jobs
- deployment assumptions across the various frontend apps
- queue-backed async jobs
- deployment assumptions across the documented setup pages
19 changes: 7 additions & 12 deletions src/app/docs/concepts/eeg-processing/page.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const metadata = {
title: 'EEG Signal Processing - NeuroLab Documentation',
description: 'Learn about the core EEG signal processing pipeline, from raw signal ingestion to feature extraction.',
}

# EEG Signal Processing

NeuroLab employs a state-of-the-art EEG signal processing pipeline designed to handle noisy real-world data and extract meaningful features for mental state classification.
Expand Down Expand Up @@ -85,25 +80,25 @@ The extracted features are further prepared for the machine learning models:

## Next Steps

Learn how these features are combined with voice data for multimodal analysis:
Continue with the mental state model or the AI service reference:

<div className='not-prose mt-6 grid gap-4 sm:grid-cols-2'>
<a
href='/docs/concepts/voice-emotion'
href='/docs/concepts/mental-states'
className='hover:bg-accent block rounded-lg border p-6 transition-colors'
>
<h3 className='mb-2 font-bold'>Voice Emotion Detection →</h3>
<h3 className='mb-2 font-bold'>Mental States →</h3>
<p className='text-muted-foreground text-sm'>
Analyze audio for emotional features
See how the processed signals map to the documented labels
</p>
</a>
<a
href='/docs/concepts/multimodal'
href='/docs/api/ai-service'
className='hover:bg-accent block rounded-lg border p-6 transition-colors'
>
<h3 className='mb-2 font-bold'>Multimodal Analysis →</h3>
<h3 className='mb-2 font-bold'>AI Service API →</h3>
<p className='text-muted-foreground text-sm'>
Combining brain and voice data
Review the analysis endpoints that expose the service contract
</p>
</a>
</div>
5 changes: 0 additions & 5 deletions src/app/docs/concepts/mental-states/page.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const metadata = {
title: 'Mental States - NeuroLab Documentation',
description: 'Understanding the mental state classification system in NeuroLab.',
}

# Mental States

NeuroLab's primary goal is to classify human brain activity and emotional markers into actionable mental states. The system currently recognizes three primary states.
Expand Down
9 changes: 4 additions & 5 deletions src/app/docs/installation/ai-service/page.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export const metadata = {
title: 'AI Service Setup - NeuroLab Documentation',
description: 'Step-by-step guide to installing and configuring the NeuroLab AI Service.',
}

# AI Service Setup

This page documents the AI service setup flow for the broader NeuroLab
platform. It assumes you have access to the platform source tree outside this
docs repository.

The AI Service is the computational heart of NeuroLab, handling EEG signal processing, voice emotion detection, and machine learning inference. It is built with FastAPI and Python.

## Prerequisites
Expand Down
9 changes: 4 additions & 5 deletions src/app/docs/installation/backend/page.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export const metadata = {
title: 'Backend Setup - NeuroLab Documentation',
description: 'Step-by-step guide to installing and configuring the NeuroLab Express.js backend.',
}

# Backend Setup

This page documents the backend setup flow for the broader NeuroLab platform.
It assumes you are working from the platform source tree rather than this docs
repository alone.

The Backend service provides the core API for NeuroLab, managing users, clinical data, billing, and orchestrating analysis sessions. It is built with Node.js and Express.

## Prerequisites
Expand Down
8 changes: 3 additions & 5 deletions src/app/docs/installation/docker/page.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export const metadata = {
title: 'Docker Setup - NeuroLab Documentation',
description: 'Learn how to deploy the entire NeuroLab platform using Docker and Docker Compose.',
}

# Docker Setup

This page assumes you are deploying the broader NeuroLab platform, not just
this docs repository.

Docker is the recommended way to deploy NeuroLab in both development and production environments. It ensures consistency across different systems and simplifies the management of multiple services and databases.

## Prerequisites
Expand Down
8 changes: 3 additions & 5 deletions src/app/docs/installation/production/page.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export const metadata = {
title: 'Production Deployment - NeuroLab Documentation',
description: 'Learn how to deploy the NeuroLab platform to production environments using Render, Vercel, and managed databases.',
}

# Production Deployment

This page assumes you are deploying the broader NeuroLab platform. It does not
describe infrastructure contained in this docs repository itself.

Deploying NeuroLab to production requires a distributed approach to ensure scalability, security, and reliability. We recommend using managed services to reduce operational overhead.

## Deployment Architecture
Expand Down
Loading
Loading