# Where to Find Core Modules in the TREK Server Source Code

> Locate TREK server source code core modules in the server/src/nest/ directory. Discover over 35 domain-specific modules like Database, Weather, Trips, and Auth, all orchestrated by app.module.ts.

- Repository: [Maurice/TREK](https://github.com/mauriceboe/TREK)
- Tags: internals
- Published: 2026-06-27

---

**The core modules in the TREK server source code are located in the `server/src/nest/` directory, with the root application module at [`server/src/nest/app.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/app.module.ts) orchestrating 35+ domain-specific modules including Database, Weather, Trips, and Auth.**

The TREK travel planning platform is built on a **NestJS** backend architecture. All core modules in the TREK server source code follow standard NestJS patterns, organized under `server/src/nest/` with each feature domain encapsulated in its own folder containing controllers, services, and providers.

## Root Module Configuration

The entry point that wires all core modules together is [`server/src/nest/app.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/app.module.ts). This root module imports every domain module required by the application:

```typescript
@Module({
  imports: [
    DatabaseModule,
    WeatherModule,
    AirportsModule,
    ConfigModule,
    SystemNoticesModule,
    MapsModule,
    CategoriesModule,
    TagsModule,
    NotificationsModule,
    AtlasModule,
    VacayModule,
    PackingModule,
    BudgetModule,
    ReservationsModule,
    DaysModule,
    AssignmentsModule,
    PlacesModule,
    TripsModule,
    TodoModule,
    CollabModule,
    FilesModule,
    PhotosModule,
    MemoriesModule,
    AirtrailModule,
    JourneyModule,
    ShareModule,
    SettingsModule,
    BackupModule,
    BookingImportModule,
    AuthModule,
    OidcModule,
    OauthModule,
    AdminModule,
    AddonsModule,
  ],
})
export class AppModule {}

```

Each entry in the `imports` array references a **module folder** under `server/src/nest/`. For example, `TripsModule` resolves to [`server/src/nest/trips/trips.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/trips/trips.module.ts), while `AuthModule` maps to [`server/src/nest/auth/auth.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/auth/auth.module.ts).

## Domain Module Structure

Core modules follow a consistent directory structure. Within each module folder, you will find the module definition file, controllers, services, and DTOs.

### Infrastructure Modules

**DatabaseModule** ([`server/src/nest/database/database.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/database/database.module.ts)) provides database connectivity, while **ConfigModule** ([`server/src/nest/config/config.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/config/config.module.ts)) handles environment variable management. These foundational modules are imported first to ensure dependent modules have access to configuration and persistence layers.

### Feature Modules

Travel-specific functionality is organized into dedicated modules:

- **TripsModule** ([`server/src/nest/trips/trips.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/trips/trips.module.ts)) - Trip management and itinerary logic
- **ReservationsModule** ([`server/src/nest/reservations/reservations.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/reservations/reservations.module.ts)) - Booking and reservation handling
- **WeatherModule** ([`server/src/nest/weather/weather.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/weather/weather.module.ts)) - Weather data integration
- **AirportsModule** ([`server/src/nest/airports/airports.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/airports/airports.module.ts)) - Airport code and location data
- **PlacesModule** ([`server/src/nest/places/places.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/places/places.module.ts)) - Point-of-interest management

### Auth and Security Modules

Authentication and authorization are split across multiple modules:

- **AuthModule** ([`server/src/nest/auth/auth.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/auth/auth.module.ts)) - Core authentication logic
- **OidcModule** ([`server/src/nest/oidc/oidc.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/oidc/oidc.module.ts)) - OpenID Connect integration
- **OauthModule** ([`server/src/nest/oauth/oauth.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/oauth/oauth.module.ts)) - OAuth 2.0 provider support
- **AdminModule** ([`server/src/nest/admin/admin.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/admin/admin.module.ts)) - Administrative functions

## Application Bootstrap

The [`server/src/bootstrap.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/bootstrap.ts) file initializes the Nest application using `NestFactory` and wires global middleware:

```typescript
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import { AppModule } from './nest/app.module';
import { applyGlobalMiddleware, applyPlatformUploads, applyPlatformTransport, applyPlatformStatic } from './middleware';

export async function buildApp() {
  const app = await NestFactory.create(AppModule, new ExpressAdapter());
  const express = app.getHttpAdapter().getInstance();

  applyGlobalMiddleware(express, { bodyParser: false });
  applyPlatformUploads(express);
  applyPlatformTransport(express);
  applyPlatformStatic(express);

  await app.init();
  return app;
}

```

This bootstrap function creates the Express instance, applies security headers and CORS via `applyGlobalMiddleware`, and registers platform-specific routes for file uploads and static assets before initializing the Nest container.

## Accessing Services Across Modules

To utilize functionality from another core module, import the service directly from the module's directory. For example, accessing `TripsService` from within another module:

```typescript
import { Injectable } from '@nestjs/common';
import { TripsService } from '../trips/trips.service';

@Injectable()
export class ExampleService {
  constructor(private readonly tripsService: TripsService) {}

  async listUserTrips(userId: string) {
    return this.tripsService.findAllForUser(userId);
  }
}

```

The `TripsService` implementation resides at [`server/src/nest/trips/trips.service.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/trips/trips.service.ts).

When adding new endpoints to existing modules, define controllers within the module's folder. For example, extending the WeatherModule:

```typescript
import { Controller, Get } from '@nestjs/common';
import { WeatherService } from './weather.service';

@Controller('weather')
export class WeatherController {
  constructor(private readonly weather: WeatherService) {}

  @Get('ping')
  ping() {
    return { status: 'ok', time: new Date() };
  }
}

```

This controller would be defined in [`server/src/nest/weather/weather.controller.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/weather/weather.controller.ts) and registered within `WeatherModule`.

## Summary

- **Core modules** in the TREK server are located in `server/src/nest/` according to the mauriceboe/TREK repository structure.
- **Root module** at [`server/src/nest/app.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/app.module.ts) imports 35+ domain modules including Database, Trips, Auth, and Weather.
- **Each module** follows NestJS conventions with dedicated folders containing `*.module.ts`, controllers, services, and DTOs.
- **Bootstrap** occurs in [`server/src/bootstrap.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/bootstrap.ts) which creates the Express instance and applies global middleware before initializing the Nest application.
- **Cross-module dependencies** are resolved via NestJS dependency injection by importing services from their respective module directories.

## Frequently Asked Questions

### What is the main entry point for TREK server modules?

The main entry point is [`server/src/nest/app.module.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/nest/app.module.ts). This root module imports all 35+ core modules including DatabaseModule, TripsModule, and AuthModule, serving as the central registry that wires the entire application together according to the mauriceboe/TREK source code.

### How are the TREK server modules organized?

Modules are organized by domain under `server/src/nest/`. Each module resides in its own folder (e.g., `trips/`, `weather/`, `auth/`) containing the module definition file, controllers, service implementations, and data transfer objects following standard NestJS architectural patterns.

### Where is the TREK server application initialized?

The application is initialized in [`server/src/bootstrap.ts`](https://github.com/mauriceboe/TREK/blob/main/server/src/bootstrap.ts). This file uses `NestFactory.create()` with an Express adapter, applies global middleware for security and CORS, configures platform-specific uploads and static routes, and then calls `app.init()` to register all controllers and providers from the core modules.

### How do I import a service from another core module?

Import the service class directly from the target module's directory. For example, `import { TripsService } from '../trips/trips.service'`. NestJS handles the dependency injection automatically when the consuming module is properly configured in the imports array of [`app.module.ts`](https://github.com/mauriceboe/TREK/blob/main/app.module.ts).