Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tutosrive/ferreandina-nosql/llms.txt

Use this file to discover all available pages before exploring further.

The Ferreandina backend lives in the app/bc module. It is a Java 21 REST API built on top of Javalin 7 and backed by MongoDB. The server listens on port 7070 and is managed entirely by the Gradle 9 build system — no additional tooling installation is required.

Prerequisites

  • Java 21 or later must be installed and available on your PATH. The Gradle toolchain block in build.gradle.kts pins the JDK version to 21, so the build will fail fast if an incompatible JDK is detected.
  • Gradle wrapper is included (gradlew / gradlew.bat). You do not need to install Gradle separately — all commands below use the wrapper.

Project Structure

app/bc/
├── app/
│   └── src/main/java/com/ferreandina/
│       ├── App.java            # Entry point, Javalin config
│       ├── controllers/        # Resource controllers
│       ├── database/           # MongoDB connection
│       ├── models/             # POJO models
│       ├── routes/             # Route definitions
│       ├── services/           # Data access layer
│       └── utils/              # Helpers (ResultUtil, Validator, Utils)
├── gradle/
├── gradlew
└── build.gradle.kts

Dependencies

The following key libraries are declared in app/build.gradle.kts:
ArtifactVersionPurpose
io.javalin:javalin7.2.2HTTP framework and route DSL
org.mongodb:mongodb-driver-bom5.7.0MongoDB Java driver (BOM — pins all sub-modules)
org.mongodb:mongodb-driver-sync(from BOM)Synchronous MongoDB client
com.fasterxml.jackson.core:jackson-databind2.21.2JSON serialization used by Javalin
io.github.cdimascio:dotenv-java3.2.0Loads .env file into the runtime environment
org.json:json20260522JSON object/array building for responses
org.slf4j:slf4j-simple2.0.17Logging backend for Javalin

Running the Server

1

Navigate to the backend module

All Gradle commands must be run from the app/bc directory, where the Gradle wrapper and build.gradle.kts reside.
cd app/bc
2

Create the .env file

The application reads database credentials from a .env file placed in the same directory you run the command from (i.e., app/bc/). Create it with the two required variables:
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=ferreandina
See the Configuration page for full details, including MongoDB Atlas URIs.
3

Start the server

Use the Gradle wrapper to compile and launch the application:
# Linux / macOS
./gradlew run

# Windows
gradlew.bat run
Gradle will resolve dependencies on the first run, compile all source files, and start the Javalin server. You should see output similar to:
mongodb://localhost:27017
ferreandina
[main] INFO io.javalin.Javalin - Javalin started in 312ms \o/
[main] INFO io.javalin.Javalin - Listening on http://localhost:7070/
4

Verify the server is running

Send a request to the branches endpoint to confirm the API is live:
curl http://localhost:7070/api/branches
A successful response returns a JSON envelope like:
{
  "message": "There are all BranchModels",
  "status": 200,
  "data": [...],
  "size": 3
}

Entry Point — App.java

The App class is the single entry point for the entire server. It creates a Javalin instance, wires up all routes via Routes, enables CORS, and starts the HTTP listener on port 7070.
package com.ferreandina;

import com.ferreandina.routes.Routes;

import io.javalin.Javalin;

public class App {
    public static void main(String[] args) {
        Javalin.create(
                config -> {
                    new Routes(config);

                    config.bundledPlugins.enableCors(cors -> {
                        cors.addRule(it -> {
                            it.anyHost();
                        });
                    });
                }).start(7070);
    }
}
The run task in build.gradle.kts is configured with inputs.files pointing at src/main/java/**/*.java. This tells Gradle to treat any Java source change as an input change, so re-running ./gradlew run after editing a source file will trigger a recompile rather than using the cached output.
tasks.named("run") {
    inputs.files(
        fileTree("src/main/java") {
            include("**/*.java")
        }
    )
}

Build docs developers (and LLMs) love