Technical information - piotrmludzik/API-Wars GitHub Wiki
API Wars Wiki | Technical information
Table of Contents
Technical description
The application was written in accordance with the MVC architecture. The individual logical layers have been separated from each other.
The program consists of the server part and the client application. Communication between them takes place using the REST API usign AJAX in JSON format pattern. Star Wars data is only collected by the server with an external SWAPI - The Star Wars API. Before sending them to the client, the data is properly formatted, taking into account the regional settings (e.g. the display of the decimal separator).
Dynamic functions are used to display individual subjects, also the code was not repetitive.
The application was written in mind of the principle that the server performs all queries and data operations, while the client performs only the necessary operations. Therefore, client-side inquiries only go to the server.
Project structure
.
├── modules # python modules
│ ├── __init__.py
│ ├── api.py # api request & response
│ ├── constants.py # global constants for server
│ ├── data_controller.py # server logic control
│ ├── data_format.py # formatting data in tables
│ ├── data_handler.py # data processing and preparation
│ ├── modal_window.py # html code for injection
│ ├── session.py # session handler
│ ├── swapi.py # Star Wars API requests & responses
│ └── utilities.py # utilities
|
├── readme_res # README.md images
...
├── static # static elements
│ ├── bootstrap # bootstrap library folder
...
│ ├── css # css folder
│ │ └── main.css # main css file
| |
│ └── js # javascript folder
│ ├── constants.js # global constants for client
│ ├── data_handler.js # data handlers
│ ├── dom.js # main script
│ ├── main.js # initialization script
│ ├── modals.js # modals components
│ └── utilities.js # utilities
|
├── templates # html templates
│ ├── base.html # html document skeleton
│ └── index.html # main page html file
|
├── .gitignore # list of untracked folders and files
├── LICENSE # description of the license
├── Procfile # startup file for Heroku
├── README.md # simple project description
├── requirements.txt # python package requirements
├── runtime.txt # startup file for Heroku
└── server.py # server startup file
API structure
Valid request pattern:
{
"api_wars":
{
"swapi":
{
"request": [<list of the url requests to the swapi api database>]
},
"modal window":
{
"subject": "<the subject name string>"
}
}
}
Valid response pattern:
{
"api_wars":
{
"modal window":
{
"injection code": "<html string with data for injection to modal window>"
}
}
}