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 applicationapi/→ Route definitions (maps requests to controllers)controllers/→ Business logicmodels/→ 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
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
mongo
openai
pushtoken
setup
stripe
token
user
Helpers
Helpers are located in the /helper directory, and the following are included for you:
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/appPages, 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/viewsContains web-specific pages and UI components
Gravity Native
Located at:
/app/viewsinside your Gravity Native project folderContains mobile screens and components
Last updated