# k-rouma/agentix architecture

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

- Interactive diagram: https://gitdiagram.com/k-rouma/agentix
- Repository: https://github.com/k-rouma/agentix

## Overview

#### Purpose and runtime entry point
Agentix is a Python 3.12 FastAPI backend intended to orchestrate agent workflows (LangGraph is a declared platform dependency), with an initial tenant-scoped Notes API. The service starts at `app/main.py`; its health endpoint validates application dependencies before traffic is considered healthy.

#### Application composition
The codebase separates reusable platform concerns from business modules:
- Core infrastructure and cross-cutting concerns: `app/core/config.py`, `app/core/db.py`, `app/core/redis.py`.
- Business capabilities are isolated under `app/modules/`; the current vertical slice is Notes: `app/modules/notes/router.py`, `app/modules/notes/model.py`.
- `app/main.py` composes routers, lifecycle/dependency wiring, and health checks. Future agent, workflow, and RAG capabilities should follow the module boundary rather than expand core.

#### Request, auth, and tenancy flow
Requests enter FastAPI routes, then authentication dependencies construct a request auth context and enforce tenant identity:
- Auth abstraction and request dependencies: `app/core/auth/provider.py`, `app/core/auth/dependencies.py`, `app/core/auth/context.py`.
- Supabase-specific token validation/provider implementation: `app/core/auth/supabase_provider.py`.
- Tenant-aware domain routes consume this context; Notes is the concrete example in `app/modules/notes/router.py`.
This makes Supabase Auth an external identity boundary while application routes operate on normalized internal auth/tenant context.

#### Persistence and isolation
Postgres in managed Supabase Cloud is the system of record. Runtime API connections use the transaction pooler only, while Alembic uses a separate direct connection:
- Runtime database setup: `app/core/db.py`.
- Shared ORM model conventions and tenancy model: `app/core/models/base.py`, `app/core/models/tenancy.py`.
- Notes persistence model: `app/modules/notes/model.py`.
- Schema evolution source of truth: `alembic/env.py`, `alembic/versions/20260714_100000_tenancy.py`, `alembic/versions/20260714_100200_notes_rls_template.py`.
Tenancy is enforced at both application and database levels, including PostgreSQL RLS policies. The `vector` extension is provisioned through Alembic, not Supabase CLI migrations.

#### Infrastructure boundaries
Supabase Cloud supplies PostgreSQL, Auth, and potentially Storage; it is explicitly not self-hosted. Redis is the only local Docker dependency and is accessed through `app/core/redis.py`, with deployment definition at `docker/docker-compose.yml`. Configuration draws environment-specific secrets and endpoint URLs through `app/core/config.py`. `/health` exercises DB connectivity, Redis, and availability of the Postgres vector extension.

#### Schema and deployment control
Alembic exclusively owns database schema, extensions, RLS, and related database hooks:
- Migration configuration/runtime: `alembic.ini`, `alembic/env.py`.
- Vector extension migration: `alembic/versions/20260707_180120_create_vector_extension.py`.
- Auth access-token database hook: `alembic/versions/20260714_100100_access_token_hook.py`.
The Supabase CLI linkage/configuration in `supabase/config.toml` is administrative only; it must not become a competing schema-management path.

#### Architectural direction
The repository includes a broader planned agent platform—agent orchestration, tools, LLM management, memory, RAG, workflows, and domain modules—documented under `docs/Doc architecture/`. These are design targets rather than represented runtime components in the current application tree. The present foundation establishes the expected expansion pattern: generic infrastructure in `app/core/`, independently routable tenant-aware capabilities in `app/modules/`, and all durable data contracts expressed through Alembic migrations.

Main entry points: [`app/main.py`](https://github.com/k-rouma/agentix/blob/main/app/main.py) (FastAPI composition), [`app/core/auth/dependencies.py`](https://github.com/k-rouma/agentix/blob/main/app/core/auth/dependencies.py) (Auth dependencies), [`app/modules/notes/router.py`](https://github.com/k-rouma/agentix/blob/main/app/modules/notes/router.py) (Notes routes), [`app/core/db.py`](https://github.com/k-rouma/agentix/blob/main/app/core/db.py) (Runtime DB access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_main["FastAPI composition<br/>entrypoint<br/>[main.py]"]
  node_config["Configuration<br/>core config<br/>[config.py]"]
  node_db[("Runtime DB access<br/>database client<br/>[db.py]")]
  node_redis_client["Redis access<br/>cache client<br/>[redis.py]"]
  node_auth_dependencies["Auth dependencies<br/>request auth<br/>[dependencies.py]"]
  node_auth_context["Auth context<br/>tenant context<br/>[context.py]"]
  node_auth_provider["Auth provider contract<br/>auth abstraction<br/>[provider.py]"]
  node_supabase_provider["Supabase token provider<br/>auth implementation"]
  node_tenancy_models["ORM tenancy conventions<br/>shared models<br/>[tenancy.py]"]
end

subgraph group_notes["Notes Module"]
  node_notes_router["Notes routes<br/>tenant API<br/>[router.py]"]
  node_notes_model[("Notes model<br/>ORM model<br/>[model.py]")]
end

subgraph group_schema["Schema Control"]
  node_alembic_env["Alembic migration runtime<br/>schema migration<br/>[env.py]"]
  node_migrations["Schema migrations<br/>migration set"]
end

subgraph group_external["Infrastructure Boundaries"]
  node_supabase_postgres[("Supabase PostgreSQL<br/>system of record")]
  node_supabase_auth{{"Supabase Auth<br/>identity boundary"}}
  node_redis[("Redis<br/>local dependency<br/>[docker-compose.yml]")]
  node_supabase_cli["Supabase CLI config<br/>administrative config<br/>[config.toml]"]
end

node_architecture_docs["Planned agent platform<br/>design target<br/>[00_index.md]"]

node_main -->|"loads"| node_config
node_main -->|"wires"| node_db
node_main -->|"wires"| node_redis_client
node_main -->|"applies"| node_auth_dependencies
node_main -->|"mounts"| node_notes_router
node_main -.->|"health checks"| node_db
node_main -.->|"health checks"| node_redis_client
node_auth_dependencies -->|"constructs"| node_auth_context
node_auth_dependencies -->|"uses"| node_auth_provider
node_supabase_provider -->|"implements"| node_auth_provider
node_supabase_provider -->|"validates tokens with"| node_supabase_auth
node_notes_router -->|"requires"| node_auth_dependencies
node_notes_router -->|"reads and writes"| node_notes_model
node_notes_model -->|"follows"| node_tenancy_models
node_db -->|"transaction pooler"| node_supabase_postgres
node_redis_client -->|"connects to"| node_redis
node_alembic_env -->|"runs"| node_migrations
node_migrations -->|"creates schema, RLS, vector"| node_supabase_postgres
node_supabase_cli -.->|"administrative linkage"| node_supabase_postgres
node_architecture_docs -.->|"expansion pattern"| node_notes_router

click node_main "https://github.com/k-rouma/agentix/blob/main/app/main.py"
click node_config "https://github.com/k-rouma/agentix/blob/main/app/core/config.py"
click node_db "https://github.com/k-rouma/agentix/blob/main/app/core/db.py"
click node_redis_client "https://github.com/k-rouma/agentix/blob/main/app/core/redis.py"
click node_auth_dependencies "https://github.com/k-rouma/agentix/blob/main/app/core/auth/dependencies.py"
click node_auth_context "https://github.com/k-rouma/agentix/blob/main/app/core/auth/context.py"
click node_auth_provider "https://github.com/k-rouma/agentix/blob/main/app/core/auth/provider.py"
click node_supabase_provider "https://github.com/k-rouma/agentix/blob/main/app/core/auth/supabase_provider.py"
click node_notes_router "https://github.com/k-rouma/agentix/blob/main/app/modules/notes/router.py"
click node_notes_model "https://github.com/k-rouma/agentix/blob/main/app/modules/notes/model.py"
click node_tenancy_models "https://github.com/k-rouma/agentix/blob/main/app/core/models/tenancy.py"
click node_alembic_env "https://github.com/k-rouma/agentix/blob/main/alembic/env.py"
click node_migrations "https://github.com/k-rouma/agentix/blob/main/alembic/versions/20260714_100000_tenancy.py"
click node_redis "https://github.com/k-rouma/agentix/blob/main/docker/docker-compose.yml"
click node_supabase_cli "https://github.com/k-rouma/agentix/blob/main/supabase/config.toml"
click node_architecture_docs "https://github.com/k-rouma/agentix/blob/main/docs/Doc%20architecture/00_index.md"

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_main,node_config,node_db,node_redis_client,node_auth_dependencies,node_auth_context,node_auth_provider,node_supabase_provider,node_tenancy_models toneBlue
class node_notes_router,node_notes_model toneAmber
class node_alembic_env,node_migrations toneMint
class node_supabase_postgres,node_supabase_auth,node_redis,node_supabase_cli toneRose
class node_architecture_docs toneNeutral
```

## Components

### Application Runtime

- [FastAPI composition](https://github.com/k-rouma/agentix/blob/main/app/main.py): entrypoint · Composes routes, lifecycle wiring, and health checks. · `app/main.py`
- [Configuration](https://github.com/k-rouma/agentix/blob/main/app/core/config.py): core config · `app/core/config.py`
- [Runtime DB access](https://github.com/k-rouma/agentix/blob/main/app/core/db.py): database client · Uses the Supabase transaction pooler for API traffic. · `app/core/db.py`
- [Redis access](https://github.com/k-rouma/agentix/blob/main/app/core/redis.py): cache client · `app/core/redis.py`
- [Auth dependencies](https://github.com/k-rouma/agentix/blob/main/app/core/auth/dependencies.py): request auth · Builds normalized auth and tenant context for routes. · `app/core/auth/dependencies.py`
- [Auth context](https://github.com/k-rouma/agentix/blob/main/app/core/auth/context.py): tenant context · `app/core/auth/context.py`
- [Auth provider contract](https://github.com/k-rouma/agentix/blob/main/app/core/auth/provider.py): auth abstraction · `app/core/auth/provider.py`
- [Supabase token provider](https://github.com/k-rouma/agentix/blob/main/app/core/auth/supabase_provider.py): auth implementation · `app/core/auth/supabase_provider.py`
- [ORM tenancy conventions](https://github.com/k-rouma/agentix/blob/main/app/core/models/tenancy.py): shared models · Provides shared model and tenant conventions. · `app/core/models/tenancy.py`

### Notes Module

- [Notes routes](https://github.com/k-rouma/agentix/blob/main/app/modules/notes/router.py): tenant API · `app/modules/notes/router.py`
- [Notes model](https://github.com/k-rouma/agentix/blob/main/app/modules/notes/model.py): ORM model · `app/modules/notes/model.py`

### Schema Control

- [Alembic migration runtime](https://github.com/k-rouma/agentix/blob/main/alembic/env.py): schema migration · The exclusive schema-management path. · `alembic/env.py`
- [Schema migrations](https://github.com/k-rouma/agentix/blob/main/alembic/versions/20260714_100000_tenancy.py): migration set · Own extensions, RLS policies, tenancy, and auth hooks. · `alembic/versions/20260714_100000_tenancy.py`

### Infrastructure Boundaries

- **Supabase PostgreSQL**: system of record · Managed Postgres with RLS and vector extension.
- **Supabase Auth**: identity boundary
- [Redis](https://github.com/k-rouma/agentix/blob/main/docker/docker-compose.yml): local dependency · The only local Docker dependency. · `docker/docker-compose.yml`
- [Supabase CLI config](https://github.com/k-rouma/agentix/blob/main/supabase/config.toml): administrative config · Administrative linkage only; not a schema path. · `supabase/config.toml`

### Other components

- [Planned agent platform](https://github.com/k-rouma/agentix/blob/main/docs/Doc%20architecture/00_index.md): design target · Documents future agent, workflow, memory, and RAG modules. · `docs/Doc architecture/00_index.md`

## Connections

- FastAPI composition → Configuration: loads
- FastAPI composition → Runtime DB access: wires
- FastAPI composition → Redis access: wires
- FastAPI composition → Auth dependencies: applies
- FastAPI composition → Notes routes: mounts
- FastAPI composition → Runtime DB access: health checks
- FastAPI composition → Redis access: health checks
- Auth dependencies → Auth context: constructs
- Auth dependencies → Auth provider contract: uses
- Supabase token provider → Auth provider contract: implements
- Supabase token provider → Supabase Auth: validates tokens with
- Notes routes → Auth dependencies: requires
- Notes routes → Notes model: reads and writes
- Notes model → ORM tenancy conventions: follows
- Runtime DB access → Supabase PostgreSQL: transaction pooler
- Redis access → Redis: connects to
- Alembic migration runtime → Schema migrations: runs
- Schema migrations → Supabase PostgreSQL: creates schema, RLS, vector
- Supabase CLI config → Supabase PostgreSQL: administrative linkage
- Planned agent platform → Notes routes: expansion pattern
