Architecture
How Stasis is built
Architecture
This page explains how Stasis is structured internally. You don't need to understand this to use Stasis, but it's helpful if you want to contribute or troubleshoot.
High-Level Overview
Stasis has four main components:
┌─────────────────────────────────────────────────────────┐
│ NGINX │
│ (Reverse Proxy) │
└─────────────────┬───────────────────┬───────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ API Server │ │ Web Frontend │
│ (Go) │ │ (Next.js) │
└────────┬────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ PostgreSQL │
│ (Database) │
└─────────────────┘NGINX
The entry point. It routes requests:
/api/*→ API Server/→ Web Frontend- Git Smart HTTP requests → API Server
API Server (Go)
The backend. Handles:
- Authentication (OIDC)
- Repository management
- Git protocol (SSH and HTTP)
- User profiles
- Tokens and SSH keys
Web Frontend (Next.js)
The UI you see in your browser. It communicates with the API server to display repositories, commits, and settings.
PostgreSQL
Stores all persistent data:
- User accounts and profiles
- Repository metadata
- SSH keys and tokens
- CI/CD job records
Directory Structure
stasis/
├── cmd/
│ └── server/ # Main entry point
├── internal/
│ ├── application/ # Business logic
│ │ ├── dto/ # Data transfer objects
│ │ └── service/ # Service implementations
│ ├── config/ # Configuration loading
│ ├── domain/ # Domain models
│ │ ├── models/ # Data structures
│ │ └── repository/ # Repository interfaces
│ ├── infrastructure/ # External integrations
│ │ ├── git/ # Git operations
│ │ └── repository/ # Database implementations
│ └── transport/ # HTTP and SSH handlers
│ ├── http/ # REST API handlers
│ └── ssh/ # SSH server
├── web/ # Next.js frontend
│ ├── app/ # Pages and routes
│ ├── components/ # React components
│ └── lib/ # Utilities and API client
├── configs/ # Configuration files
└── deploy/ # Deployment configs (nginx, etc.)How Git Operations Work
HTTP (Smart HTTP Protocol)
When you git clone http://localhost/username/repo.git:
- NGINX receives the request
- NGINX forwards it to the API server
- The API server authenticates the request (token or session)
- The API server reads the repository from disk
- The API server returns the git data
- Your local git client processes the data
SSH
When you git clone ssh://localhost:2222/username/repo.git:
- The SSH server receives the connection
- It verifies your SSH key against stored keys
- It executes the git command
- It reads/writes the repository on disk
How Authentication Works
See Authentication for user-facing details. Internally:
- OIDC tokens are verified against the identity provider
- Session tokens are stored in cookies
- API tokens are verified against the database
- SSH keys are verified against stored public keys
Contributing
Want to contribute to Stasis? See Contributing for how to set up your development environment and submit changes.