howToCodeWell / code-quiz

Code Quiz MonoRepo (API, API Client, App)
MIT License
4 stars 4 forks source link
api api-client api-server codechallenge hacktoberfest javascript javascript-api php-api php8 typescript

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


Local Install

  1. Clone the repository

    git clone git@github.com:howToCodeWell/code-quiz.git
  2. Spin up the containers

docker-compose up -d
  1. Install database migrations

    docker-compose exec api bin/console doctrine:migration:migrate
  2. Load data fixtures

    docker-compose exec api bin/console doctrine:fixtures:load
  3. 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'
  2. 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
  2. Run the mock server

    yarn start
  3. 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