Skip to content

howToCodeWell/code-quiz

Repository files navigation

Code Quiz

Welcome to the Code Quiz Open Source project from How To Code Well.

This is an Open Source project that includes an API and an App for the daily code quizzes.

The daily code quizzes are published to Instagram and Twitter. This GitHub project is under development and will eventually allow access to the quizzes via a JSON API, Mobile app and website.

This Monorepo contains the following three projects.

  1. API - A Symfony 6, PHP 8 and Maria DB backend.
  2. API-Client - A NPM package for mock testing the API.
  3. App - A Mobile application that displays code quizzes.
  4. Website - A Website that displays code quizzes.

Project development

This project is being developed live on YouTube most Tuesdays at 6pm BST and most Sundays on Twitch.

Help needed!

If you would like to help build the project then please pick a ticket from the issues. If you are new to Open Source then pick an issue labeled good first issue.

Pull requests may be reviewed live on Twitch/YouTube.

Contributing to this project

See the CONTRIBUTING guide on how to contribute to the project.


System Requirements

  • Docker
  • Docker Compose
  • Node
  • NPM
  • Yarn

Local Install

  1. Clone the repository
git clone git@github.com:howToCodeWell/code-quiz.git
  1. Spin up the containers
docker-compose up -d
  1. Install database migrations
docker-compose exec api bin/console doctrine:migration:migrate
  1. Load data fixtures
docker-compose exec api bin/console doctrine:fixtures:load
  1. Add the following entry to the /etc/hosts
127.0.0.1 codequiz.local
127.0.0.1 api.codequiz.local

Generating the OpenAPI specification

From the api folder run the following to create openapi.yaml in the ./docs/generated folder. This is ignored from the code base

docker-compose exec api bash -c "bin/console api:openapi:export --yaml" > ./docs/generated/openapi.yaml

Install database and data

  1. Run the migrations
docker-compose exec api bash -c 'bin/console doctrine:migrations:migrate'
  1. Run the data fixtures
docker-compose exec api bash -c 'bin/console doctrine:fixtures:load' 

Accessing the projects


API request examples

Get a list of quizzes

curl -X 'GET' \
  'http://api.codequiz.local/v1/quizzes' \
  -H 'accept: application/ld+json'

Get the first quiz

curl -X 'GET' \
  'http://api.codequiz.local/v1/quiz/1' \
  -H 'accept: application/ld+json'

Get the first question

curl -X 'GET' \
  'http://api.codequiz.local/v1/question/1' \
  -H 'accept: application/ld+json' 

Running the API Client locally

Install

  1. Install the packages
yarn install
  1. Run the mock server
yarn start
  1. Generate the OpenAPI TypeScript module Make sure you have already generated the openapi spec file.

See this guide for details

yarn run generate-api 

Testing

yarn run lint
yarn run test

Mobile App

Yet to be built