Skip to content
Gravity Logo / Docs Gravity home
Browse documentation
Documentation/Gravity Server

Application Structure

Gravity follows a simple Model–View–Controller (MVC) pattern with a REST API.

This keeps your codebase predictable, easy to extend, and easy for AI tools to work with.

By Architecture

Next.js

The MVC pattern is implemented within a single app:

  • Models → Database schemas and data logic
  • Controllers → Server actions / API route handlers
  • Views → React components (pages + UI)

Routing and backend logic are co-located, removing the need for a separate server.


Node.js

Gravity Server is structured as a traditional MVC backend:

  • server.js → Entry point of the application
  • api/ → Route definitions (maps requests to controllers)
  • controller/ → Business logic
  • model/ → Database schemas

Client applications (Web / Native) communicate with this server via REST APIs.

Controllers

Controllers are located inside the /controller directory, the following come as standard:

  • accountController
  • aiController
  • authController
  • demoController
  • eventController
  • feedbackController
  • inviteController
  • notificationController
  • webhookController
  • jobController
  • keyController
  • pushtokenController
  • setupController
  • socialController
  • userController
  • utilityController

Models

Models are located in the /model directory, and the following are included for you:

  • account
  • auth
  • demo
  • email
  • feedback
  • invite
  • key
  • knex
  • log
  • login
  • event
  • notification
  • usage
  • mongo/ (MongoDB model implementations)
  • openai
  • pushtoken
  • setup
  • stripe
  • token
  • user

Helpers

Helpers are located in the /helper directory, and the following are included for you:

  • auth
  • i18n
  • chart
  • file
  • mail
  • notification
  • s3
  • utility

Views

Views are where your UI components and live. Their location depends on your architecture and client:

Next.js

  • Located inside: /src/app
  • Pages, layouts, and React components live alongside server actions and API routes
  • Allows co-locating frontend and backend logic for faster development and simpler imports

Gravity Web

  • Located at: /client/src/views
  • Contains web-specific pages and UI components

Gravity Native

  • Located at: /app/views inside your Gravity Native project folder
  • Contains mobile screens and components

Watch the video