Skip to content

Commit 3c46fac

Browse files
committed
Adding gemini generated documentation on the codebase
1 parent 18697f3 commit 3c46fac

File tree

9 files changed

+204
-32
lines changed

9 files changed

+204
-32
lines changed

firestore/.gemini/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

firestore/.gemini/agents/discover-and-doc.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

firestore/docs/architecture.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Architecture
2+
3+
The Friendly Eats application is a full-stack application with a clear separation of concerns between the frontend, backend, and helper scripts.
4+
5+
## Frontend
6+
7+
The frontend is an [Angular](https://angular.io/) 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).
8+
9+
## Backend
10+
11+
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).
12+
13+
## Scripts
14+
15+
The `scripts` directory contains helper scripts for populating the Firestore database with mock data. This is useful for development and testing purposes.
16+
17+
## Integration
18+
19+
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.
20+
21+
For more information about the data model, see the [data model documentation](./data-model.md).

firestore/docs/backend.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Backend
2+
3+
The backend of the Friendly Eats application consists of a set of [Firebase Functions](https://firebase.google.com/docs/functions).
4+
5+
## Commands
6+
7+
The following commands are available for the backend (run from the `functions` directory):
8+
9+
* `npm install`: Install dependencies.
10+
* `npm run build`: Build the functions.
11+
* `npm run serve`: Run the functions emulator.
12+
13+
## Functions
14+
15+
The Firebase Functions are located in the `functions/src/index.ts` file. Here is a brief overview of their purpose:
16+
17+
* **`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.

firestore/docs/data-model.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Data Model
2+
3+
The Friendly Eats application uses two main collections in Firestore: `restaurants` and `ratings`.
4+
5+
## `restaurants`
6+
7+
This collection contains a document for each restaurant. The structure of a restaurant document is as follows:
8+
9+
* `id` (string): The unique identifier for the restaurant.
10+
* `avgRating` (number): The average rating of the restaurant.
11+
* `category` (string): The category of the restaurant (e.g., "Pizza", "Mexican").
12+
* `city` (string): The city where the restaurant is located.
13+
* `name` (string): The name of the restaurant.
14+
* `numRatings` (number): The number of ratings the restaurant has received.
15+
* `photo` (string): The URL of the restaurant's photo.
16+
* `price` (number): The price range of the restaurant (1-4).
17+
18+
## `ratings`
19+
20+
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 as follows:
21+
22+
* `id` (string, optional): The unique identifier for the rating.
23+
* `rating` (number): The rating given by the user (1-5).
24+
* `text` (string): The text of the review.
25+
* `timestamp` (Date, optional): The timestamp of the review.
26+
* `userId` (string, optional): The ID of the user who submitted the review.
27+
* `userName` (string, optional): The name of the user who submitted the review.

firestore/docs/frontend.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Frontend
2+
3+
The frontend of the Friendly Eats application is an [Angular](https://angular.io/) application.
4+
5+
## Commands
6+
7+
The following commands are available for the frontend:
8+
9+
* `npm install`: Install dependencies.
10+
* `npm start`: Run the application with emulators.
11+
* `npm run production`: Run the application against a production Firebase project.
12+
* `npm test`: Run unit tests.
13+
* `npm run fmt`: Format code.
14+
15+
## Components
16+
17+
The main Angular components are located in the `src/app` directory. Here is a brief overview of their roles:
18+
19+
* **`app.component`**: The root component of the application.
20+
* **`homepage`**: The main page of the application, which displays a list of restaurants.
21+
* **`restaurant-card`**: A card component that displays information about a single restaurant.
22+
* **`restuarant-page`**: A page that displays the details of a single restaurant, including its reviews.
23+
* **`review-list`**: A component that displays a list of reviews for a restaurant.
24+
* **`filter-dialog`**: A dialog that allows users to filter the list of restaurants.
25+
* **`sign-in-modal`**: A modal that allows users to sign in.
26+
* **`submit-review-modal`**: A modal that allows users to submit a review.
27+
28+
## Firebase Connection
29+
30+
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.

firestore/docs/overview.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Friendly Eats Documentation
2+
3+
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.
4+
5+
For more detailed information, please see the following documents:
6+
7+
* [Architecture](./architecture.md)
8+
* [Frontend](./frontend.md)
9+
* [Backend](./backend.md)
10+
* [Data Model](./data-model.md)
11+
* [Setup](./setup.md)
12+
13+
## Project Purpose
14+
15+
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.
16+
17+
## Technology Stack
18+
19+
The application is built with the following technologies:
20+
21+
* **Language**: [TypeScript](https://www.typescriptlang.org/) - The primary programming language for the application.
22+
* **Frontend**:
23+
* [Angular](https://angular.io/) - A popular web application framework. Please note that this project currently uses an older version of Angular, while the Firebase integrations are more recent.
24+
* [Angular Material](https://material.angular.io/) - UI component library for Angular.
25+
* **Backend**: [Firebase Functions](https://firebase.google.com/docs/functions) - Serverless functions to extend Firebase services.
26+
* **Database**: [Firestore](https://firebase.google.com/docs/firestore) - A flexible, scalable NoSQL cloud database.
27+
* **Authentication**: [Firebase Authentication](https://firebase.google.com/docs/auth) - A service for managing user authentication.
28+
* **Storage**: [Cloud Storage for Firebase](https://firebase.google.com/docs/storage) - A service for storing and serving user-generated content.
29+
* **Tooling**:
30+
* [npm](https://www.npmjs.com/) - Package manager for JavaScript.
31+
* [Angular CLI](https://angular.io/cli) - Command-line interface for Angular.
32+
* [Firebase CLI](https://firebase.google.com/docs/cli) - Command-line interface for Firebase.

firestore/docs/setup.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Setup
2+
3+
This document provides step-by-step instructions for setting up the Friendly Eats application for local development.
4+
5+
## Prerequisites
6+
7+
* [Node.js](https://nodejs.org/en/download) (version 16.0 or higher)
8+
* [Java](https://jdk.java.net/) (JDK version 11 or higher)
9+
* [Angular CLI](https://angular.io/cli)
10+
* [Firebase CLI](https://firebase.google.com/docs/cli)
11+
12+
## Installation
13+
14+
1. **Clone the repository:**
15+
16+
```bash
17+
git clone https://github.com/firebase/quickstart-js.git
18+
cd quickstart-js/firestore
19+
```
20+
21+
2. **Install dependencies:**
22+
23+
```bash
24+
npm install
25+
(cd functions && npm install)
26+
(cd scripts && npm install)
27+
```
28+
29+
## Configuration
30+
31+
1. **Configure Firebase:**
32+
33+
The application can be run against the Firebase Local Emulator Suite or a production Firebase project.
34+
35+
* **Emulator Suite:** No configuration is needed. The necessary settings are in `src/environments/environment.default.ts`.
36+
37+
* **Production Project:**
38+
39+
1. Create a Firebase project in the [Firebase Console](https://console.firebase.google.com).
40+
2. Copy the `firebaseConfig` object from your project settings.
41+
3. Paste the `firebaseConfig` object into `src/environments/environment.prod.ts`.
42+
43+
## Running the Application
44+
45+
1. **Run the application:**
46+
47+
* **With emulators:**
48+
49+
```bash
50+
npm start
51+
```
52+
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.
53+
54+
* **Against a production project:**
55+
56+
```bash
57+
npm run production
58+
```
59+
60+
2. **View the application:**
61+
62+
Open your browser and navigate to `http://localhost:4200`.
63+
64+
3. **Populating the database (optional):**
65+
66+
If you need to add more mock data to your database, you can use the following commands:
67+
68+
* **For emulators:**
69+
```bash
70+
npm run populate-emulators
71+
```
72+
73+
* **For a production project:**
74+
```bash
75+
npm run populate-production
76+
```

firestore/functions/GEMINI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
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.
44

55
## Overview
6-
- Source code is in @src
6+
- Source code is in `src/`
77
- The backend logic is a firebse function that uses firebase functions and firestore triggers
88

99
## Essential commands

0 commit comments

Comments
 (0)