# ilyassokhlal/companion-pet-health-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/ilyassokhlal/companion-pet-health-tracker
- Repository: https://github.com/ilyassokhlal/companion-pet-health-tracker

## Overview

Companion is a shared-API pet health tracker with web and Android clients. Owners authenticate, manage pet profiles and health records, use photo galleries and reminders, track weight, walks, feeding and expenses, and ask a reference-grounded AI assistant questions about their pets. Premium access and account administration are additional product capabilities. The README documents the cross-client workflow and feature set; source excerpts and the index confirm key backend entry points and internal dependencies, but many domain routers and client screens were not sampled.

Main entry points: [`backend/main.py`](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/main.py) (FastAPI service), [`backend/routers/records.py`](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/records.py) (Pets and records), [`frontend-web/src/App.tsx`](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-web/src/App.tsx) (Web app), [`frontend-mobile/src/app/(tabs)/index.tsx`](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-mobile/src/app/(tabs)/index.tsx) (Android app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Owner clients"]
  node_web["Web app<br/>[App.tsx]"]
  node_mobile["Android app<br/>[index.tsx]"]
  node_webapi["Web API client<br/>[client.ts]"]
  node_mobileapi["Mobile API client<br/>[client.ts]"]
end

subgraph group_api["API and identity"]
  node_server["FastAPI service<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_session["Session security<br/>[security.py]"]
end

subgraph group_petdata["Pet records and tracking"]
  node_petrecords["Pets and records<br/>[records.py]"]
  node_tracking["Activity tracking"]
  node_photos["Photo processing<br/>[photos.py]"]
  node_reminders["Scheduling reminders<br/>[reminders.py]"]
  node_exports["Owner exports<br/>[export.py]"]
end

subgraph group_assistant["Care assistant"]
  node_rag["RAG answer pipeline<br/>[rag.py]"]
  node_ask["Pet question endpoint<br/>[ask.py]"]
end

subgraph group_operations["Access and operations"]
  node_store[("SQL database<br/>[database.py]")]
  node_models["Domain models<br/>[models.py]"]
  node_access["Premium and limits<br/>[access.py]"]
  node_billing["Billing integration<br/>[billing.py]"]
  node_email["Email reminders<br/>[mailer.py]"]
  node_admin["Admin dashboard<br/>[admin.py]"]
end

node_owner(("Pet owner"))

node_owner -->|"uses"| node_web
node_owner -->|"uses"| node_mobile
node_web -.->|"requests"| node_webapi
node_mobile -.->|"requests"| node_mobileapi
node_webapi -->|"calls shared API"| node_server
node_mobileapi -->|"calls shared API"| node_server
node_server -->|"routes"| node_auth
node_auth -->|"authenticates"| node_session
node_server -->|"routes"| node_petrecords
node_server -->|"routes"| node_tracking
node_petrecords -->|"processes uploads"| node_photos
node_petrecords -->|"exports data"| node_exports
node_server -->|"routes"| node_ask
node_ask -->|"gets grounded answers"| node_rag
node_server -->|"routes"| node_billing
node_billing -->|"checks account access"| node_access
node_server -->|"opens sessions"| node_store
node_store -->|"maps domain data"| node_models
node_server -->|"schedules jobs"| node_reminders
node_reminders -->|"sends reminders"| node_email
node_owner -->|"uses private dashboard"| node_admin

click node_web "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-web/src/App.tsx"
click node_mobile "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-mobile/src/app/(tabs)/index.tsx"
click node_webapi "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-web/src/api/client.ts"
click node_mobileapi "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-mobile/src/api/client.ts"
click node_server "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/main.py"
click node_auth "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/auth.py"
click node_session "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/security.py"
click node_petrecords "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/records.py"
click node_tracking "https://github.com/ilyassokhlal/companion-pet-health-tracker/tree/main/backend/routers"
click node_photos "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/photos.py"
click node_reminders "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/reminders.py"
click node_exports "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/export.py"
click node_rag "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/rag.py"
click node_ask "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/ask.py"
click node_store "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/database.py"
click node_models "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/models/models.py"
click node_access "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/access.py"
click node_billing "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/billing.py"
click node_email "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/mailer.py"
click node_admin "https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/admin.py"

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_web,node_mobile,node_webapi,node_mobileapi toneBlue
class node_server,node_auth,node_session toneAmber
class node_petrecords,node_tracking,node_photos,node_reminders,node_exports toneMint
class node_rag,node_ask toneRose
class node_store,node_models,node_access,node_billing,node_email,node_admin,node_owner toneIndigo
```

## Components

### Owner clients

- [Web app](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-web/src/App.tsx): `frontend-web/src/App.tsx`
- [Android app](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-mobile/src/app/(tabs)/index.tsx): `frontend-mobile/src/app/(tabs)/index.tsx`
- [Web API client](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-web/src/api/client.ts): `frontend-web/src/api/client.ts`
- [Mobile API client](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/frontend-mobile/src/api/client.ts): `frontend-mobile/src/api/client.ts`

### API and identity

- [FastAPI service](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/main.py): `backend/main.py`
- [Authentication](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/auth.py): `backend/routers/auth.py`
- [Session security](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/security.py): `backend/utils/security.py`

### Pet records and tracking

- [Pets and records](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/records.py): `backend/routers/records.py`
- [Activity tracking](https://github.com/ilyassokhlal/companion-pet-health-tracker/tree/main/backend/routers): `backend/routers`
- [Photo processing](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/photos.py): `backend/utils/photos.py`
- [Scheduling reminders](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/reminders.py): `backend/utils/reminders.py`
- [Owner exports](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/export.py): `backend/utils/export.py`

### Care assistant

- [RAG answer pipeline](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/rag.py): `backend/rag.py`
- [Pet question endpoint](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/ask.py): `backend/routers/ask.py`

### Access and operations

- [SQL database](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/database.py): `backend/database.py`
- [Domain models](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/models/models.py): `backend/models/models.py`
- [Premium and limits](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/access.py): `backend/utils/access.py`
- [Billing integration](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/routers/billing.py): `backend/routers/billing.py`
- [Email reminders](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/utils/mailer.py): `backend/utils/mailer.py`
- [Admin dashboard](https://github.com/ilyassokhlal/companion-pet-health-tracker/blob/main/backend/admin.py): `backend/admin.py`

### Other components

- **Pet owner**

## Connections

- Pet owner → Web app: uses (evidence: `README.md`)
- Pet owner → Android app: uses (evidence: `README.md`)
- Web app → Web API client: requests
- Android app → Mobile API client: requests
- Web API client → FastAPI service: calls shared API (evidence: `README.md`)
- Mobile API client → FastAPI service: calls shared API (evidence: `README.md`)
- FastAPI service → Authentication: routes (evidence: `backend/main.py`)
- Authentication → Session security: authenticates (evidence: `backend/routers/auth.py`)
- FastAPI service → Pets and records: routes (evidence: `backend/main.py`)
- FastAPI service → Activity tracking: routes (evidence: `backend/main.py`)
- Pets and records → Photo processing: processes uploads (evidence: `backend/routers/records.py`)
- Pets and records → Owner exports: exports data (evidence: `backend/routers/records.py`)
- FastAPI service → Pet question endpoint: routes (evidence: `backend/main.py`)
- Pet question endpoint → RAG answer pipeline: gets grounded answers (evidence: `backend/routers/ask.py`)
- FastAPI service → Billing integration: routes (evidence: `backend/main.py`)
- Billing integration → Premium and limits: checks account access (evidence: `backend/routers/billing.py`)
- FastAPI service → SQL database: opens sessions (evidence: `backend/main.py`)
- SQL database → Domain models: maps domain data (evidence: `backend/models/models.py`)
- FastAPI service → Scheduling reminders: schedules jobs (evidence: `backend/main.py`)
- Scheduling reminders → Email reminders: sends reminders (evidence: `backend/utils/reminders.py`)
- Pet owner → Admin dashboard: uses private dashboard (evidence: `README.md`)
