gitlab-org/gitlab
Namespace
The polymorphic root of every URL in GitLab. Every project lives under a namespace; every group is a namespace; every user has a namespace.
Source
app/models/namespace.rb plus subclasses:
Namespaces::UserNamespace— personal namespace (one per user).Group— a group namespace (type = 'Group'in single-table inheritance).ProjectNamespace— synthetic namespace per project (used for routing & cross-cutting features).
app/models/namespaces/ and app/services/namespaces/ extend the base.
Why so polymorphic
A "namespace" is anything that can own projects, sub-resources, and a Git path:
- A user owns their personal namespace.
- A group owns nested groups and projects.
- A project owns a synthetic project namespace.
Routing uses a single namespaces.path column to assemble URLs without per-type lookups. This is why /gitlab-org/gitlab is a path and Namespaces::Path parses it.
Hierarchy
namespaces.parent_id builds a tree. Namespace#self_and_descendants, #self_and_ancestors, and Postgres recursive CTEs handle the tree (lib/gitlab/sql/recursive_cte.rb).
Settings
namespace_settings (a 1:1 settings table) holds:
- Default branch protection.
- Membership lock (group-only).
- Custom roles enabled (EE).
- Many feature toggles.
Aggregations
namespace_statistics rolls up counts (projects, storage, etc.) and is updated by Sidekiq workers when child resources change.
Storage
Namespaces have storage size and limit columns. Namespaces::Storage::* services enforce limits and produce notifications.
Related
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.