# thepersonalaicompany/amurex-backend architecture

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

- Interactive diagram: https://gitdiagram.com/thepersonalaicompany/amurex-backend
- Repository: https://github.com/thepersonalaicompany/amurex-backend

## Overview

1. **High-level shape**
   - This repo is a **Python 3.11 backend service** for Amurex.
   - It is not a full product stack by itself; it provides the server-side runtime, database schema, and integrations needed by the Amurex client(s), likely the browser extension referenced in the README.

2. **Main application entrypoint**
   - `index.py` is the service entrypoint and is the place where request handling / orchestration starts.
   - The codebase appears intentionally small: most architectural weight is in external services and database integration rather than many internal modules.

3. **Persistence layer boundary**
   - `database/db_manager.py` is the main in-repo abstraction for data access.
   - The system’s primary persistent store is **Supabase Postgres**, not a local embedded database.
   - This makes Supabase the canonical system of record for user and meeting-related data.

4. **Database schema and domain model**
   - Schema is managed through Supabase migrations under `supabase/migrations`.
   - The migration names indicate these core domain tables:
     - `users`
     - `meetings`
     - `memories`
     - `tracking`
     - `late_meeting`
   - Architecturally, this suggests the backend tracks users, meeting metadata, meeting-derived context/memories, and some form of observability or late-meeting state.

5. **Meeting-context storage**
   - The README specifies a Supabase Storage bucket named `meeting_context_files`.
   - That bucket is a separate storage boundary from the Postgres tables and is used for file-based meeting context, attachments, or artifacts related to meetings.

6. **AI/model execution boundary**
   - The backend supports two AI execution modes controlled by `CLIENT_MODE`:
     - **ONLINE**: uses hosted model APIs such as **OpenAI**, **Groq**, and **Mistral**
     - **LOCAL**: uses **Ollama** for inference and **fast-embed** for embeddings
   - This is an important architectural switch: the service can run either as a cloud-integrated backend or a mostly local inference backend.

7. **Operational dependencies**
   - **Redis** is a required runtime dependency.
   - The repo does not show the Redis usage code, but its presence in prerequisites means the backend depends on it for transient state, coordination, caching, or background workflow support.
   - This is a distinct operational subsystem from Supabase persistence.

8. **Notification / outbound messaging**
   - The backend integrates with **Resend** via `RESEND_API_KEY` and `RESEND_NOREPLY`.
   - This implies an outbound email/notification path separate from the main database and AI flows.

9. **Configuration and secrets**
   - Runtime behavior is driven by environment variables in `.env` / `.env.example`.
   - Key configuration groups are:
     - Supabase credentials
     - Redis connection details
     - AI provider keys
     - Resend email settings
     - mode selection via `CLIENT_MODE`
   - This repo is therefore strongly environment-configured rather than hard-coded.

10. **Deployment topology**
   - The presence of `Dockerfile` and `compose.yaml` indicates the backend is intended to run in containers.
   - Docker Compose likely packages the service with its runtime dependencies, making local and hosted deployment symmetric.

11. **Repository boundary**
   - There is no frontend, no large service graph, and no explicit job worker code visible here.
   - The repo is best drawn as a **backend orchestration layer** sitting between:
     - external clients
     - Supabase/Postgres + Storage
     - Redis
     - AI providers or local model runtime
     - Resend for outbound email

12. **What to show in an architecture diagram**
   - Put **index.py / Python service** at the center.
   - Show **Supabase** as two parts: **Postgres tables** and **Storage bucket**.
   - Show **Redis** as an operational side dependency.
   - Show a forked AI path:
     - ONLINE → OpenAI/Groq/Mistral
     - LOCAL → Ollama + fast-embed
   - Show **Resend** as a separate outbound integration.
   - Show schema migrations as the mechanism that defines the persistent domain model, not as a runtime component.

Main entry points: [`supabase/migrations`](https://github.com/thepersonalaicompany/amurex-backend/tree/main/supabase/migrations) (Postgres), [`.env.example`](https://github.com/thepersonalaicompany/amurex-backend/blob/main/.env.example) (Mode Switch), [`index.py`](https://github.com/thepersonalaicompany/amurex-backend/blob/main/index.py) (Service), [`compose.yaml`](https://github.com/thepersonalaicompany/amurex-backend/blob/main/compose.yaml) (Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_index_py["Service<br/>python entrypoint<br/>[index.py]"]
  node_client_mode(("Mode Switch<br/>runtime config<br/>[.env.example]"))
end

subgraph group_data["Data"]
  node_db_manager["DB Manager<br/>data access<br/>[db_manager.py]"]
  node_supabase_postgres[("Postgres<br/>system of record")]
  node_supabase_storage[("File Store<br/>object storage")]
  node_users_table["Users<br/>schema table"]
  node_meetings_table["Meetings<br/>schema table"]
  node_memories_table["Memories<br/>schema table"]
  node_tracking_table["Tracking<br/>schema table"]
  node_late_meeting_table["Late Meeting<br/>schema table"]
end

subgraph group_integrations["Integrations"]
  node_openai_api(("OpenAI<br/>cloud model api"))
  node_groq_api(("Groq<br/>cloud model api"))
  node_mistral_api(("Mistral<br/>cloud model api"))
  node_ollama(("Ollama<br/>local inference"))
  node_fast_embed(("Fast Embed<br/>embedding runtime"))
  node_redis[("Redis<br/>cache/coordination")]
  node_resend(("Resend<br/>email api"))
end

subgraph group_deploy["Deploy"]
  node_dockerfile["Dockerfile<br/>container build"]
  node_compose["Compose<br/>deployment config<br/>[compose.yaml]"]
end

node_index_py -->|"uses"| node_db_manager
node_db_manager -->|"reads/writes"| node_supabase_postgres
node_supabase_postgres -.->|"defines"| node_users_table
node_supabase_postgres -.->|"defines"| node_meetings_table
node_supabase_postgres -.->|"defines"| node_memories_table
node_supabase_postgres -.->|"defines"| node_tracking_table
node_supabase_postgres -.->|"defines"| node_late_meeting_table
node_index_py -->|"stores files"| node_supabase_storage
node_index_py -->|"selects"| node_client_mode
node_client_mode -->|"online"| node_openai_api
node_client_mode -->|"online"| node_groq_api
node_client_mode -->|"online"| node_mistral_api
node_client_mode -->|"local"| node_ollama
node_client_mode -->|"local"| node_fast_embed
node_index_py -->|"depends on"| node_redis
node_index_py -->|"sends mail"| node_resend
node_dockerfile -->|"packages"| node_index_py
node_compose -->|"builds"| node_dockerfile
node_compose -->|"includes"| node_redis
node_compose -.->|"connects"| node_supabase_postgres

click node_index_py "https://github.com/thepersonalaicompany/amurex-backend/blob/main/index.py"
click node_db_manager "https://github.com/thepersonalaicompany/amurex-backend/blob/main/database/db_manager.py"
click node_supabase_postgres "https://github.com/thepersonalaicompany/amurex-backend/tree/main/supabase/migrations"
click node_users_table "https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20250206_init_users_table.sql"
click node_meetings_table "https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20241201195715_meetings.sql"
click node_memories_table "https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20240320000000_memories.sql"
click node_tracking_table "https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20240319000000_tracking_table.sql"
click node_late_meeting_table "https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20241209115823_late_meeting.sql"
click node_client_mode "https://github.com/thepersonalaicompany/amurex-backend/blob/main/.env.example"
click node_dockerfile "https://github.com/thepersonalaicompany/amurex-backend/tree/main/Dockerfile"
click node_compose "https://github.com/thepersonalaicompany/amurex-backend/blob/main/compose.yaml"

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_index_py,node_client_mode toneBlue
class node_db_manager,node_supabase_postgres,node_supabase_storage,node_users_table,node_meetings_table,node_memories_table,node_tracking_table,node_late_meeting_table toneAmber
class node_openai_api,node_groq_api,node_mistral_api,node_ollama,node_fast_embed,node_redis,node_resend toneMint
class node_dockerfile,node_compose toneRose
```

## Components

### Runtime

Python service and execution modes

- [Service](https://github.com/thepersonalaicompany/amurex-backend/blob/main/index.py): python entrypoint · Main backend entrypoint and orchestration hub · `index.py`
- [Mode Switch](https://github.com/thepersonalaicompany/amurex-backend/blob/main/.env.example): runtime config · Selects ONLINE cloud AI or LOCAL inference mode · `.env.example`

### Data

Persistence and schema

- [DB Manager](https://github.com/thepersonalaicompany/amurex-backend/blob/main/database/db_manager.py): data access · Repository abstraction over persistent reads and writes · `database/db_manager.py`
- [Postgres](https://github.com/thepersonalaicompany/amurex-backend/tree/main/supabase/migrations): system of record · Primary relational store backing users, meetings, memories, and tracking · `supabase/migrations`
- **File Store**: object storage · Meeting context files bucket in Supabase Storage
- [Users](https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20250206_init_users_table.sql): schema table · User identity and account records · `supabase/migrations/20250206_init_users_table.sql`
- [Meetings](https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20241201195715_meetings.sql): schema table · Meeting metadata and lifecycle records · `supabase/migrations/20241201195715_meetings.sql`
- [Memories](https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20240320000000_memories.sql): schema table · Meeting-derived context and persisted memory records · `supabase/migrations/20240320000000_memories.sql`
- [Tracking](https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20240319000000_tracking_table.sql): schema table · Operational tracking and observability state · `supabase/migrations/20240319000000_tracking_table.sql`
- [Late Meeting](https://github.com/thepersonalaicompany/amurex-backend/blob/main/supabase/migrations/20241209115823_late_meeting.sql): schema table · Late-meeting status and related handling · `supabase/migrations/20241209115823_late_meeting.sql`

### Integrations

External services and model providers

- **OpenAI**: cloud model api · Hosted model provider used in ONLINE mode
- **Groq**: cloud model api · Hosted model provider used in ONLINE mode
- **Mistral**: cloud model api · Hosted model provider used in ONLINE mode
- **Ollama**: local inference · Local model runtime used in LOCAL mode
- **Fast Embed**: embedding runtime · Local embedding backend used in LOCAL mode
- **Redis**: cache/coordination · Operational dependency for transient state or workflow support
- **Resend**: email api · Outbound email and notification delivery

### Deploy

Container and compose setup

- [Dockerfile](https://github.com/thepersonalaicompany/amurex-backend/tree/main/Dockerfile): container build · Container image definition for the backend · `Dockerfile`
- [Compose](https://github.com/thepersonalaicompany/amurex-backend/blob/main/compose.yaml): deployment config · Local multi-service runtime composition · `compose.yaml`

## Connections

- Service → DB Manager: uses · Entrypoint delegates persistence work to the DB abstraction
- DB Manager → Postgres: reads/writes · All primary domain data persists in Supabase Postgres
- Postgres → Users: defines · Users schema lives in migrations
- Postgres → Meetings: defines · Meetings schema lives in migrations
- Postgres → Memories: defines · Memories schema lives in migrations
- Postgres → Tracking: defines · Tracking schema lives in migrations
- Postgres → Late Meeting: defines · Late-meeting schema lives in migrations
- Service → File Store: stores files · Service can work with meeting context artifacts in storage
- Service → Mode Switch: selects · Runtime chooses AI path based on environment mode
- Mode Switch → OpenAI: online · ONLINE mode can use hosted providers
- Mode Switch → Groq: online · ONLINE mode can use hosted providers
- Mode Switch → Mistral: online · ONLINE mode can use hosted providers
- Mode Switch → Ollama: local · LOCAL mode uses Ollama for inference
- Mode Switch → Fast Embed: local · LOCAL mode uses local embeddings
- Service → Redis: depends on · Backend requires Redis as an operational dependency
- Service → Resend: sends mail · Outbound email/notification integration
- Dockerfile → Service: packages · Container image runs the Python service
- Compose → Dockerfile: builds · Compose defines the service container setup
- Compose → Redis: includes · Local deployment likely brings up Redis alongside the service
- Compose → Postgres: connects · Deployment expects the backend to reach Supabase persistence
