Skip to content
STACK IT FAST

Logto

Curated OSSClassicIdentity & Auth Infrastructure6-20 people

Audited from github.com/logto-io/logto

Logto is an open-source identity infrastructure providing OIDC/OAuth 2.1 authentication, multi-tenancy, enterprise SSO, and RBAC for SaaS and AI applications, usable self-hosted or as a managed cloud service.

Language
TypeScript
Database
PostgreSQL
Hosting
Docker
License
MPL-2.0
Running for
3 years 1 month
Team
6-20 people

Why this architecture

A Koa server backed by a single PostgreSQL database keeps the identity core simple, while Console and Experience ship as separate Vite/React apps and dozens of independently versioned connector packages plug in social and enterprise login providers.

Tech stack by layer

10 technologies · audited Sep 17, 2026
Frontend & UI
  • ReactPowers the Console admin dashboard and the Experience sign-in app, both Vite builds.
  • ViteBuilds and dev-serves both packages/console and packages/experience.
  • SCSSStyles Console and Experience components, linted with stylelint.
Backend & APIs
  • Koa@logto/core is a Koa-based Node server implementing the OIDC/OAuth provider and management APIs.
Data & Persistence
  • PostgreSQLSole datastore for tenants, users, and OIDC state.
  • SlonikTyped Postgres query builder used by the schemas package and the CLI migration engine.
Infrastructure & Deploy
  • DockerMulti-stage Dockerfile builds a production image run alongside Postgres for local testing.
  • Renderrender.yaml defines a one-click Render.com web service backed by a managed Postgres database.
  • pnpmWorkspace package manager across packages/* and packages/connectors/*.
  • GitHub ActionsRuns integration tests, CodeQL, penetration tests, and releases across the monorepo.

Logto architecture diagram

Open SVG
Logto architecture diagramConsole → @logto/core (Management API); Sign-in experience → @logto/core (Experience API); Your apps → @logto/core (OIDC); @logto/core → Connectors (connector-kit); Connectors → Identity providers (federate); @logto/core → PostgreSQL (Slonik); logto CLI → PostgreSQL (migrations)CLIENTSSERVICESWORKERS & JOBSDATA & STORAGEEXTERNALConsoleReact · ViteSign-in experienceReact · ViteYour appsOIDC / OAuth 2.1 SDKs@logto/coreKoa · OIDC providerConnectorssocial · SMS · emaillogto CLIsetup · alterationsPostgreSQLSlonikIdentity providerssocial · enterprise SSOconnector-kitManagement APIExperience APIOIDCmigrationsSlonikfederate
How the main components of Logto connect, drawn from the audited repository.
Diagram as text
  • Console (React · Vite) → @logto/core (Koa · OIDC provider): Management API
  • Sign-in experience (React · Vite) → @logto/core (Koa · OIDC provider): Experience API
  • Your apps (OIDC / OAuth 2.1 SDKs) → @logto/core (Koa · OIDC provider): OIDC
  • @logto/core (Koa · OIDC provider) → Connectors (social · SMS · email): connector-kit
  • Connectors (social · SMS · email) → Identity providers (social · enterprise SSO): federate
  • @logto/core (Koa · OIDC provider) → PostgreSQL (Slonik): Slonik
  • logto CLI (setup · alterations) → PostgreSQL (Slonik): migrations

Key architectural decisions

5 decisions
  1. 01

    The OIDC/OAuth core server is Koa, not Express

    packages/core/package.json depends on @koa/cors and the Koa ecosystem, making @logto/core a Koa application that implements the OIDC provider, management API, and experience API routes rather than an Express server.

  2. 02

    Console, Experience, and Core are separate packages, not one app

    pnpm-workspace.yaml lists packages/*, packages/toolkit/*, and packages/connectors/* as workspace members; packages/console (admin UI) and packages/experience (end-user sign-in flow) are independent Vite builds consumed by @logto/core at runtime.

  3. 03

    Social and enterprise connectors are a plugin ecosystem, not hardcoded

    packages/connectors contains dozens of independently versioned packages (connector-alipay-native, connector-wechat-web, connector-apple, and more), linked into the Docker build through the ADDITIONAL_CONNECTOR_ARGS build argument in the Dockerfile.

  4. 04

    Database migrations use a typed Slonik query layer, not an ORM

    packages/schemas depends on @silverhand/slonik and ships alterations/ SQL migration scripts run through the logto db alt command, defined as the alteration script in the root package.json.

  5. 05

    Render.com is a first-class deploy target alongside Docker

    render.yaml provisions a Docker-based web service plus a managed logto-database Postgres instance, letting users deploy via the render.com button referenced in the README without writing their own compose file.

How Logto is built

How Logto is structured

Logto is a pnpm monorepo (pnpm-workspace.yaml) covering packages/*, packages/toolkit/*, and packages/connectors/*. The core server lives in packages/core (@logto/core); packages/console is the tenant-facing admin dashboard; packages/experience is the end-user sign-in/registration flow; packages/schemas owns the Postgres schema and migrations; packages/cli provides the logto CLI used for setup and database alterations; and packages/connectors holds dozens of independently versioned social/enterprise identity provider integrations. packages/api and packages/shared provide types and utilities shared across these packages.

Frontend

Both user-facing apps are built with Vite and React. packages/console (vite/vite build scripts) is the admin Console where tenants configure applications, connectors, and RBAC; it depends on @logto/react for its own auth and Radix-adjacent UI plus @monaco-editor/react for JSON/script editors. packages/experience is a separate Vite/React app implementing the actual sign-in, registration, and consent screens documented in end-user-flows/*.md, styled with SCSS and using @simplewebauthn/browser for passkey support. Both apps are generated/built (pnpm generate && vite build) and served as static assets by the Koa core server at runtime rather than deployed independently.

Backend & APIs

packages/core is a Koa application (@koa/cors dependency) implementing three concerns in one server: the OIDC/OAuth 2.1 provider, the Management API (used by Console and the CLI), and the Experience API consumed by the sign-in app. It depends on @logto/schemas, @logto/connector-kit, @logto/core-kit, and the demo apps (@logto/demo-app, @logto/device-demo-app) as workspace packages. Connector packages under packages/connectors follow a consistent shape (each with its own package.json) so new identity providers, SMS gateways, or email senders can be added without touching core server code; the Dockerfile links additional connectors at build time via pnpm cli connector link $ADDITIONAL_CONNECTOR_ARGS. packages/toolkit holds smaller shared libraries (core-kit for cross-package utilities) used by both the core server and the CLI, and packages/translate provides a logto-translate command for managing the phrase/i18n packages (packages/phrases, packages/phrases-experience) that back Console and Experience's multi-language UI.

Data & persistence

PostgreSQL is the only datastore: docker-compose.yml's postgres service uses postgres:17-alpine, and render.yaml provisions a managed logto-database for the hosted deploy path. Rather than a conventional ORM, packages/schemas depends on @silverhand/slonik, a typed SQL query builder, and ships versioned migration scripts under alterations/ (with a compiled alterations-js/ output), applied through the logto db alt CLI command (the root package.json's alteration script). .scripts/compare-database.js and its test suite exist specifically to validate schema consistency across alteration scripts.

Build, test & deploy

The workspace uses changesets for versioning (.changeset/) and pnpm -r build / pnpm -r --parallel ... lint for CI builds, defined as ci:build, ci:lint, ci:stylelint, and ci:test scripts in the root package.json. Renovate (renovate.json) manages dependency updates. GitHub Actions workflows include integration-test.yml and alteration-compatibility-integration-test.yml (validating that schema migrations apply cleanly), codeql-analysis.yml and pen-tests.yml for security, and master-codecov-report.yml for coverage. commitlint.yml enforces Conventional Commits via commitlint.config.ts.

Self-hosting notes

The root Dockerfile uses BuildKit cache mounts to reuse the pnpm store, builds all packages with pnpm -r build, links any additional connectors, and prunes dev dependencies before producing a node:22-alpine runtime image that starts with npm run start. docker-compose.yml is explicitly marked "for demonstration only," running the prebuilt svhd/logto image against a local Postgres container and seeding demo data via npm run cli db seed -- --swe. For managed deployment, render.yaml describes a Docker-based Render web service wired to a Render Postgres database with no public IP allow-list, and the README also documents a Gitpod-based quickstart (.gitpod.yml) as a zero-install way to try the OSS build. The Dockerfile also accepts SSRF-related build/runtime arguments (private_key_rotation_grace_period) and environment variables documented in docker-compose.yml (SSRF_ALLOWED_ADDRESSES, SSRF_PROTECTION_DISABLED) so self-hosters can allow-list internal webhook, SSO, or OIDC relying-party endpoints without disabling Logto's default outbound-request protection entirely.

Sources & repo audit

Audited
Sep 17, 2026
Commit
c12d89f
License
MPL-2.0

Independent analysis of repository at github.com/logto-io/logto. Spotted an inaccuracy? Use the claim form to request a correction.

Show this stack on your README or website
Tech stack of Logto
[![Tech stack of Logto on STACK IT FAST](https://stackitfast.com/badge/logto.svg)](https://stackitfast.com/project/logto)

Paste it into your README. It shows your current stack and links to this page.

Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Logto's architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 59 lines · 6.5 KB
# MISSION: Scaffold "Logto" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Logto**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Logto
- **What It Does**: Logto is an open-source identity infrastructure providing OIDC/OAuth 2.1 authentication, multi-tenancy, enterprise SSO, and RBAC for SaaS and AI applications, usable self-hosted or as a managed cloud service.
- **Domain & Category**: Identity & Auth Infrastructure
- **Production Scale**: 6-20 people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: A Koa server backed by a single PostgreSQL database keeps the identity core simple, while Console and Experience ship as separate Vite/React apps and dozens of independently versioned connector packages plug in social and enterprise login providers.
- **Live Website Reference**: https://logto.io
- **Source Repository**: https://github.com/logto-io/logto
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, React, PostgreSQL, Vite, pnpm, Docker, Render, SCSS, Koa, Slonik
- **Primary Language(s)**: TypeScript, SCSS
- **License of the reference repo**: MPL-2.0
- **Frontend**: React — Powers the Console admin dashboard and the Experience sign-in app, both Vite builds.; Vite — Builds and dev-serves both packages/console and packages/experience.; SCSS — Styles Console and Experience components, linted with stylelint.
- **Backend & APIs**: Koa — @logto/core is a Koa-based Node server implementing the OIDC/OAuth provider and management APIs.
- **Data & persistence**: PostgreSQL — Sole datastore for tenants, users, and OIDC state.; Slonik — Typed Postgres query builder used by the schemas package and the CLI migration engine.
- **Infrastructure & deploy**: Docker — Multi-stage Dockerfile builds a production image run alongside Postgres for local testing.; Render — render.yaml defines a one-click Render.com web service backed by a managed Postgres database.; pnpm — Workspace package manager across packages/* and packages/connectors/*.; GitHub Actions — Runs integration tests, CodeQL, penetration tests, and releases across the monorepo.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/logto-io/logto @ c12d89f)
1. **The OIDC/OAuth core server is Koa, not Express**: packages/core/package.json depends on @koa/cors and the Koa ecosystem, making @logto/core a Koa application that implements the OIDC provider, management API, and experience API routes rather than an Express server.
2. **Console, Experience, and Core are separate packages, not one app**: pnpm-workspace.yaml lists packages/*, packages/toolkit/*, and packages/connectors/* as workspace members; packages/console (admin UI) and packages/experience (end-user sign-in flow) are independent Vite builds consumed by @logto/core at runtime.
3. **Social and enterprise connectors are a plugin ecosystem, not hardcoded**: packages/connectors contains dozens of independently versioned packages (connector-alipay-native, connector-wechat-web, connector-apple, and more), linked into the Docker build through the ADDITIONAL_CONNECTOR_ARGS build argument in the Dockerfile.
4. **Database migrations use a typed Slonik query layer, not an ORM**: packages/schemas depends on @silverhand/slonik and ships alterations/ SQL migration scripts run through the logto db alt command, defined as the alteration script in the root package.json.
5. **Render.com is a first-class deploy target alongside Docker**: render.yaml provisions a Docker-based web service plus a managed logto-database Postgres instance, letting users deploy via the render.com button referenced in the README without writing their own compose file.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Utilize Vite 6 with TanStack Router for fully type-safe routing. Manage server state and caching via TanStack Query v5 with optimistic UI updates.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (PostgreSQL, Slonik): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a identity & auth infrastructure project?

Frequently asked about Logto

What is Logto built with?

Logto's backend (@logto/core) is a Koa Node.js server backed by PostgreSQL, with a React/Vite Console admin app and a separate React/Vite Experience app for end-user sign-in flows.

Does Logto use PostgreSQL or another database?

PostgreSQL is Logto's only supported database; both docker-compose.yml and render.yaml provision a Postgres instance, and packages/schemas manages its schema through Slonik-based migrations.

Can I self-host Logto?

Yes. The repository ships a Dockerfile, docker-compose.yml for local use, and a render.yaml blueprint for one-click deployment to Render.com, in addition to the managed Logto Cloud.

How does Logto support social and enterprise logins?

Through packages/connectors, a workspace of independently versioned connector packages for providers like Alipay, WeChat, Apple, and SMS or email gateways, all plugging into the Koa core server.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md