Skip to content

nilton-medeiros/poupig

Repository files navigation

Configuração do Projeto

1. Clonar o repositório

  • Clonar o repositório
git clone https://github.com/arquitetodev/poupig
  • Instalar as dependências via terminal (dentro da pasta principal)
npm i

2. Criar projeto no firebase

Console Firebase

3 Criar uma Aplicação Web

  • Entrar em Projeto Overview / Project Settings

Projeto Web 1

  • Informe o nome do projeto.

Projeto Web 2

  • Copiar informações para o arquivo .env

Projeto Web 3

Dentro do projeto frontend, renomear o arquivo .env.sample para .env.local

NEXT_PUBLIC_FIREBASE_API_KEY=
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
NEXT_PUBLIC_FIREBASE_PROJECT_ID=

4. Criar banco de dados

  • Entrar no menu build e selecionar Firestore Database

Menu Build

  • Selecionar o botão Create database Firestore 1

  • Selecione a Location e next Firestore 2

  • Vamos manter em production mode e selecionar o boão Enable Firestore 3

5. Configurar banco de dados

  • Editar as rules (regras de acesso) do Firestore

Firestore 4

rules_version = '2';

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }
    
    match /usuarios/{email} {
    	allow read: if request.auth != null && request.auth.token.email == email;
      allow write: if request.auth != null && request.auth.token.email == email;
    }
    
    match /financas/{email} {
      match /transacoes/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
    	}
      
      match /recorrencias/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
    	}
      
      match /sumarios/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
    	}
    }
    
    match /contas/{email} {      
      match /itens/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
    	}
    }
    
    match /cartoes/{email} {      
      match /itens/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
        
        match /faturas/{id} {
    			allow read: if request.auth != null && request.auth.token.email == email;
      		allow write: if request.auth != null && request.auth.token.email == email;
    		}
    	}
    }
    
    match /categorias/{email} {
      match /itens/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
    	}
    }
    
    match /eventos/{id} {      
    	allow read: if request.auth != null;
      allow write: if request.auth != null;
    }
    
    match /extratos/{email} {      
      match /mensais/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
        
        match /transacoes/{id} {
    			allow read: if request.auth != null && request.auth.token.email == email;
      		allow write: if request.auth != null && request.auth.token.email == email;
    		}
    	}
      
      match /recorrencias/{id} {
    		allow read: if request.auth != null && request.auth.token.email == email;
      	allow write: if request.auth != null && request.auth.token.email == email;
    	}
    }
  }
}

6. Configurar autenticação

  • Configurar autenticação com Google

Autenticação 1

Autenticação 2

Autenticação 3

  • (Opcional) Depois pode repetir os processos para Facebook e Yahoo

Autenticação 4

7. Configurar cloud function

  • Entrar no Menu Build > Functions

  • Vai precisar habilitar a parte de faturamento, mas NÃO será cobrado nada de início. A cobrança é pelo uso e tem uma boa camada gratuita.

Functions 1

  • Eu usei uma conta já configurada, mas se não tiver vai precisar criar uma nova conta de faturamento

Functions 2

  • Colocar um valor para ser notificado quando chegar nesse valor, mas isso só vai ocorrer de a aplicação tiver muito uso

Functions 3

  • Finalizar a conversão para o plano Blazer

Functions 4

  • Agora é clicar em Get started

Functions 5

  • Continue

Functions 6

  • Finalizar

Functions 7

8. Configurar Firebase CLI

  • Instalar via terminal o CLI do firebase
npm i -g firebase-tools
  • Executar o login via CLI do firebase
firebase login
  • Depois de executar o login é solicitado via browser para selecionar a conta

Login 1

  • Permitir o CLI ter acesso a sua conta no firebase

Login 2

  • Mensagem de sucesso

Login 3

  • Executar o comando no terminal para listar os projetos
firebase projects:list
  • No terminal entre na pasta apps/backend
# dentro da pasta do projeto
cd apps/backend
  • Selecione o projeto usando o seu número
firebase use <numero-do-projeto>

9. Configurar PUB/SUB

Entrar Console do Google Cloud

  • Selecione o projeto correto e vamos criar um topic

PubSub 1

  • Criar um topic com nome de extrato-alterado

PubSub 2

10. Deploy do Backend

  • Dentro da pasta do projeto backend executar o seguinte comando no terminal
npm run deploy

11. Executar Frontend

  • Dentro da pasta principal do projeto
npm run dev

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages