# perlaanvi/memora-ai architecture

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

- Interactive diagram: https://gitdiagram.com/perlaanvi/memora-ai
- Repository: https://github.com/perlaanvi/memora-ai

## Overview

MEMORA is an AI personal second brain for capturing memories, documents, ideas, goals, and projects, then exploring them and asking questions grounded in stored memories. The principal question-answering path is ChatPage → server chat handler → RAG pipeline, which retrieves and prepares memory context before generating an answer. The app also offers dashboard, timeline, knowledge-graph, and settings experiences. The graph preserves documented product branches, but several page implementations and server services were not excerpted; their internal connections are omitted where the available evidence does not establish them.

Main entry points: [`server.ts`](https://github.com/perlaanvi/memora-ai/blob/main/server.ts) (Chat API handler), [`src/server/ragPipelineService.ts`](https://github.com/perlaanvi/memora-ai/blob/main/src/server/ragPipelineService.ts) (RAG orchestration), [`src/context/AuthContext.tsx`](https://github.com/perlaanvi/memora-ai/blob/main/src/context/AuthContext.tsx) (Authentication), [`src/services/firestoreService.ts`](https://github.com/perlaanvi/memora-ai/blob/main/src/services/firestoreService.ts) (Firestore access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_authscreen["Sign-in screen<br/>[AuthScreen.tsx]"]
  node_authcontext["Authentication<br/>[AuthContext.tsx]"]
end

subgraph group_experience["App experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_layout["Main layout<br/>[MainLayout.tsx]"]
  node_chat["Memory chat<br/>[ChatPage.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_knowledge["Knowledge graph view<br/>[KnowledgePage.tsx]"]
  node_settings["Settings<br/>[SettingsPage.tsx]"]
end

subgraph group_records["Personal records"]
  node_records["Memory and life records<br/>[AppContext.tsx]"]
  node_capture["Record capture"]
  node_otherpages["Goals, ideas, projects"]
  node_timeline["Timeline<br/>[TimelinePage.tsx]"]
  node_documents["Document vault<br/>[KnowledgePage.tsx]"]
end

subgraph group_ai["AI and retrieval"]
  node_server["Chat API handler<br/>[server.ts]"]
  node_rag["RAG orchestration"]
  node_semantic["Semantic retrieval"]
  node_embedding["Memory embeddings"]
  node_graphretrieval["Graph retrieval"]
  node_graphservice["Knowledge graph service"]
  node_temporalretrieval["Temporal retrieval"]
  node_temporal["Temporal metadata<br/>[temporalService.ts]"]
  node_rerank["Candidate reranking"]
end

subgraph group_storage["Persistence"]
  node_api["Client API<br/>[api.ts]"]
  node_firestoreclient["Firestore access"]
  node_firebase["Firebase setup<br/>[firebase.ts]"]
  node_firestore[("Cloud Firestore")]
end

node_person(("User"))
node_gemini["Gemini generation"]

node_person -->|"signs in"| node_authscreen
node_authscreen -->|"submits credentials"| node_authcontext
node_authcontext -->|"authenticates"| node_firebase
node_authcontext -->|"syncs profile"| node_firestoreclient
node_app -->|"checks session"| node_authcontext
node_app -->|"shows signed out"| node_authscreen
node_app -->|"shows signed in"| node_layout
node_person -->|"asks questions"| node_chat
node_chat -->|"uses app state"| node_records
node_chat -->|"requests answers"| node_api
node_server -->|"runs pipeline"| node_rag
node_rag -->|"retrieves memories"| node_semantic
node_rag -->|"reranks candidates"| node_rerank
node_server -->|"creates embeddings"| node_embedding
node_server -->|"retrieves memories"| node_semantic
node_server -->|"extracts metadata"| node_temporal
node_graphretrieval -->|"normalizes entities"| node_graphservice
node_temporalretrieval -->|"parses dates"| node_temporal
node_api -->|"delegates records"| node_firestoreclient
node_firestoreclient -->|"uses client setup"| node_firebase
node_firestoreclient -->|"reads and writes"| node_firestore
node_person -->|"records life events"| node_capture
node_person -->|"tracks goals and ideas"| node_otherpages
node_person -->|"reviews history"| node_timeline
node_person -->|"browses knowledge"| node_documents
node_rag -.->|"generates answer"| node_gemini

click node_authscreen "https://github.com/perlaanvi/memora-ai/blob/main/src/components/auth/AuthScreen.tsx"
click node_authcontext "https://github.com/perlaanvi/memora-ai/blob/main/src/context/AuthContext.tsx"
click node_app "https://github.com/perlaanvi/memora-ai/blob/main/src/App.tsx"
click node_layout "https://github.com/perlaanvi/memora-ai/blob/main/src/components/layout/MainLayout.tsx"
click node_chat "https://github.com/perlaanvi/memora-ai/blob/main/src/pages/ChatPage.tsx"
click node_dashboard "https://github.com/perlaanvi/memora-ai/blob/main/src/pages/DashboardPage.tsx"
click node_knowledge "https://github.com/perlaanvi/memora-ai/blob/main/src/pages/KnowledgePage.tsx"
click node_settings "https://github.com/perlaanvi/memora-ai/blob/main/src/pages/SettingsPage.tsx"
click node_records "https://github.com/perlaanvi/memora-ai/blob/main/src/context/AppContext.tsx"
click node_capture "https://github.com/perlaanvi/memora-ai/tree/main/src/components/modals"
click node_otherpages "https://github.com/perlaanvi/memora-ai/tree/main/src/pages"
click node_timeline "https://github.com/perlaanvi/memora-ai/blob/main/src/pages/TimelinePage.tsx"
click node_documents "https://github.com/perlaanvi/memora-ai/blob/main/src/pages/KnowledgePage.tsx"
click node_server "https://github.com/perlaanvi/memora-ai/blob/main/server.ts"
click node_rag "https://github.com/perlaanvi/memora-ai/blob/main/src/server/ragPipelineService.ts"
click node_semantic "https://github.com/perlaanvi/memora-ai/blob/main/src/server/semanticRetrievalService.ts"
click node_embedding "https://github.com/perlaanvi/memora-ai/blob/main/src/server/embeddingService.ts"
click node_graphretrieval "https://github.com/perlaanvi/memora-ai/blob/main/src/server/knowledgeGraphRetrievalService.ts"
click node_graphservice "https://github.com/perlaanvi/memora-ai/blob/main/src/server/knowledgeGraphService.ts"
click node_temporalretrieval "https://github.com/perlaanvi/memora-ai/blob/main/src/server/temporalRetrievalService.ts"
click node_temporal "https://github.com/perlaanvi/memora-ai/blob/main/src/server/temporalService.ts"
click node_rerank "https://github.com/perlaanvi/memora-ai/blob/main/src/server/huggingFaceService.ts"
click node_api "https://github.com/perlaanvi/memora-ai/blob/main/src/services/api.ts"
click node_firestoreclient "https://github.com/perlaanvi/memora-ai/blob/main/src/services/firestoreService.ts"
click node_firebase "https://github.com/perlaanvi/memora-ai/blob/main/src/services/firebase.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_authscreen,node_authcontext,node_person toneBlue
class node_app,node_layout,node_chat,node_dashboard,node_knowledge,node_settings toneAmber
class node_records,node_capture,node_otherpages,node_timeline,node_documents toneMint
class node_server,node_rag,node_semantic,node_embedding,node_graphretrieval,node_graphservice,node_temporalretrieval,node_temporal,node_rerank toneRose
class node_api,node_firestoreclient,node_firebase,node_firestore,node_gemini toneIndigo
```

## Components

### Identity

- [Sign-in screen](https://github.com/perlaanvi/memora-ai/blob/main/src/components/auth/AuthScreen.tsx): `src/components/auth/AuthScreen.tsx`
- [Authentication](https://github.com/perlaanvi/memora-ai/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`

### App experience

- [App shell](https://github.com/perlaanvi/memora-ai/blob/main/src/App.tsx): `src/App.tsx`
- [Main layout](https://github.com/perlaanvi/memora-ai/blob/main/src/components/layout/MainLayout.tsx): `src/components/layout/MainLayout.tsx`
- [Memory chat](https://github.com/perlaanvi/memora-ai/blob/main/src/pages/ChatPage.tsx): `src/pages/ChatPage.tsx`
- [Dashboard](https://github.com/perlaanvi/memora-ai/blob/main/src/pages/DashboardPage.tsx): `src/pages/DashboardPage.tsx`
- [Knowledge graph view](https://github.com/perlaanvi/memora-ai/blob/main/src/pages/KnowledgePage.tsx): `src/pages/KnowledgePage.tsx`
- [Settings](https://github.com/perlaanvi/memora-ai/blob/main/src/pages/SettingsPage.tsx): `src/pages/SettingsPage.tsx`

### Personal records

- [Memory and life records](https://github.com/perlaanvi/memora-ai/blob/main/src/context/AppContext.tsx): `src/context/AppContext.tsx`
- [Record capture](https://github.com/perlaanvi/memora-ai/tree/main/src/components/modals): `src/components/modals`
- [Goals, ideas, projects](https://github.com/perlaanvi/memora-ai/tree/main/src/pages): `src/pages`
- [Timeline](https://github.com/perlaanvi/memora-ai/blob/main/src/pages/TimelinePage.tsx): `src/pages/TimelinePage.tsx`
- [Document vault](https://github.com/perlaanvi/memora-ai/blob/main/src/pages/KnowledgePage.tsx): `src/pages/KnowledgePage.tsx`

### AI and retrieval

- [Chat API handler](https://github.com/perlaanvi/memora-ai/blob/main/server.ts): `server.ts`
- [RAG orchestration](https://github.com/perlaanvi/memora-ai/blob/main/src/server/ragPipelineService.ts): `src/server/ragPipelineService.ts`
- [Semantic retrieval](https://github.com/perlaanvi/memora-ai/blob/main/src/server/semanticRetrievalService.ts): `src/server/semanticRetrievalService.ts`
- [Memory embeddings](https://github.com/perlaanvi/memora-ai/blob/main/src/server/embeddingService.ts): `src/server/embeddingService.ts`
- [Graph retrieval](https://github.com/perlaanvi/memora-ai/blob/main/src/server/knowledgeGraphRetrievalService.ts): `src/server/knowledgeGraphRetrievalService.ts`
- [Knowledge graph service](https://github.com/perlaanvi/memora-ai/blob/main/src/server/knowledgeGraphService.ts): `src/server/knowledgeGraphService.ts`
- [Temporal retrieval](https://github.com/perlaanvi/memora-ai/blob/main/src/server/temporalRetrievalService.ts): `src/server/temporalRetrievalService.ts`
- [Temporal metadata](https://github.com/perlaanvi/memora-ai/blob/main/src/server/temporalService.ts): `src/server/temporalService.ts`
- [Candidate reranking](https://github.com/perlaanvi/memora-ai/blob/main/src/server/huggingFaceService.ts): `src/server/huggingFaceService.ts`

### Persistence

- [Client API](https://github.com/perlaanvi/memora-ai/blob/main/src/services/api.ts): `src/services/api.ts`
- [Firestore access](https://github.com/perlaanvi/memora-ai/blob/main/src/services/firestoreService.ts): `src/services/firestoreService.ts`
- [Firebase setup](https://github.com/perlaanvi/memora-ai/blob/main/src/services/firebase.ts): `src/services/firebase.ts`
- **Cloud Firestore**

### Other components

- **User**
- **Gemini generation**

## Connections

- User → Sign-in screen: signs in (evidence: `README.md`)
- Sign-in screen → Authentication: submits credentials (evidence: `src/components/auth/AuthScreen.tsx`)
- Authentication → Firebase setup: authenticates (evidence: `src/context/AuthContext.tsx`)
- Authentication → Firestore access: syncs profile (evidence: `src/context/AuthContext.tsx`)
- App shell → Authentication: checks session (evidence: `src/App.tsx`)
- App shell → Sign-in screen: shows signed out (evidence: `src/App.tsx`)
- App shell → Main layout: shows signed in (evidence: `src/App.tsx`)
- User → Memory chat: asks questions (evidence: `README.md`)
- Memory chat → Memory and life records: uses app state (evidence: `src/pages/ChatPage.tsx`)
- Memory chat → Client API: requests answers (evidence: `src/pages/ChatPage.tsx`)
- Chat API handler → RAG orchestration: runs pipeline (evidence: `server.ts`)
- RAG orchestration → Semantic retrieval: retrieves memories (evidence: `src/server/ragPipelineService.ts`)
- RAG orchestration → Candidate reranking: reranks candidates (evidence: `src/server/ragPipelineService.ts`)
- Chat API handler → Memory embeddings: creates embeddings (evidence: `server.ts`)
- Chat API handler → Semantic retrieval: retrieves memories (evidence: `server.ts`)
- Chat API handler → Temporal metadata: extracts metadata (evidence: `server.ts`)
- Graph retrieval → Knowledge graph service: normalizes entities (evidence: `src/server/knowledgeGraphRetrievalService.ts`)
- Temporal retrieval → Temporal metadata: parses dates (evidence: `src/server/temporalRetrievalService.ts`)
- Client API → Firestore access: delegates records (evidence: `src/services/api.ts`)
- Firestore access → Firebase setup: uses client setup (evidence: `src/services/firestoreService.ts`)
- Firestore access → Cloud Firestore: reads and writes (evidence: `README.md`)
- User → Record capture: records life events (evidence: `README.md`)
- User → Goals, ideas, projects: tracks goals and ideas (evidence: `README.md`)
- User → Timeline: reviews history (evidence: `README.md`)
- User → Document vault: browses knowledge (evidence: `README.md`)
- RAG orchestration → Gemini generation: generates answer
