# eccealgo/calories-tracker-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/eccealgo/calories-tracker-v1
- Repository: https://github.com/eccealgo/calories-tracker-v1

## Overview

This repository is a web application for account registration/login and food-product lookup. The user-facing flow is signup or login through the React app, with profile recovery when a token exists; separately, product searches reach an Express endpoint that queries Open Food Facts. The backend also exposes person create/read/update/delete operations. The README is empty, and some route mounting and frontend-to-backend wiring are not shown, so those links are omitted or marked unverified rather than inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/App.tsx) (Route app), [`frontend/src/services/authService.ts`](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/services/authService.ts) (Auth requests), [`frontend/src/pages/authentification/Signup.tsx`](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/authentification/Signup.tsx) (Signup form), [`frontend/src/pages/authentification/Login.tsx`](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/authentification/Login.tsx) (Login form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["Route app<br/>[App.tsx]"]
  node_auth["Auth state<br/>[AuthContext.tsx]"]
  node_user["User profile state<br/>[UserContext.tsx]"]
  node_private["Private route<br/>[PrivateRoute.tsx]"]
  node_signup["Signup form<br/>[Signup.tsx]"]
  node_login["Login form<br/>[Login.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_header["Account header<br/>[Header.tsx]"]
  node_authservice["Auth requests<br/>[authService.ts]"]
  node_fetch["JSON transport<br/>[fetchJson.ts]"]
end

subgraph group_backend["Backend API"]
  node_backend["Express server<br/>[index.ts]"]
  node_personroutes["Person routes<br/>[personRouter.ts]"]
  node_personcontroller["Person controller"]
  node_personservice["Person service<br/>[personService.ts]"]
  node_personmodel["Person persistence<br/>[personModel.ts]"]
  node_persondb[("Person database<br/>[schema.prisma]")]
end

subgraph group_product["Product lookup"]
  node_productroutes["Product routes<br/>[productRouter.ts]"]
  node_productcontroller["Product controller"]
  node_productservice["Product search service<br/>[productService.ts]"]
end

node_visitor(("Visitor"))
node_off["Open Food Facts"]

node_visitor -->|"uses"| node_app
node_app -->|"provides"| node_auth
node_app -->|"provides"| node_user
node_app -->|"routes to"| node_signup
node_app -->|"routes to"| node_login
node_app -->|"guards route"| node_private
node_app -->|"routes to"| node_dashboard
node_signup -->|"submits to"| node_authservice
node_signup -->|"checks state"| node_auth
node_login -->|"authenticates via"| node_authservice
node_login -->|"updates profile"| node_user
node_user -->|"fetches profile"| node_authservice
node_authservice -->|"sends requests"| node_fetch
node_authservice -.->|"calls API"| node_backend
node_dashboard -->|"renders"| node_header
node_header -->|"reads state"| node_auth
node_backend -->|"imports routes"| node_personroutes
node_backend -->|"imports routes"| node_productroutes
node_personroutes -->|"dispatches to"| node_personcontroller
node_personcontroller -->|"calls"| node_personservice
node_personservice -->|"calls"| node_personmodel
node_personservice -.->|"queries"| node_persondb
node_productroutes -->|"dispatches to"| node_productcontroller
node_productcontroller -->|"calls"| node_productservice
node_productservice -->|"searches"| node_off

click node_app "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/App.tsx"
click node_auth "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_user "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/contexts/UserContext.tsx"
click node_private "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/components/PrivateRoute.tsx"
click node_signup "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/authentification/Signup.tsx"
click node_login "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/authentification/Login.tsx"
click node_dashboard "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/dashboard/Dashboard.tsx"
click node_header "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/components/layout/Header.tsx"
click node_authservice "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/services/authService.ts"
click node_fetch "https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/utils/fetchJson.ts"
click node_backend "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/index.ts"
click node_personroutes "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/routes/personRouter.ts"
click node_personcontroller "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/controllers/personController.ts"
click node_personservice "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/services/personService.ts"
click node_personmodel "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/models/personModel.ts"
click node_persondb "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/prisma/schema.prisma"
click node_productroutes "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/routes/productRouter.ts"
click node_productcontroller "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/controllers/productController.ts"
click node_productservice "https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/services/productService.ts"

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_app,node_auth,node_user,node_private,node_signup,node_login,node_dashboard,node_header,node_authservice,node_fetch toneBlue
class node_backend,node_personroutes,node_personcontroller,node_personservice,node_personmodel,node_persondb toneAmber
class node_productroutes,node_productcontroller,node_productservice toneMint
class node_visitor,node_off toneIndigo
```

## Components

### Web application

- [Route app](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth state](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`
- [User profile state](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/contexts/UserContext.tsx): `frontend/src/contexts/UserContext.tsx`
- [Private route](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/components/PrivateRoute.tsx): `frontend/src/components/PrivateRoute.tsx`
- [Signup form](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/authentification/Signup.tsx): `frontend/src/pages/authentification/Signup.tsx`
- [Login form](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/authentification/Login.tsx): `frontend/src/pages/authentification/Login.tsx`
- [Dashboard](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/pages/dashboard/Dashboard.tsx): `frontend/src/pages/dashboard/Dashboard.tsx`
- [Account header](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/components/layout/Header.tsx): `frontend/src/components/layout/Header.tsx`
- [Auth requests](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/services/authService.ts): `frontend/src/services/authService.ts`
- [JSON transport](https://github.com/eccealgo/calories-tracker-v1/blob/main/frontend/src/utils/fetchJson.ts): `frontend/src/utils/fetchJson.ts`

### Backend API

- [Express server](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Person routes](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/routes/personRouter.ts): `backend/src/routes/personRouter.ts`
- [Person controller](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/controllers/personController.ts): `backend/src/controllers/personController.ts`
- [Person service](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/services/personService.ts): `backend/src/services/personService.ts`
- [Person persistence](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/models/personModel.ts): `backend/src/models/personModel.ts`
- [Person database](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/prisma/schema.prisma): `backend/prisma/schema.prisma`

### Product lookup

- [Product routes](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/routes/productRouter.ts): `backend/src/routes/productRouter.ts`
- [Product controller](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/controllers/productController.ts): `backend/src/controllers/productController.ts`
- [Product search service](https://github.com/eccealgo/calories-tracker-v1/blob/main/backend/src/services/productService.ts): `backend/src/services/productService.ts`

### Other components

- **Visitor**
- **Open Food Facts**

## Connections

- Visitor → Route app: uses
- Route app → Auth state: provides (evidence: `frontend/src/App.tsx`)
- Route app → User profile state: provides (evidence: `frontend/src/App.tsx`)
- Route app → Signup form: routes to (evidence: `frontend/src/App.tsx`)
- Route app → Login form: routes to (evidence: `frontend/src/App.tsx`)
- Route app → Private route: guards route (evidence: `frontend/src/App.tsx`)
- Route app → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Signup form → Auth requests: submits to (evidence: `frontend/src/pages/authentification/Signup.tsx`)
- Signup form → Auth state: checks state (evidence: `frontend/src/pages/authentification/Signup.tsx`)
- Login form → Auth requests: authenticates via (evidence: `frontend/src/pages/authentification/Login.tsx`)
- Login form → User profile state: updates profile (evidence: `frontend/src/pages/authentification/Login.tsx`)
- User profile state → Auth requests: fetches profile (evidence: `frontend/src/contexts/UserContext.tsx`)
- Auth requests → JSON transport: sends requests (evidence: `frontend/src/services/authService.ts`)
- Auth requests → Express server: calls API
- Dashboard → Account header: renders (evidence: `frontend/src/pages/dashboard/Dashboard.tsx`)
- Account header → Auth state: reads state (evidence: `frontend/src/components/layout/Header.tsx`)
- Express server → Person routes: imports routes (evidence: `backend/src/index.ts`)
- Express server → Product routes: imports routes (evidence: `backend/src/index.ts`)
- Person routes → Person controller: dispatches to (evidence: `backend/src/routes/personRouter.ts`)
- Person controller → Person service: calls (evidence: `backend/src/controllers/personController.ts`)
- Person service → Person persistence: calls (evidence: `backend/src/services/personService.ts`)
- Person service → Person database: queries
- Product routes → Product controller: dispatches to (evidence: `backend/src/routes/productRouter.ts`)
- Product controller → Product search service: calls (evidence: `backend/src/controllers/productController.ts`)
- Product search service → Open Food Facts: searches (evidence: `backend/src/services/productService.ts`)
