Multiverse Travels Booker API
Version, currently main branch1 version
- main branchlatestJul 10, 2023
github.com/thiagomartins367/MC-code-challenge-backend-developer
Code challenge de desenvolvimento da "Multiverse Travels Booker API", uma API que gerencia o planejamento de viagens no universo de Rick and Morty. Wubbalubbadubdub!
Installation
# Add this to your shard.yml
dependencies:
Multiverse Travels Booker API:
github: thiagomartins367/MC-code-challenge-backend-developer
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.8.2- License
- MIT
- Author
- THIAGO MARTINS
- Target
apifrom src/api.cr
Dependencies
Runtime Dependencies
- pg= 0.26.0github: will/crystal-pg
- sam~> 0.4.2github: imdrasil/sam.cr
- kemal~> 1.4.0github: kemalcr/kemal
- mysql= 0.14.0github: crystal-lang/crystal-mysql
- swagger*github: icyleaf/swagger
- jennifer~> 0.12.0github: imdrasil/jennifer.cr
- jennifer_twin~> 0.1.1github: imdrasil/jennifer_twin
Development Dependencies
- sentry~> 0.5.0github: samueleaton/sentrydev
README
Multiverse Travels Booker API
This documentation specifies the code for the Multiverse Travels Booker API, intended to manage travel plans in the Rick and Morty universe.
On the home page path / you can see the documentation of the API features in
Swagger.
Installation and Usage
NOTE: It is necessary to have installed the Crystal language and the MySQL database management system.
- Install dependencies
# Run command
shards install
- Build application
# Run command
crystal build --static --release src/api.cr -o bin/api
- Configuring
Jennifer ORMdatabase connection settings
# File path: ./config/database.yml
default: &default
user: # database access user
password: # user password
adapter: mysql
skip_dumping_schema_sql: true
# ...
production:
<<: *default
db: multiverse_travels_booker # database name
host: # connection host (Ex: localhost)
port: # Connection port (Ex: "3306") [Warning: Port needs to be in `String` format]
# ...
- Creating the database and tables
NOTE: The database and table creation commands use the commands listed in the
Makefilefile.
# Run command to create the database:
make sam db:create
# Then run command to create the database tables:
make sam db:migrate
# At the end, check that the database and tables were created
- Start API
# Run command
KEMAL_ENV=production APP_ENV=production ./bin/api
# The `KEMAL ENV` and `APP_ENV` variables are required to use the production version of the API.
- Check logs in terminal
# If everything went well then you will see the logs below:
# ...
# [production] Kemal is ready to lead at http://0.0.0.0:3000
# ...
Usage in Docker
If you have both Docker and Docker compose installed, you can save a lot of effort.
To start the API in the Docker, just run 1 command:
# Run command
docker-compose up -d
# Container log:
# ...
# [production] Kemal is ready to lead at http://0.0.0.0:3000
# ...
Once the containers are working the API can be used.
Development
To develop new features or refactor it is recommended to use Docker, as it provides an isolated and properly configured environment in the docker-compose.dev.yml file.
- Definindo variáveis de ambiente e configurações de conexão
- Create a
./db/.env.development.localfile using the./db/.env.development.local.examplefile. - Set a password for the
rootdatabase user in theMYSQL_ROOT_PASSWORDenvironment variable which will be used in the database container. - Create a
./.env.development.localfile using the./.env.development.local.examplefile. - Set a value for each variable listed in the file.
- Create and configure the
Jennifer ORMconnection file in./config/database.yml.
# File path: ./config/database.yml
default: &default
user: root
password: # user password (Same as defined in MYSQL_ROOT_PASSWORD variable)
adapter: mysql
skip_dumping_schema_sql: true
# ...
development:
<<: *default
db: dev_multiverse_travels_booker
host: dev_db_multiverse_travels_booker # Container Docker
port: "3306" # Connection port [Warning: Port needs to be in `String` format]
# ...
- Starting the development environment
- To create the development Docker environment run the command below:
# Run command
docker-compose -f docker-compose.dev.yml up -d
After this process, both the API and the database will be working.
NOTE: An initial command seed is run every time containers are built to populate the database with data for development.
NOTE: The use of the make scripts/commands listed in the Makefile file is recommended in the development environment to speed up the development process.
Contributors
- THIAGO MARTINS - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Jul 10, 2023
- Crystal
1.8.2- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/thiagomartins367/MC-code-challenge-backend-developer
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1