# renan-gimenez/librarium architecture

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

- Interactive diagram: https://gitdiagram.com/renan-gimenez/librarium
- Repository: https://github.com/renan-gimenez/librarium

## Overview

Librarium is a book-catalog browser with an AI chat assistant. A visitor searches, filters, sorts, and pages through books, opens book details or similar-book discovery, and can ask the assistant about the catalog. The API also exposes genre and book administration, including embedding reindexing. The graph separates the web experience, catalog API, chat subsystem, and shared UI. Several client-service and persistence details are not shown in the excerpts, so those connections are omitted rather than assumed.

Main entry points: [`apps/web/src/app.tsx`](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/app.tsx) (Catalog app), [`apps/api/src/modules/chat/chat.service.ts`](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.service.ts) (Chat processing), [`packages/ui/src`](https://github.com/renan-gimenez/librarium/tree/main/packages/ui/src) (UI components), [`apps/api/src/modules/book/book.service.ts`](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/book/book.service.ts) (Book operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Catalog app<br/>[app.tsx]"]
  node_bookqueries["Book queries<br/>[use-books.ts]"]
  node_bookservices["Book services<br/>[books.ts]"]
  node_chatdrawer["Chat drawer<br/>[chat-drawer.tsx]"]
  node_chatsession["Chat session"]
  node_chatservices["Chat services<br/>[chat.ts]"]
  node_bookviews["Book views<br/>[book-grid.tsx]"]
  node_bookcard["Book card<br/>[book-card.tsx]"]
  node_bookdetails["Book details"]
  node_filters["Catalog filters<br/>[filter-bar.tsx]"]
  node_header["Search header<br/>[header.tsx]"]
  node_pagination["Pagination<br/>[pagination.tsx]"]
end

subgraph group_catalog["Catalog API"]
  node_bookroutes["Book routes<br/>[book.routes.ts]"]
  node_booklogic["Book operations<br/>[book.service.ts]"]
  node_genreroutes["Genre routes<br/>[genre.routes.ts]"]
  node_database[("Catalog database<br/>[prisma.ts]")]
end

subgraph group_chat["Chat assistant"]
  node_chatroutes["Chat routes<br/>[chat.routes.ts]"]
  node_chatlogic["Chat processing<br/>[chat.service.ts]"]
  node_chatprompts["Prompt building<br/>[chat.prompts.ts]"]
  node_chattools["Catalog tools<br/>[chat.tools.ts]"]
  node_redis[("Session cache<br/>[redis.ts]")]
  node_openai["OpenAI service<br/>[openai.ts]"]
end

subgraph group_ui["Shared UI"]
  node_uikit["UI components"]
end

node_visitor(("Visitor"))

node_visitor -->|"uses"| node_webapp
node_webapp -->|"queries"| node_bookqueries
node_webapp -->|"renders"| node_header
node_webapp -->|"renders"| node_filters
node_webapp -->|"renders"| node_bookviews
node_webapp -->|"renders"| node_pagination
node_webapp -->|"renders"| node_bookdetails
node_webapp -->|"renders"| node_chatdrawer
node_bookviews -->|"renders"| node_bookcard
node_bookdetails -->|"uses"| node_uikit
node_chatdrawer -->|"uses"| node_uikit
node_filters -->|"uses"| node_uikit
node_header -->|"uses"| node_uikit
node_bookroutes -->|"calls"| node_booklogic
node_genreroutes -->|"reads/writes"| node_database
node_chatroutes -->|"calls"| node_chatlogic
node_chatlogic -->|"builds prompts"| node_chatprompts
node_chatlogic -->|"uses tools"| node_chattools
node_chattools -->|"queries catalog"| node_booklogic
node_booklogic -.->|"reads/writes"| node_database
node_chatlogic -.->|"stores sessions"| node_redis
node_chatlogic -.->|"requests completions"| node_openai

click node_webapp "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/app.tsx"
click node_bookqueries "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/hooks/use-books.ts"
click node_bookservices "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/services/books.ts"
click node_chatdrawer "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/chat-drawer.tsx"
click node_chatsession "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/hooks/use-chat-session.ts"
click node_chatservices "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/services/chat.ts"
click node_bookviews "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/book-grid.tsx"
click node_bookcard "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/book-card.tsx"
click node_bookdetails "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/book-details-modal.tsx"
click node_filters "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/filter-bar.tsx"
click node_header "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/header.tsx"
click node_pagination "https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/pagination.tsx"
click node_bookroutes "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/book/book.routes.ts"
click node_booklogic "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/book/book.service.ts"
click node_genreroutes "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/genre/genre.routes.ts"
click node_chatroutes "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.routes.ts"
click node_chatlogic "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.service.ts"
click node_chatprompts "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.prompts.ts"
click node_chattools "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.tools.ts"
click node_database "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/lib/prisma.ts"
click node_redis "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/lib/redis.ts"
click node_openai "https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/lib/openai.ts"
click node_uikit "https://github.com/renan-gimenez/librarium/tree/main/packages/ui/src"

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_webapp,node_bookqueries,node_bookservices,node_chatdrawer,node_chatsession,node_chatservices,node_bookviews,node_bookcard,node_bookdetails,node_filters,node_header,node_pagination toneBlue
class node_bookroutes,node_booklogic,node_genreroutes,node_database toneAmber
class node_chatroutes,node_chatlogic,node_chatprompts,node_chattools,node_redis,node_openai toneMint
class node_uikit toneRose
class node_visitor toneIndigo
```

## Components

### Web experience

- [Catalog app](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/app.tsx): `apps/web/src/app.tsx`
- [Book queries](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/hooks/use-books.ts): `apps/web/src/hooks/use-books.ts`
- [Book services](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/services/books.ts): `apps/web/src/services/books.ts`
- [Chat drawer](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/chat-drawer.tsx): `apps/web/src/components/chat-drawer.tsx`
- [Chat session](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/hooks/use-chat-session.ts): `apps/web/src/hooks/use-chat-session.ts`
- [Chat services](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/services/chat.ts): `apps/web/src/services/chat.ts`
- [Book views](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/book-grid.tsx): `apps/web/src/components/book-grid.tsx`
- [Book card](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/book-card.tsx): `apps/web/src/components/book-card.tsx`
- [Book details](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/book-details-modal.tsx): `apps/web/src/components/book-details-modal.tsx`
- [Catalog filters](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/filter-bar.tsx): `apps/web/src/components/filter-bar.tsx`
- [Search header](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/header.tsx): `apps/web/src/components/header.tsx`
- [Pagination](https://github.com/renan-gimenez/librarium/blob/main/apps/web/src/components/pagination.tsx): `apps/web/src/components/pagination.tsx`

### Catalog API

- [Book routes](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/book/book.routes.ts): `apps/api/src/modules/book/book.routes.ts`
- [Book operations](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/book/book.service.ts): `apps/api/src/modules/book/book.service.ts`
- [Genre routes](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/genre/genre.routes.ts): `apps/api/src/modules/genre/genre.routes.ts`
- [Catalog database](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/lib/prisma.ts): `apps/api/src/lib/prisma.ts`

### Chat assistant

- [Chat routes](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.routes.ts): `apps/api/src/modules/chat/chat.routes.ts`
- [Chat processing](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.service.ts): `apps/api/src/modules/chat/chat.service.ts`
- [Prompt building](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.prompts.ts): `apps/api/src/modules/chat/chat.prompts.ts`
- [Catalog tools](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/modules/chat/chat.tools.ts): `apps/api/src/modules/chat/chat.tools.ts`
- [Session cache](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/lib/redis.ts): `apps/api/src/lib/redis.ts`
- [OpenAI service](https://github.com/renan-gimenez/librarium/blob/main/apps/api/src/lib/openai.ts): `apps/api/src/lib/openai.ts`

### Shared UI

- [UI components](https://github.com/renan-gimenez/librarium/tree/main/packages/ui/src): `packages/ui/src`

### Other components

- **Visitor**

## Connections

- Visitor → Catalog app: uses
- Catalog app → Book queries: queries (evidence: `apps/web/src/app.tsx`)
- Catalog app → Search header: renders (evidence: `apps/web/src/app.tsx`)
- Catalog app → Catalog filters: renders (evidence: `apps/web/src/app.tsx`)
- Catalog app → Book views: renders (evidence: `apps/web/src/app.tsx`)
- Catalog app → Pagination: renders (evidence: `apps/web/src/app.tsx`)
- Catalog app → Book details: renders (evidence: `apps/web/src/app.tsx`)
- Catalog app → Chat drawer: renders (evidence: `apps/web/src/app.tsx`)
- Book views → Book card: renders (evidence: `apps/web/src/components/book-grid.tsx`)
- Book details → UI components: uses (evidence: `apps/web/src/components/book-details-modal.tsx`)
- Chat drawer → UI components: uses (evidence: `apps/web/src/components/chat-drawer.tsx`)
- Catalog filters → UI components: uses (evidence: `apps/web/src/components/filter-bar.tsx`)
- Search header → UI components: uses (evidence: `apps/web/src/components/header.tsx`)
- Book routes → Book operations: calls (evidence: `apps/api/src/modules/book/book.routes.ts`)
- Genre routes → Catalog database: reads/writes (evidence: `apps/api/src/modules/genre/genre.routes.ts`)
- Chat routes → Chat processing: calls (evidence: `apps/api/src/modules/chat/chat.routes.ts`)
- Chat processing → Prompt building: builds prompts (evidence: `apps/api/src/modules/chat/chat.service.ts`)
- Chat processing → Catalog tools: uses tools (evidence: `apps/api/src/modules/chat/chat.service.ts`)
- Catalog tools → Book operations: queries catalog (evidence: `apps/api/src/modules/chat/chat.tools.ts`)
- Book operations → Catalog database: reads/writes
- Chat processing → Session cache: stores sessions
- Chat processing → OpenAI service: requests completions
