# 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)
* `controllers/` → Business logic
* `models/` → 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&#x20;
* setup
* stripe
* token
* user

## Helpers

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

* chart
* file&#x20;
* mail
* notification
* s3
* utility

## Views

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

**Next.js**&#x20;

* 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**&#x20;

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

**Gravity Native**&#x20;

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

{% embed url="<https://www.youtube.com/watch?v=dEXQErxl2oI>" %}
