On this page

How the platform is built

The web app, the Python service, PostgreSQL with pgvector, and the local models that answer questions.

MFU AI Teaching Assistant is a web application plus a separate Python service. The web app handles sign-in, portals, and screens. The service owns retrieval, documents, and the database.

Components

LayerTechnologyResponsibility
Web appNext.js (App Router), React, TypeScript, TailwindPortals, screens, session handling, server-side proxy routes
API serviceFastAPI, Pydantic, SQLAlchemy (async)Authentication checks, documents, retrieval, streaming answers
DatabasePostgreSQL 16 + pgvectorPeople, courses, enrollments, documents, chunks, embeddings
ModelsOllama (default), Gemini (optional)Chat completion and embeddings
PackagingDocker ComposeRuns the web app and service together

Request flow

  1. The browser calls a Next.js route such as /api/chat/stream.
  2. The route forwards the request to the Python service with the caller's identity.
  3. The service resolves that identity to a person in the database.
  4. It checks the course and enrollment, then retrieves passages from that course.
  5. It streams the answer back as server-sent events.
  6. The browser renders the text and the citations.

The browser never talks to the database directly, and never decides which documents it may read.

Why two services

Separating them keeps model work and data rules in one place:

  • Retrieval, chunking, and embeddings are Python.
  • The database schema is owned by the service and migrated with Alembic.
  • Screens can change without touching retrieval logic.
  • The same API could serve a mobile client later.

Data model in one table

TableHolds
peopleTeachers, students, admins; unique email
coursesCourse code, title, owning teacher
enrollmentsWhich student takes which course
documentsOne uploaded PDF per course, with status and hash
document_chunksText, embedding, and keyword index per chunk

Enrollment is a row, not a claim from the browser. That is what makes course scoping enforceable.

Running it locally

docker compose --env-file .env.local up --build

The web app runs on port 3000 and the service on port 8000. Ollama runs on port 11434 when local models are enabled.

Guide feedback

Did this guide get you unstuck?

Tell us whether this guide answered your question.

MFU AI Knowledge Studio · practical guidance for learning, teaching, and platform operations