What Database System Does Akash Console Use? PostgreSQL with Drizzle and Sequelize

Akash Console uses PostgreSQL as its primary database system, leveraging Drizzle ORM for the API layer and Sequelize-TypeScript for shared schema definitions.

The akash-network/console repository implements a robust persistence layer built entirely on PostgreSQL. Understanding what database system Akash Console use reveals a dual-ORM architecture designed for type safety, ACID compliance, and horizontal scalability. The platform configures database connections through environment variables such as POSTGRES_DB_URI and manages schema migrations via Drizzle's PostgreSQL driver.

PostgreSQL as the Core Database System

Akash Console relies on PostgreSQL for all persistent storage needs, including lease contracts, billing records, and user settings. The architecture prioritizes ACID guarantees and transactional integrity, which are critical for a decentralized cloud marketplace where financial settlements occur.

The implementation supports advanced PostgreSQL features such as connection pooling and configurable timeouts. Environment variables like POSTGRES_MAX_CONNECTIONS, POSTGRES_IDLE_TIMEOUT, and POSTGRES_CONNECT_TIMEOUT allow operators to tune performance for high-throughput workloads.

Database Access Patterns: Drizzle and Sequelize

The codebase employs two distinct ORM strategies to interact with PostgreSQL, each serving different architectural layers.

Drizzle ORM for the API Layer

The API application (apps/api) uses Drizzle ORM with the native postgres driver to manage database connections. In apps/api/src/core/providers/postgres.provider.ts, the provider initializes a PostgreSQL client and registers it in the dependency injection container.

import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import { CORE_CONFIG } from "./config.provider";

const client = postgres(config.POSTGRES_DB_URI, {
  max: config.POSTGRES_MAX_CONNECTIONS,
  connect_timeout: config.POSTGRES_CONNECT_TIMEOUT,
  idle_timeout: config.POSTGRES_IDLE_TIMEOUT,
  max_lifetime: config.POSTGRES_MAX_LIFETIME,
});
export const db = drizzle(client, { schema, logger });

The Drizzle configuration file at apps/api/drizzle.config.ts explicitly declares the dialect as "postgresql", ensuring all migrations and schema generation target PostgreSQL-specific features.

Sequelize-TypeScript for Shared Schemas

The shared database schemas located in packages/database/dbSchemas/ utilize Sequelize-TypeScript to define model structures. While Drizzle handles the active API layer, Sequelize manages legacy schema definitions and cross-service data contracts, both targeting PostgreSQL as the underlying engine.

Configuration and Environment Variables

Database connectivity is externalized through environment variables consumed by the CORE_CONFIG provider. Key variables include:

  • POSTGRES_DB_URI – The full connection string (e.g., postgres://user:pass@host:5432/dbname)
  • POSTGRES_MAX_CONNECTIONS – Pool size limits
  • POSTGRES_IDLE_TIMEOUT – Seconds before idle connections are closed
  • POSTGRES_CONNECT_TIMEOUT – Connection establishment timeout
  • POSTGRES_MAX_LIFETIME – Maximum duration a connection remains valid

These settings allow operators to optimize PostgreSQL performance for both development environments and production deployments handling high volumes of lease transactions.

Implementation Examples

Initializing the PostgreSQL Client

The following pattern from postgres.provider.ts demonstrates how Akash Console establishes a type-safe PostgreSQL connection using Drizzle:

const client = postgres(config.POSTGRES_DB_URI, {
  max: config.POSTGRES_MAX_CONNECTIONS,
  connect_timeout: config.POSTGRES_CONNECT_TIMEOUT,
  idle_timeout: config.POSTGRES_IDLE_TIMEOUT,
  max_lifetime: config.POSTGRES_MAX_LIFETIME,
});
export const db = drizzle(client, { schema, logger });

Running Database Migrations

Migrations execute against the PostgreSQL instance using Drizzle's migration utility:

import { migrate } from "drizzle-orm/postgres-js/migrator";

export async function migratePG() {
  const migrationClient = postgres(config.POSTGRES_DB_URI, { max: 1 });
  const pgMigrationDatabase = drizzle(migrationClient, getDrizzleOptions(config));
  await migrate(pgMigrationDatabase, { migrationsFolder: config.DRIZZLE_MIGRATIONS_FOLDER });
  await migrationClient.end();
}

Health Check Implementation

The API verifies PostgreSQL availability using a simple query:

await appPgClient.unsafe("SELECT 1"); // simple ping to verify DB is alive

Key Files in the Repository

Path Role
apps/api/src/core/providers/postgres.provider.ts Central PostgreSQL provider; registers client, runs migrations, and implements health checks.
apps/api/drizzle.config.ts Drizzle ORM configuration with dialect: "postgresql".
packages/database/dbSchemas/ Sequelize-TypeScript schema definitions targeting PostgreSQL.
doc/database-structure.md Documentation describing the dual-ORM PostgreSQL architecture.

Summary

  • Akash Console uses PostgreSQL as its sole database system for all persistent storage, including lease contracts and billing data.
  • Dual ORM architecture: Drizzle ORM handles the API layer with type-safe PostgreSQL queries, while Sequelize-TypeScript manages shared schema definitions.
  • Environment-driven configuration: Connection parameters are externalized via POSTGRES_DB_URI and related variables for connection pooling and timeouts.
  • Migration support: Database schema changes are managed through Drizzle's PostgreSQL-specific migration utilities.

Frequently Asked Questions

Does Akash Console support other database systems besides PostgreSQL?

No, the codebase is architected specifically for PostgreSQL. The Drizzle configuration explicitly sets dialect: "postgresql", and all connection providers import from drizzle-orm/postgres-js. While Drizzle ORM theoretically supports other databases, Akash Console's migration scripts, schema definitions, and environment variable conventions are tightly coupled to PostgreSQL features.

What ORM does Akash Console use for database operations?

Akash Console employs two ORMs simultaneously. Drizzle ORM powers the API layer (apps/api), providing type-safe SQL-like queries and PostgreSQL-specific optimizations. Sequelize-TypeScript defines the shared database schemas in packages/database/dbSchemas/, ensuring consistent model definitions across services. Both ORMs ultimately target the same PostgreSQL instance.

How does Akash Console handle database migrations?

Migrations are executed via Drizzle ORM's PostgreSQL migrator. The postgres.provider.ts file contains a migratePG() function that creates a dedicated migration client (with max: 1 connection), invokes migrate() from drizzle-orm/postgres-js/migrator, and points to the migrations folder defined by DRIZZLE_MIGRATIONS_FOLDER. This ensures schema changes apply atomically against the PostgreSQL backend.

Where are the database connection settings configured in Akash Console?

Connection settings are centralized in environment variables and consumed through the CORE_CONFIG provider. Key variables include POSTGRES_DB_URI for the connection string, and POSTGRES_MAX_CONNECTIONS, POSTGRES_IDLE_TIMEOUT, POSTGRES_CONNECT_TIMEOUT, and POSTGRES_MAX_LIFETIME for pool management. These values are injected into the PostgreSQL client initialization in apps/api/src/core/providers/postgres.provider.ts.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →