Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore document #6

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ PUBLIC_FIREBASE_APP_ID="1:585902608528:web:908698a423651bb865c815"
PUBLIC_FIREBASE_MEASUREMENT_ID="G-QFXF543DV8"

GOOGLE_APPLICATION_CREDENTIALS="service-account-file.example.json"
HUGGINGFACE_TOKEN="HUGGINGFACE_TOKEN"
OPENAI_BASE_URL="https://openai.api2d.net/v1"
HUGGINGFACE_TOKEN="hf_xxx"
OPENAI_BASE_URL="https://api.openai.com/v1"
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,27 @@ Ensure your code adheres to the project's linting and formatting rules:
pnpm lint
pnpm format
```

## Data Flow

We have four main components in the system: the browser, the server, Firestore, and R2 (S3-compatible storage).

- **Firestore and R2** are read-only for the browser. The difference is that Firestore is used on a push (subscribe) basis, while R2 is used on a pull (download) basis.
- The **server** is the only component that can write to Firestore and R2. The browser must communicate through the server to perform any write operations.

```mermaid
graph TD
browser -->|api| server
server -->|reference| browser
server -->|upload| R2
R2 -->|download| browser
Firestore -->|subscribe| browser
Firestore -->|read| server
server -->|write| Firestore
```

This data flow allows us to control data updates centrally while still leveraging Firestore's security rules and real-time capabilities for read operations.

## Data Model

The front-end data model between the browser and Firestore is straightforward. We aim to map application routes directly to Firestore document paths. This approach allows us to easily subscribe to the appropriate documents and collections in Firestore, optimizing the number of read operations since the front-end views only one document or collection at a time.
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@
"@sveltejs/kit": "^2.8.2",
"@sveltejs/vite-plugin-svelte": "^4.0.1",
"@tailwindcss/typography": "^0.5.15",
"@types/debug": "^4.1.12",
"@types/eslint": "^9.6.1",
"@types/qrcode": "^1.5.5",
"autoprefixer": "^10.4.20",
"debug": "^4.3.7",
"dotenv": "^16.4.5",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.0",
"firebase": "^11.0.2",
"firebase-admin": "^12.7.0",
"flowbite": "^2.5.2",
"flowbite-svelte": "^0.47.3",
"globals": "^15.12.0",
"html5-qrcode": "^2.3.8",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"lucide-svelte": "^0.454.0",
"mdsvex": "^0.11.2",
"openai": "^4.73.0",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-svelte": "^3.3.2",
Expand All @@ -44,17 +49,14 @@
"tailwindcss": "^3.4.15",
"typescript": "^5.7.2",
"typescript-eslint": "^8.15.0",
"vite": "^5.4.11"
"vite": "^5.4.11",
"zod": "^3.23.8"
},
"lint-staged": {
"*.{yml,yaml,json,js,ts,css,html,svelte}": [
"prettier --write",
"eslint --fix"
]
},
"packageManager": "pnpm@9.12.3",
"dependencies": {
"openai": "^4.73.0",
"zod": "^3.23.8"
}
"packageManager": "pnpm@9.12.3"
}
Loading