Skip to content

Backend Overview

The Medipal backend ecosystem spans multiple repositories — the core API server, auto-generated modules, a plugin system, an analytics tracker, and shared Python libraries.

Repositories

Core

RepositoryDescription
mp-serverMain FastAPI backend — RESTful API, RBAC, scheduler, event system, plugin loader
mp-trackerStandalone Python analytics service for mobile usage events
mp-tracker-api-specOpenAPI spec for tracker endpoints

Generated Modules

These repositories are auto-generated from mp-schema via genma + yamser and consumed as git submodules by mp-server:

RepositoryDescription
mp-server-pydantic-modelsPydantic v2 request/response models for all API endpoints
mp-server-sql-alchemy-modelsSQLAlchemy 2.0 ORM model classes mapping to PostgreSQL tables
mp-server-apiFastAPI route definitions generated from OpenAPI specs
mp-server-config-schemaApplication configuration schema (YAML-based, validated at startup)

Never edit manually

These repos are regenerated on every mp-schema push. Manual edits will be overwritten.

Plugin System

RepositoryDescription
mp-server-plugin-sdkPython SDK defining the plugin interface — hooks for events, scheduling, and custom API endpoints
mp-server-plugin-smtp-emailBuilt-in SMTP email plugin — transactional emails (invitations, password resets, notifications)

Internal Python Libraries

Shared packages used across mp-server, mp-tracker, and code generation tooling:

RepositoryDescription
pylogStructured JSON logging with correlation IDs and request context
storielStorage abstraction — unified API for local filesystem and S3
confirionConfiguration management — loads, merges, and validates YAML/env config at startup
genmaCode generation engine — reads schema definitions, produces source files via Jinja2 templates
yamserYAML serialisation/deserialisation with schema validation and reference resolution
fylerFile utilities — temp file management, path resolution, archive handling
structoData structure helpers — deep merge, diff, flatten, schema-aware transforms

Key Technologies

  • FastAPI — async web framework
  • SQLAlchemy — ORM and query builder
  • Alembic — database migrations
  • PostgreSQL — primary database
  • Redis — caching
  • APScheduler — task scheduling (heartbeat, tracker ping, enrollment reminders)
  • CloudEvents — event-driven messaging with outbox pattern

Core Concepts

The backend follows a layered architecture with routes, services, and repositories. Auto-generated modules from mp-schema provide typed models and database definitions. Plugins extend server functionality via mp-server-plugin-sdk without modifying core code.

See Platform Architecture for how backend services fit into the full dependency graph.