> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mov-eat.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Platform

> The business backend and source of truth for Moveat.

# Platform

Platform is the Moveat business backend. It is responsible for durable product state, validation rules and official calculations.

## Responsibilities

Platform owns:

* Authentication session handling.
* User identity metadata.
* Profiles.
* Goals.
* Nutrition settings.
* Meal entries.
* Daily nutrition summaries.
* Weight logs.
* Workout sessions.
* Channel links.
* Coaching context.
* Internal APIs consumed by Agent.

## Architecture style

Platform is a TypeScript modular monolith built with NestJS and Prisma.

The intended structure is pragmatic hexagonal architecture:

| Layer                | Responsibility                                             |
| -------------------- | ---------------------------------------------------------- |
| HTTP controllers     | Parse request, validate DTOs, authenticate, call services. |
| Application services | Own use cases, transactions and business flow.             |
| Domain helpers       | Own calculations, conversion and invariant logic.          |
| Infrastructure       | Database, Redis and external adapters.                     |

## Source of truth

Platform is the only service that should persist business data.

Agent and Client must not write directly to PostgreSQL.

## Database

PostgreSQL stores product data. Prisma owns schema and migrations.

Redis can be used for cache/session support, but Redis is not the durable source of truth for product data.

## API split

Platform exposes two categories of APIs:

| API type              | Consumer   | Example                                               |
| --------------------- | ---------- | ----------------------------------------------------- |
| Public product APIs   | Web client | Login, onboarding, profile, meals, weights, workouts. |
| Internal service APIs | Agent      | Resolve user by channel, get context, log meals.      |

Internal APIs require a service token and should not be used by frontend clients.
