# athul675/gitea architecture

> Architecture diagram of the GitHub repository athul675/gitea, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/athul675/gitea
- Repository: https://github.com/athul675/gitea

## Overview

This repository is a deployment reference for self-hosted Gitea, with cumulative per-user Git storage quotas enforced by server-side hooks. The documented push path runs through Nginx and Gitea to a repository hook: pre-receive checks usage and reserves quota; post-receive supports accounting after the push. PostgreSQL holds quota state, while SQL files define and seed it. The repository also supplies service, proxy, and Fail2ban configuration. The source excerpts are unavailable, so relationships below are limited to those stated in the README.

Main entry points: [`scripts/quota-pre-receive`](https://github.com/athul675/gitea/blob/main/scripts/quota-pre-receive) (Pre-receive check), [`scripts/quota-post-receive`](https://github.com/athul675/gitea/blob/main/scripts/quota-post-receive) (Post-receive accounting), [`configs/fail2ban/gitea-filter.conf`](https://github.com/athul675/gitea/blob/main/configs/fail2ban/gitea-filter.conf) (Fail2ban filter), [`scripts/install-hooks.sh`](https://github.com/athul675/gitea/blob/main/scripts/install-hooks.sh) (Hook installer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Ingress and security"]
  node_nginx["Nginx proxy<br/>[nginx.conf]"]
  node_fail2ban["Fail2ban filter<br/>[gitea-filter.conf]"]
  node_fail2ban_jail["Fail2ban jail<br/>[gitea-jail.local]"]
end

subgraph group_gitea["Gitea service"]
  node_gitea["Gitea server"]
  node_app_config["Gitea settings<br/>[app.ini.example]"]
  node_service["Service unit<br/>[gitea.service]"]
  node_repositories[("Git repositories")]
end

subgraph group_quota["Quota enforcement"]
  node_installer["Hook installer<br/>[install-hooks.sh]"]
  node_pre_receive["Pre-receive check"]
  node_post_receive["Post-receive accounting"]
end

subgraph group_storage["Quota persistence"]
  node_postgres[("PostgreSQL")]
  node_schema["Quota schema<br/>[01_schema.sql]"]
  node_seed["Quota allocation<br/>[02_seed_quotas.sql]"]
end

node_client(("Git client"))

node_client -->|"sends HTTP"| node_nginx
node_nginx -->|"proxies traffic"| node_gitea
node_gitea -->|"manages repositories"| node_repositories
node_gitea -->|"uses database"| node_postgres
node_gitea -->|"runs hook"| node_pre_receive
node_gitea -->|"runs hook"| node_post_receive
node_installer -->|"installs centrally"| node_pre_receive
node_installer -->|"installs centrally"| node_post_receive
node_pre_receive -->|"checks and reserves"| node_postgres
node_post_receive -->|"tracks usage"| node_postgres
node_schema -->|"defines tables"| node_postgres
node_seed -->|"seeds quotas"| node_postgres
node_fail2ban -->|"filters jail events"| node_fail2ban_jail
node_fail2ban -.->|"mitigates threats"| node_gitea

click node_nginx "https://github.com/athul675/gitea/blob/main/configs/nginx.conf"
click node_fail2ban "https://github.com/athul675/gitea/blob/main/configs/fail2ban/gitea-filter.conf"
click node_fail2ban_jail "https://github.com/athul675/gitea/blob/main/configs/fail2ban/gitea-jail.local"
click node_app_config "https://github.com/athul675/gitea/blob/main/configs/app.ini.example"
click node_service "https://github.com/athul675/gitea/blob/main/configs/gitea.service"
click node_installer "https://github.com/athul675/gitea/blob/main/scripts/install-hooks.sh"
click node_pre_receive "https://github.com/athul675/gitea/blob/main/scripts/quota-pre-receive"
click node_post_receive "https://github.com/athul675/gitea/blob/main/scripts/quota-post-receive"
click node_schema "https://github.com/athul675/gitea/blob/main/sql/01_schema.sql"
click node_seed "https://github.com/athul675/gitea/blob/main/sql/02_seed_quotas.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_nginx,node_fail2ban,node_fail2ban_jail,node_client toneBlue
class node_gitea,node_app_config,node_service,node_repositories toneAmber
class node_installer,node_pre_receive,node_post_receive toneMint
class node_postgres,node_schema,node_seed toneRose
```

## Components

### Ingress and security

- [Nginx proxy](https://github.com/athul675/gitea/blob/main/configs/nginx.conf): `configs/nginx.conf`
- [Fail2ban filter](https://github.com/athul675/gitea/blob/main/configs/fail2ban/gitea-filter.conf): `configs/fail2ban/gitea-filter.conf`
- [Fail2ban jail](https://github.com/athul675/gitea/blob/main/configs/fail2ban/gitea-jail.local): `configs/fail2ban/gitea-jail.local`

### Gitea service

- **Gitea server**
- [Gitea settings](https://github.com/athul675/gitea/blob/main/configs/app.ini.example): `configs/app.ini.example`
- [Service unit](https://github.com/athul675/gitea/blob/main/configs/gitea.service): `configs/gitea.service`
- **Git repositories**

### Quota enforcement

- [Hook installer](https://github.com/athul675/gitea/blob/main/scripts/install-hooks.sh): `scripts/install-hooks.sh`
- [Pre-receive check](https://github.com/athul675/gitea/blob/main/scripts/quota-pre-receive): `scripts/quota-pre-receive`
- [Post-receive accounting](https://github.com/athul675/gitea/blob/main/scripts/quota-post-receive): `scripts/quota-post-receive`

### Quota persistence

- **PostgreSQL**
- [Quota schema](https://github.com/athul675/gitea/blob/main/sql/01_schema.sql): `sql/01_schema.sql`
- [Quota allocation](https://github.com/athul675/gitea/blob/main/sql/02_seed_quotas.sql): `sql/02_seed_quotas.sql`

### Other components

- **Git client**

## Connections

- Git client → Nginx proxy: sends HTTP (evidence: `README.md`)
- Nginx proxy → Gitea server: proxies traffic (evidence: `README.md`)
- Gitea server → Git repositories: manages repositories (evidence: `README.md`)
- Gitea server → PostgreSQL: uses database (evidence: `README.md`)
- Gitea server → Pre-receive check: runs hook (evidence: `README.md`)
- Gitea server → Post-receive accounting: runs hook (evidence: `README.md`)
- Hook installer → Pre-receive check: installs centrally (evidence: `README.md`)
- Hook installer → Post-receive accounting: installs centrally (evidence: `README.md`)
- Pre-receive check → PostgreSQL: checks and reserves (evidence: `README.md`)
- Post-receive accounting → PostgreSQL: tracks usage (evidence: `README.md`)
- Quota schema → PostgreSQL: defines tables (evidence: `README.md`)
- Quota allocation → PostgreSQL: seeds quotas (evidence: `README.md`)
- Fail2ban filter → Fail2ban jail: filters jail events (evidence: `README.md`)
- Fail2ban filter → Gitea server: mitigates threats (evidence: `README.md`)
