MuseMVP

MuseMVP Base : Next.js pour Node et Cloudflare. MuseMVP Flare : un template SaaS IA qui tourne entièrement sur Cloudflare. Authentification, facturation et administration incluses.

Produit
  • Accueil
  • Tarifs
  • Modèles
Ressources
  • Docs
  • Blog
  • Journal
Mentions légales
  • Confidentialité
  • Conditions
  • Communauté
Open-Launch Top 1 Daily WinnerOpen-Launch Top 1 Daily WinnerVerified DR - Verified Domain Rating for musemvp.comVerified DR - Verified Domain Rating for musemvp.comMuseMVP - Featured on Startup FameMuseMVP - Featured on Startup FameFazier badgeFazier badgeLiftOff award badgeLiftOff award badge

© 2026 MuseMVP. Tous droits réservés.

MuseMVP
  • Tarifs
  • Docs
  • Blog
  • Journal
Acheter MuseMVP Base
Docs MuseMVP
Docs MuseMVP
OverviewTech StackQuick Start
Project Structure
API ArchitectureBackend GuideDefining New RoutesAPI Keys
EmailObject Storage
Internationalization
SEOAnalytics
API

Cette page n'est pas encore disponible dans la langue sélectionnée. Vous consultez la version originale en English.

Voir l'original (English)

API Architecture

An overview of MuseMVP's API: why Hono, how it integrates with Next.js, and availability/observability entry points.

MuseMVP uses a Hono + Next.js Route Handler setup: all APIs go through /api/*, with Hono managing routes and middleware.

Overview

src/app/api/[[...rest]]/route.ts
src/backend/api/app.ts
src/backend/api/routes/

The request path keeps a single entrypoint: /api/* -> route.ts -> Hono app.ts -> feature router -> service/query.


Why Hono

The reasons are straightforward:

  • Lightweight, with clear route and middleware organization
  • TypeScript-friendly, making type-safe API clients easier to build
  • Easy OpenAPI integration for interface collaboration

Compared to spreading logic across many Route Handlers, a centralized API layer is easier to maintain.


Availability

By default, API and Web are served together, so you do not need to maintain separate entrypoints. If you later add mobile, plugins, or third-party clients, you can still reuse the same Hono routes.

Common route groups (examples):

  • /api (auth)
  • /api/admin, /api/assets, /api/upload
  • /api/muse-billing, /api/upgrade, /api/newsletter
  • /api/health
  • /api/openapi, /api/docs

Layering convention:

  • Route: input validation, auth, HTTP responses
  • Service (src/modules/<feature>/lib/*): business orchestration
  • Query (packages/db/src/queries/*): database read/write

Error Handling and Request Limits

src/backend/api/app.ts also registers two app-level guards:

  • app.onError catches uncaught errors and returns a consistent JSON error structure; thrown HTTPExceptions keep their own responses
  • hono/body-limit caps API request bodies at 1MB; avatar uploads use a separate same-origin /files/avatars/* route with PNG/5 MiB checks

Observability

  • Health check: /api/health
  • OpenAPI: /api/openapi
  • API docs (Scalar UI): /api/docs

Practical Guideline

Keep middleware focused on entry responsibilities (logging, CORS, auth gate). Put complex business logic in the service layer to avoid API entry bloat.

Database Migrations

Review and apply D1 migrations with backups and release checks.

Backend Guide

A practical guide to src/backend responsibilities, api-client usage in client/server contexts, and the full request chain.

Sur cette page

OverviewWhy HonoAvailabilityError Handling and Request LimitsObservability

Un paiement. Taxes comprises.

MuseMVP Base

Next.js pour Node et pour Cloudflare, avec auth, paiements et admin.

$69

Acheter MuseMVP Base