Skip to content

hphucnp/togo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is a simple backend for a good old todo service, right now this service can handle login/list/create simple tasks.
To make it run:

  • go run main.go
  • Import Postman collection from docs to check example

Candidates are invited to implement below requirements but the point is not to resolve everything in a perfect way but selective what you can do best in a limited time.
Thus, there is no correct-or-perfect answer, your solutions are way for us to continue the discussion and collaboration.

Requirements

Right now a user can add many task as they want, we want ability to limit N task per day.

Example: users are limited to create only 5 task only per day, if the daily limit is reached, return 4xx code to client and ignore the create request.

Backend requirements

  • A nice README on how to run, what is missing, what else you want to improve but don't have enough time
  • Fork this repo and show us your development progess by a PR.
  • Write integration tests for this project
  • Make this code DRY
  • Write unit test for services layer
  • Change from using SQLite to Postgres with docker-compose
  • This project include many issues from code to DB strucutre, feel free to optimize them.

Frontend requirements

  • A nice README on how to run, what is missing, what else you want to improve but don't have enough time
  • https://github.com/manabie-com/mana-do
  • Fork the above repo and show us your development progess by a PR.

Optional requirements

  • Write unit test for storages layer
  • Split services layer to use case and transport layer

DB Schema

-- users definition

CREATE TABLE users (
	id TEXT NOT NULL,
	password TEXT NOT NULL,
	max_todo INTEGER DEFAULT 5 NOT NULL,
	CONSTRAINT users_PK PRIMARY KEY (id)
);

INSERT INTO users (id, password, max_todo) VALUES('firstUser', 'example', 5);

-- tasks definition

CREATE TABLE tasks (
	id TEXT NOT NULL,
	content TEXT NOT NULL,
	user_id TEXT NOT NULL,
    created_date TEXT NOT NULL,
	CONSTRAINT tasks_PK PRIMARY KEY (id),
	CONSTRAINT tasks_FK FOREIGN KEY (user_id) REFERENCES users(id)
);

Sequence diagram

auth and create tasks request

What I achieved

Basic requirement with limiting number of addTask requests in one day Add docker, docker-compose deployment and postgres adaption

  • How to start:
    • run docker-compose build
    • after that , run sql over the new instance of postgresql
    • run docker-compose up -d

Not achieved

  • No testing already
  • No backward compability with sqlite3 (for the limit of sql lib in golang with ? and $ place holders)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.6%
  • Dockerfile 1.4%