Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
18697f3
Adding an initial gemini file
rafikhan Aug 13, 2025
3c46fac
Adding gemini generated documentation on the codebase
rafikhan Aug 18, 2025
e38f003
feat(deps): upgrade angular from v16 to v17
rafikhan Aug 18, 2025
205cb0c
feat(deps): upgrade angular from v17 to v18
rafikhan Aug 18, 2025
171cf38
feat(deps): upgrade angular from v18 to v19
rafikhan Aug 18, 2025
ca65876
feat(deps): upgrade angular from v19 to v20
rafikhan Aug 18, 2025
5e23179
feat(deps): upgrade @angular/cdk and @angular/material to v17
rafikhan Aug 18, 2025
e883e86
feat(deps): upgrade @angular/cdk and @angular/material to v18
rafikhan Aug 18, 2025
16a9bfb
feat(deps): upgrade @angular/cdk and @angular/material to v19
rafikhan Aug 18, 2025
bb9f421
feat(deps): upgrade @angular/cdk and @angular/material to v20
rafikhan Aug 18, 2025
74c0dfe
feat(deps): upgrade tooling dependencies
rafikhan Aug 18, 2025
ce7143e
feat(deps): upgrade backend dependencies
rafikhan Aug 18, 2025
c1cc976
feat(deps): upgrade rxjs and tslib
rafikhan Aug 18, 2025
e636409
fix(build): fixing build errors in app.module.ts caused by the recent…
rafikhan Aug 18, 2025
e199068
fix(styles): correct material styles and typography
rafikhan Aug 20, 2025
3c13462
docs: update and correct documentation
rafikhan Aug 20, 2025
7a2ef69
fix(app): address code review feedback
rafikhan Aug 20, 2025
6bcb27e
style(app): correct indentation of @Component decorators
rafikhan Aug 20, 2025
7cf2d13
chore(docs): Fixing angular urls
rafikhan Aug 20, 2025
e8669cc
chore(docs): Removing url paths that don't exist
rafikhan Aug 20, 2025
e887746
fix(tests): correct TestBed configuration for all components
rafikhan Aug 21, 2025
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
26 changes: 26 additions & 0 deletions firestore/GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Friendly Eats

A Firestore quickstart application for the web

- This folder contains the frontend logic
- `functions/` contains the backend logic
- `scripts/` has helper code for the firebase emulator

## Architecture
- Use `npm` for dependencies. Always ask before adding a new dependency.
- Use typescript for coding
- This is a simple Angular web application
- Source code is in `src/`

## Essential commands
- Build with `npm build`
- Run tests with `npm test`
- Format code with `npm fmt`

## Workflow
- Use a separate git branch for each major task
- Make small commits frequently
- Use conventional commits messages
- Format code files before making commits
- Ensure tests pass before making commits
- Changes to the frontend and backend should happen in separate commits
10 changes: 6 additions & 4 deletions firestore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Introduction

FriendlyEats is a restaurant recommendation app built on Firestore. It was built with the [Angular](https://angular.io/) Javascript framework, and can make use of [Firebase's Local Emulator Suite][emulator-docs] (specifically, the [Authentication](https://firebase.google.com/docs/emulator-suite/connect_auth), [Storage](https://firebase.google.com/docs/emulator-suite/connect_storage), [Functions](https://firebase.google.com/docs/emulator-suite/connect_functions), and [Firestore](https://firebase.google.com/docs/emulator-suite/connect_firestore) emulators) so that the quickstart can be run without needing to create a project in the [Firebase Console](https://console.firebase.google.com).
FriendlyEats is a restaurant recommendation app built on Firestore. It was built with the [Angular](https://angular.dev/) Javascript framework, and can make use of [Firebase's Local Emulator Suite][emulator-docs] (specifically, the [Authentication](https://firebase.google.com/docs/emulator-suite/connect_auth), [Storage](https://firebase.google.com/docs/emulator-suite/connect_storage), [Functions](https://firebase.google.com/docs/emulator-suite/connect_functions), and [Firestore](https://firebase.google.com/docs/emulator-suite/connect_firestore) emulators) so that the quickstart can be run without needing to create a project in the [Firebase Console](https://console.firebase.google.com).

For more information about Firestore visit the [Firestore docs][firestore-docs].

Expand Down Expand Up @@ -32,9 +32,9 @@ Follow these steps to setup and run the quickstart:
npm -g i firebase-tools
```

1. Install and build all project dependencies
1. Install all project dependencies
```bash
npm install && (cd functions && npm install)
npm install && (cd functions && npm install) && (cd scripts && npm install)
```

> **Note:** When modifying the contents of `functions/src`, be sure to run `npm run build` in the `functions/` directory so that Typescript changes can be compiled and present in the next emulator run.
Expand All @@ -49,7 +49,9 @@ Follow these steps to setup and run the quickstart:

Follow these steps to have a working version of the quickstart running with the Firebase console:

> **Note:** In the original application (that runs on the emulators), there is a Firebase Function that updates the `avgRating` field of a restaurant whenever that restaurant recieves a review. While **Authentication**, **Storage**, and **Firestore** are offered as free services through the Firebase console, using Firebase **Functions** on the Firebase Console requires a billing plan. There is a [free tier billing plan](https://firebase.google.com/pricing) that allows up to 2 million free function calls per month, but enabling this plan requires presenting payment information to Firebase. The following instructions, therefore, exclude those steps needed to deploy and host functions on the Firebase Console. All application functionality, other than the auto-updating `avgRating` field for restaurants, is conserved.
> **Note on Billing:** Firebase offers two main pricing plans: the Spark Plan (free) and the Blaze Plan (pay-as-you-go). The Spark Plan has a generous free tier for many services, including Cloud Functions. If you exceed the limits of the Spark Plan, your app's usage of that particular service will be capped for the rest of the billing cycle to prevent any charges. The Blaze Plan gives you the same free tier as the Spark Plan, but you are billed for any usage that exceeds those limits.
>
> For more information, see the [Firebase pricing page](https://firebase.google.com/pricing).

1. Create a new Firebase project in the [Firebase Console](https://console.firebase.google.com)

Expand Down
34 changes: 30 additions & 4 deletions firestore/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "friendly-eats-quickstart:build:production"
"buildTarget": "friendly-eats-quickstart:build:production"
},
"local":{
"browserTarget": "friendly-eats-quickstart:build:local"
"local": {
"buildTarget": "friendly-eats-quickstart:build:local"
}
},
"defaultConfiguration": "local"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "friendly-eats-quickstart:build"
"buildTarget": "friendly-eats-quickstart:build"
}
},
"test": {
Expand Down Expand Up @@ -102,5 +102,31 @@
},
"cli": {
"analytics": false
},
"schematics": {
"@schematics/angular:component": {
"type": "component"
},
"@schematics/angular:directive": {
"type": "directive"
},
"@schematics/angular:service": {
"type": "service"
},
"@schematics/angular:guard": {
"typeSeparator": "."
},
"@schematics/angular:interceptor": {
"typeSeparator": "."
},
"@schematics/angular:module": {
"typeSeparator": "."
},
"@schematics/angular:pipe": {
"typeSeparator": "."
},
"@schematics/angular:resolver": {
"typeSeparator": "."
}
}
}
21 changes: 21 additions & 0 deletions firestore/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Architecture

The Friendly Eats application is a full-stack application with a clear separation of concerns between the frontend, backend, and helper scripts.

## Frontend

The frontend is an [Angular](https://angular.dev/) application located in the root directory of the project. It is responsible for rendering the user interface and interacting with the Firebase services. For more details, see the [frontend documentation](./frontend.md).

## Backend

The backend consists of a set of [Firebase Functions](https://firebase.google.com/docs/functions) located in the `functions` directory. These functions are triggered by events in the Firestore database and are used to perform actions such as calculating the average rating of a restaurant. For more details, see the [backend documentation](./backend.md).

## Scripts

The `scripts` directory contains helper scripts for populating the Firestore database with mock data. This is useful for development and testing purposes.

## Integration

The frontend, backend, and scripts are integrated through the `firebase.json` file. This file configures the Firestore rules and indexes, the emulators, and the Firebase Functions.

For more information about the data model, see the [data model documentation](./data-model.md).
23 changes: 23 additions & 0 deletions firestore/docs/backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Backend

The backend of the Friendly Eats application consists of a set of [Firebase Functions](https://firebase.google.com/docs/functions).

## Commands

The following commands are available for the backend (run from the `functions` directory):

* `npm install`: Install dependencies.
* `npm run build`: Build the functions.
* `npm run serve`: Run the functions emulator.

## Functions

The Firebase Functions are located in the `functions/src/index.ts` file. Here is a brief overview of their purpose:

* **`updateNumRatings`**: This function is triggered when a new rating is added to a restaurant's `ratings` sub-collection. It recalculates the average rating for the restaurant and updates the `avgRating` and `numRatings` fields in the corresponding restaurant document.

## Note on Billing

Firebase offers two main pricing plans: the Spark Plan (free) and the Blaze Plan (pay-as-you-go). The Spark Plan has a generous free tier for many services, including Cloud Functions. If you exceed the limits of the Spark Plan, your app's usage of that particular service will be capped for the rest of the billing cycle to prevent any charges. The Blaze Plan gives you the same free tier as the Spark Plan, but you are billed for any usage that exceeds those limits.

For more information, see the [Firebase pricing page](https://firebase.google.com/pricing).
27 changes: 27 additions & 0 deletions firestore/docs/data-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Data Model

The Friendly Eats application uses two main collections in Firestore: `restaurants` and `ratings`.

## `restaurants`

This collection contains a document for each restaurant. The structure of a restaurant document is defined in the [`restaurant.ts`](../src/types/restaurant.ts) file.

* `id` (string): The unique identifier for the restaurant.
* `avgRating` (number): The average rating of the restaurant.
* `category` (string): The category of the restaurant (e.g., "Pizza", "Mexican").
* `city` (string): The city where the restaurant is located.
* `name` (string): The name of the restaurant.
* `numRatings` (number): The number of ratings the restaurant has received.
* `photo` (string): The URL of the restaurant's photo.
* `price` (number): The price range of the restaurant (1-4).

## `ratings`

This is a sub-collection of a restaurant document. It contains a document for each rating that a restaurant has received. The structure of a rating document is defined in the [`ratings.ts`](../src/types/ratings.ts) file.

* `id` (string, optional): The unique identifier for the rating.
* `rating` (number): The rating given by the user (1-5).
* `text` (string): The text of the review.
* `timestamp` (Date, optional): The timestamp of the review.
* `userId` (string, optional): The ID of the user who submitted the review.
* `userName` (string, optional): The name of the user who submitted the review.
30 changes: 30 additions & 0 deletions firestore/docs/frontend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Frontend

The frontend of the Friendly Eats application is an [Angular](https://angular.dev/) application.

## Commands

The following commands are available for the frontend:

* `npm install`: Install dependencies.
* `npm start`: Run the application with emulators.
* `npm run production`: Run the application against a production Firebase project.
* `npm test`: Run unit tests.
* `npm run fmt`: Format code.

## Components

The main Angular components are located in the `src/app` directory. Here is a brief overview of their roles:

* **`app.component`**: The root component of the application.
* **`homepage`**: The main page of the application, which displays a list of restaurants.
* **`restaurant-card`**: A card component that displays information about a single restaurant.
* **`restuarant-page`**: A page that displays the details of a single restaurant, including its reviews.
* **`review-list`**: A component that displays a list of reviews for a restaurant.
* **`filter-dialog`**: A dialog that allows users to filter the list of restaurants.
* **`sign-in-modal`**: A modal that allows users to sign in.
* **`submit-review-modal`**: A modal that allows users to submit a review.

## Firebase Connection

The frontend connects to Firebase services through the `firebaseConfig` object in the `src/environments/environment.default.ts` and `src/environments/environment.prod.ts` files. This object contains the Firebase project configuration.
32 changes: 32 additions & 0 deletions firestore/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Friendly Eats Documentation

Welcome to the documentation for the Friendly Eats application. This document provides a high-level overview of the project's purpose, architecture, and technology stack.

For more detailed information, please see the following documents:

* [Architecture](./architecture.md)
* [Frontend](./frontend.md)
* [Backend](./backend.md)
* [Data Model](./data-model.md)
* [Setup](./setup.md)

## Project Purpose

The Friendly Eats application is a demonstration of Firebase capabilities, specifically the JavaScript SDK, Firebase Auth, Firestore rules, and Firestore triggers. It is a simple restaurant review app where customers can anonymously find restaurants and read reviews. Once authenticated, they can create new restaurants and review them.

## Technology Stack

The application is built with the following technologies:

* **Language**: [TypeScript](https://www.typescriptlang.org/) - The primary programming language for the application.
* **Frontend**:
* [Angular](https://angular.dev/) - A popular web application framework. Please note that this project currently uses an older version of Angular, while the Firebase integrations are more recent.
* [Angular Material](https://material.angular.dev/) - UI component library for Angular.
* **Backend**: [Firebase Functions](https://firebase.google.com/docs/functions) - Serverless functions to extend Firebase services.
* **Database**: [Firestore](https://firebase.google.com/docs/firestore) - A flexible, scalable NoSQL cloud database.
* **Authentication**: [Firebase Authentication](https://firebase.google.com/docs/auth) - A service for managing user authentication.
* **Storage**: [Cloud Storage for Firebase](https://firebase.google.com/docs/storage) - A service for storing and serving user-generated content.
* **Tooling**:
* [npm](https://www.npmjs.com/) - Package manager for JavaScript.
* [Angular CLI](https://angular.dev/cli) - Command-line interface for Angular.
* [Firebase CLI](https://firebase.google.com/docs/cli) - Command-line interface for Firebase.
83 changes: 83 additions & 0 deletions firestore/docs/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Setup

This document provides step-by-step instructions for setting up the Friendly Eats application for local development.

## Prerequisites

* [Node.js](https://nodejs.org/en/download) (version 16.0 or higher)
* [Java](https://jdk.java.net/) (JDK version 11 or higher)
* [Angular CLI](https://angular.dev/cli)
* [Firebase CLI](https://firebase.google.com/docs/cli)

To install the CLIs globally, run the following commands:

```bash
npm install -g @angular/cli
npm install -g firebase-tools
```

## Installation

1. **Clone the repository:**

```bash
git clone https://github.com/firebase/quickstart-js.git
cd quickstart-js/firestore
```

2. **Install dependencies:**

```bash
npm install
(cd functions && npm install)
(cd scripts && npm install)
```

## Configuration

1. **Configure Firebase:**

The application can be run against the Firebase Local Emulator Suite or a production Firebase project.

* **Emulator Suite:** No configuration is needed. The necessary settings are in `src/environments/environment.default.ts`.

* **Production Project:**

1. Create a Firebase project in the [Firebase Console](https://console.firebase.google.com).
2. Copy the `firebaseConfig` object from your project settings.
3. Paste the `firebaseConfig` object into `src/environments/environment.prod.ts`.

## Running the Application

1. **Run the application:**

* **With emulators:**

```bash
npm start
```
This command will start the Firebase Emulator Suite and the Angular development server. The emulators are automatically populated with data from the `app-data-seed` directory on startup.

* **Against a production project:**

```bash
npm run production
```

2. **View the application:**

Open your browser and navigate to `http://localhost:4200`.

3. **Populating the database (optional):**

If you need to add more mock data to your database, you can use the following commands:

* **For emulators:**
```bash
npm run populate-emulators
```

* **For a production project:**
```bash
npm run populate-production
```
12 changes: 12 additions & 0 deletions firestore/functions/GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Friendly Eats backend logic

This folder contains the backend logic for the firestore friendly eats sample application. This folder should be considered separate from the frontend. It has separate essential commands for building and running the api server.

## Overview
- Source code is in `src/`
- The backend logic is a firebase function that uses firebase functions and firestore triggers

## Essential commands
- Build with `npm build`
- Run the api server through `npm run serve`
- There are no tests for this project
Loading
Loading