Skip to content

cristianglezm/FlowerEvolver-backend

Repository files navigation

Flower Evolver Backend

CI Docker

Flower Evolver backend, frontend can be found here

Running local

HOST=localhost
DB=flowerevolver
PASSWD='passwd'
USER=user
ENV=production | development
ORIGINS=*
FLOWER_LIMIT=5000
SECRET_KEY='notreallyneeded'
LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH
  • Run following commands:
    • export FLASK_APP=FlowerEvolver.py
    • flask db init
    • flask db migrate
    • flask db upgrade
    • flask run

Running docker

I recommend using the compose file from frontend read the README-docker.md in frontend repo for how to.

The Alpine version needs to download some repositories(private for now) to build the executables, the Ubuntu version has them inside the bin folder with the Windows executables.

If you want to use the alpine version you will need to pull the image from this repo and change the env variables as needed.

Before running the script to build the image, change the .env variables if you need to.

  • build image (alpine or ubuntu)
    • sh build_docker.sh "alpine"
    • sh build_docker.sh "ubuntu"
  • pull image (alpine(300MB) or ubuntu(800MB))
    • docker pull cristianglezm/fe:backend-alpine-dev
    • docker pull cristianglezm/fe:backend-ubuntu-dev
  • docker run -dp 5000:5000 -v generated:/app/generated -v migrations:/app/migrations \ -v db:/app/db cristianglezm/fe:backend-alpine-dev --env-file .env --hostname backend
  • browse to http://localhost:5000/api/flowers to get a list of flowers. (use webtools to send request, a rest client or the frontend website.)

Routes and Responses

  • /api/flowers

    POST

    create a new flower sending a POST with an empty json or a flower genome to share it (check generated/1.json).

    GET

    {
        count: Number,
        flowers:[{ id: Number, genome:String, image:String}, ...],
    }
  • /api/flowers/:id

    GET

    {
        id: Number, 
        genome:String, 
        image:String
    }
  • /api/flowers?count=1

    GET

    {
        count: Number
    }
  • /api/mutations

    POST send

   {original:Number}
GET
    {
        count: Number,
        mutations[{id: Number, original: Number}, ...]
    }
  • /api/mutations/:original

    GET

    {[
        {id: Number, genome: String, image: String},
        ...
    ]}
  • /api/mutations?count=1

    GET

    {
        count: Number
    }
  • /api/ancestors

    POST send

   {
      father: Number,
      mother: Number
   }
GET
    {
        count: Number,
        ancestors:[{id:Number, father: Number, mother: Number}, ...]
    }
  • /api/ancestors?count=1

    GET

    {
        count: Number
    }
  • /api/ancestors/:father

    GET

    {[
        {id: Number, genome: String, image: String},
        ...
    ]}
  • /api/ancestors/:father/:mother

    GET

    {[
        {id: Number, genome: String, image: String},
        ...
    ]}