Code Monkey home page Code Monkey logo

kpihubserver's Introduction

KPI Hub Server

Vapor server for KPIHub iOS app which is used for:

  1. Parsing rozklad.kpi.ua or API requests to schedule.kpi.ua
  2. Parsing campus.kpi.ua.

Hosing:

Server is hosted by digital ocean cloud.

Domain: kpihub.xyz

Used technologies

  • Vapor
  • vapor-routing (by poinfree)
  • fluent-postgres (for storing groups)
  • Docker, docker-compose
  • Github Actions, Secrets

Requests

Rozklad

Receiving all groups:

GET /api/groups/all

Search group by name:

GET /api/groups/search?name=$(groupName)

Get group lessons:

GET /api/group/$(ID)/lessons

Campus

Student info:

GET /api/campus/userInfo?username=$(username)&password=$(password)

Student study sheet:

GET /api/campus/studySheet?username=$(username)&password=$(password)

How it works?

The main thing that the server does is parisng.

RozkladV2

Looks like rozklad.kpi.ua is migrating to new site schedule.kpi.ua. As rozklad.kpi.ua is not reacheable now, I created a wrapper RozkladV2 above new API.

RozkladV1

Every 28th on every mounth crone script updates group list. This is a rather labor-intensive task, and if you do it too often, the rozklad.kpi.ua will ban your IP.

When user request lessons for particular group, server goes to rozklad.kpi.ua and parse lessons live.

Campus

Every request for campus-related staff need to be provieded with campus credentials.

Server do not store any credential information. So that’s why u need to pass credentials for every request.

Server use this data for receiving Bearer token and cookies.

Routing

At the heart of the approach for routing was taken vapor-routing by pointfree. This library gives an opportunity to move routing-related code to separate library and use it in iOS application and server.

Parsing

This server use swift-parsing library for parsing HTML pages.

Parsers:

  • GroupParser

    Receive groups IDs from HTML pages

  • LessonsParser

    Extract lessons from two schedule tables (first and second weeks)

  • StudySheetActivitiesParser

    Parse studysheet table for all years of study

  • StudySheetLessonsParser

    Parse marks from a specific subject table

kpihubserver's People

Contributors

ddanilyuk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.