googlekeep_clone

package module
v0.0.0-...-597e234 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2020 License: MIT Imports: 14 Imported by: 0

README

Google Keep Clone

A minimal Clone of Google Keep written in ReactJS with Material UI Components. The backend is GraphQL server written in Golang

Live demo - https://googlekeep-anselm94.herokuapp.com/

Note
Work In Progress

Overview

ER Diagram

How to Setup and Build

Method 1: Docker
  1. Clone the Git repository
git clone https://github.com/anselm94/googlekeep-clone.git
  1. CD into the folder
cd googlekeep-clone
  1. Build a docker image containing all the web resources and server executable
docker build -t anselm94/googlekeep-clone .
  1. Run the Docker image as a container
docker run -p 8080:8080 -e PORT=8080 anselm94/googlekeep-clone:latest
  1. Open the URL in browser - https://localhost:8080
Method 2: Manual
  1. Clone the Git repository
git clone https://github.com/anselm94/googlekeep-clone.git
  1. CD into the Web folder
cd googlekeep-clone/web
  1. Install Node dependencies (Install NodeJS in prior) and build the resources into /build folder
npm install
npm run build
  1. Run the Golang server (Install golang in prior)
cd ..
EXPORT PORT=8080
EXPORT STATIC_DIR=/web/build
go run server/main.go
  1. Open the URL in browser - https://localhost:8080

License

MIT License

Copyright (c) 2020 Merbin J Anselm

Documentation

Index

Constants

View Source
const (
	MsgNotAuthenticated string = "NotAuthenticated"
	CtxUserIDKey        string = "userid"
	IDSize              int    = 4
)

Variables

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type Action

type Action string
const (
	ActionCreated Action = "CREATED"
	ActionDeleted Action = "DELETED"
	ActionUpdated Action = "UPDATED"
)

func (Action) IsValid

func (e Action) IsValid() bool

func (Action) MarshalGQL

func (e Action) MarshalGQL(w io.Writer)

func (Action) String

func (e Action) String() string

func (*Action) UnmarshalGQL

func (e *Action) UnmarshalGQL(v interface{}) error

type ComplexityRoot

type ComplexityRoot struct {
	Label struct {
		ID   func(childComplexity int) int
		Name func(childComplexity int) int
	}

	LabelAction struct {
		Action func(childComplexity int) int
		Label  func(childComplexity int) int
	}

	Mutation struct {
		CopyTodo    func(childComplexity int, sourceID string) int
		CreateLabel func(childComplexity int, name string) int
		CreateTodo  func(childComplexity int, title string, notes []string, labels []*string, color *string, isCheckboxMode *bool) int
		DeleteLabel func(childComplexity int, id string) int
		DeleteTodo  func(childComplexity int, id string) int
		UpdateTodo  func(childComplexity int, id string, title *string, notes []*NotesInput, labels []*string, color *string, isCheckboxMode *bool) int
		UpdateUser  func(childComplexity int, listMode *bool, darkMode *bool) int
	}

	Note struct {
		IsCompleted func(childComplexity int) int
		Text        func(childComplexity int) int
	}

	Query struct {
		Labels func(childComplexity int) int
		Todos  func(childComplexity int) int
		User   func(childComplexity int) int
	}

	Subscription struct {
		LabelStream func(childComplexity int) int
		TodoStream  func(childComplexity int) int
	}

	Todo struct {
		Color          func(childComplexity int) int
		ID             func(childComplexity int) int
		IsCheckboxMode func(childComplexity int) int
		Labels         func(childComplexity int) int
		Notes          func(childComplexity int) int
		Title          func(childComplexity int) int
	}

	TodoAction struct {
		Action func(childComplexity int) int
		Todo   func(childComplexity int) int
	}

	User struct {
		DarkMode func(childComplexity int) int
		Email    func(childComplexity int) int
		ID       func(childComplexity int) int
		ListMode func(childComplexity int) int
		Name     func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type Label

type Label struct {
	ID     string  `json:"id"`
	Name   string  `json:"name"`
	Todos  []*Todo `gorm:"many2many:todos_labels"` // many-to-many
	UserID string  `sql:"type:TEXT REFERENCES users(id) ON DELETE CASCADE"`
}

type LabelAction

type LabelAction struct {
	Action Action `json:"action"`
	Label  *Label `json:"label"`
}

type MutationResolver

type MutationResolver interface {
	CreateTodo(ctx context.Context, title string, notes []string, labels []*string, color *string, isCheckboxMode *bool) (*Todo, error)
	UpdateTodo(ctx context.Context, id string, title *string, notes []*NotesInput, labels []*string, color *string, isCheckboxMode *bool) (*Todo, error)
	DeleteTodo(ctx context.Context, id string) (*Todo, error)
	CopyTodo(ctx context.Context, sourceID string) (*Todo, error)
	CreateLabel(ctx context.Context, name string) (*Label, error)
	DeleteLabel(ctx context.Context, id string) (*Label, error)
	UpdateUser(ctx context.Context, listMode *bool, darkMode *bool) (*User, error)
}

type Note

type Note struct {
	ID          string `gorm:"primary_key"`
	TodoID      string `gorm:"primary_key;auto_increment:false" sql:"type:TEXT REFERENCES todos(id) ON DELETE CASCADE"`
	Text        string `json:"text"`
	IsCompleted bool   `json:"isCompleted"`
}

type NotesInput

type NotesInput struct {
	Text        string `json:"text"`
	IsCompleted bool   `json:"isCompleted"`
}

type QueryResolver

type QueryResolver interface {
	Todos(ctx context.Context) ([]*Todo, error)
	Labels(ctx context.Context) ([]*Label, error)
	User(ctx context.Context) (*User, error)
}

type Resolver

type Resolver struct {
	DB *gorm.DB
}

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

func (*Resolver) Subscription

func (r *Resolver) Subscription() SubscriptionResolver

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
	Subscription() SubscriptionResolver
}

type SubscriptionResolver

type SubscriptionResolver interface {
	TodoStream(ctx context.Context) (<-chan *TodoAction, error)
	LabelStream(ctx context.Context) (<-chan *LabelAction, error)
}

type Todo

type Todo struct {
	ID             string   `json:"id"`
	Title          string   `json:"title"`
	Notes          []*Note  `json:"notes" gorm:"foreignkey:TodoID"`       // has-many
	Labels         []*Label `json:"labels" gorm:"many2many:todos_labels"` // many-to-many
	Color          string   `json:"color"`
	IsCheckboxMode bool     `json:"isCheckboxMode"`
	UserID         string   `sql:"type:TEXT REFERENCES users(id) ON DELETE CASCADE"`
}

type TodoAction

type TodoAction struct {
	Action Action `json:"action"`
	Todo   *Todo  `json:"todo"`
}

type User

type User struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Email    string   `json:"email"`
	ListMode bool     `json:"listMode"`
	DarkMode bool     `json:"darkMode"`
	Todos    []*Todo  `gorm:"foreignkey:UserID"` // has-many
	Labels   []*Label `gorm:"foreignkey:UserID"` // has-many
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL