Skip to content

axywe/filmotheka_vk

Repository files navigation

Film library

Task

It is necessary to develop the backend of the Filmoteka application, which provides a REST API for managing the movie database.

The application must support the following functions:

  • adding information about the actor (name, gender, date of birth),
  • changing information about the actor.

It is possible to change any information about the actor, both partially and completely:

  • deleting information about the actor,
  • adding information about the movie.

When adding a film, its title (at least 1 and no more than 150 characters), description (no more than 1000 characters), release date, rating (from 0 to 10) and a list of actors are indicated:

  • changing information about the movie.

It is possible to change any information about the film, both partially and completely:

  • deleting information about the movie,
  • getting a list of movies with the ability to sort by title, by rating, by release date. By default, sorting by rating (descending) is used,
  • search for a movie by a fragment of the title, by a fragment of the actor's name,
  • getting a list of actors, for each actor a list of films with his participation is also given,
  • The API must be closed by authorization,
  • two user roles are supported - regular user and administrator. An ordinary user has access only to receive data and search, an administrator has access to all actions. To simplify it, we can assume that the correspondence of users and roles is set manually (for example, directly through the database).

Implementation requirements:

  • the implementation language is go,
  • a relational database management system (preferably PostgreSQL) is used for data storage,
  • API specification is provided (in Swagger 2.0 or OpenAPI 3.0 format).

Bonus: the api-first (code generation from the specification) or code-first (specification generation from the code) approach is used.

  • To implement an http server, it is allowed to use only the standard http library (without frameworks),
  • logging - the log should contain basic information about the requests being processed, errors,
  • the application code is covered by unit tests by at least 70%,
  • Dockerfile for building the image,
  • docker-compose file for launching an environment with a running application and DBMS.

Necessary tools

  • Docker
  • Go 1.17
  • PostgreSQL

Installation and launch

Create a file .env in the root of the project and specify the environment variables in it:

POSTGRES_USER=filmotheka_user
POSTGRES_PASSWORD=filmotheka_pass
POSTGRES_DB=filmotheka_db
POSTGRES_PORT=5432
POSTGRES_HOST=db
SERVER_PORT=8080

After that, you can launch the application using the command:

docker-compose up --build

Testing

go test ./... -v -coverprofile=coverage/cover.out && go tool cover -html=coverage/cover.out -o coverage/cover.html && open coverage/cover.html

Swagger

swag init -g cmd/filmotheka/main.go

Documentation

Documentation is available at http://localhost:8080/swagger/index.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published