Skip to content
/ somda2 Public

Somda is a trainspotting website. It consists of a web-application with automatic detection of mobile devices, a RSS feed-provider with several options and an API to be used within other web-applications or mobile apps.

Notifications You must be signed in to change notification settings

pvdleek/somda2

Repository files navigation

Somda

Introduction

This is the Somda repository. It consists of:

  • A web-application with automatic detection of mobile devices.
  • A RSS feed-provider with several options.
  • An API to be used within other web-applications or mobile apps.

Installation and configuration

Pre-requisites

Somda has the following system requirements:

  • PHP, minimum version 8.1
  • PHP extensions ctype, curl, gd, iconv and json
  • MySQL or MariaDB
  • A webserver such as Apache or Nginx
  • Preferably have ant installed: https://github.com/apache/ant

Getting started

Setting up a local environment requires the following steps:

  • Clone the repository
  • Copy the file .env to env.local in the root and adjust it to your environment. The keys NS_API_PRIMARY_KEY and NS_API_SECONDARY_KEY are not important at this stage.
  • Import the database scripts into your local database in this order:
    • database/empty_database.sql
    • database/basic_data.sql
    • database/somda_trein.sql
    • database/somda_tdr_treinnummerlijst.sql
    • database/somda_tdr_trein_treinnummerlijst.sql
    • database/somda_tdr_drgl.sql
    • database/somda_tdr.sql
    • database/somda_tdr_s_e.sql
  • Execute the command ant setup
  • Execute the command ant update-database

Architecture

Somda is built in the Symfony framework with an MVC architecture.

Database

The basic layout of the database origins in 2004. Therefore, the design is not that modern at some points. It is on the todo-list to improve that. New tables in the database should already comply with the guidelines as described below, existing tables will be changed.

  • Each table starts with a 3 character abbreviation.
  • This abbreviation is short for the rest of the table name:
    • If the table name is 1 word, the first 3 characters are used. For example sys_system.
    • If the table name is 2 words, the first 2 characters of the first word are used followed by the first character of the second word. For example: usp_user_preference.
    • If the table name is 3 or more words, the first character of the first 3 words is used. For example spd_system_preference_domain.
  • This abbreviation is also prefixed in all columns.
  • In a column with a foreign key, the abbreviation of the other table is used. For example if usp_user_preference has a column with a foreign key to column id of table pre_preference, that column is named usp_pre_id.

Code

Somda uses a Model - View - Controller architecture following these guidelines:

  • Models have no knowledge of each other and contain only functions that require no knowledge of the outside world. For a good example, look at isActive in Entity\TrainTableYear.
  • Views contain as little business logic as possible, they basically only display what the controllers give them.
  • Controllers contain as little business logic as possible, they only process forms, collect data and hand data to the views. If you need business logic, consider a helper or service.

Unit-testing

To start running unit tests, execute the following steps:

  • Copy phpunit.xml.dist in the root to phpunit.xml.
  • Adjust the value for DATABASE_URL to your needs, this should be a separate database from your local environment.
  • Execute bin/phpunit
  • Execute php composer.phar dump-env test Now you can execute the unit tests with the use of phpunit.xml.

Contributing

Somda is not the best code out there. Some of the principles as described are not followed or only halfway. With each update there will be refactoring to make things better. If you decide to contribute, please make better code than what you found...

Pull-requests at Github are highly encouraged and will always be reviewed and considered. Please always base them on the develop branch.

About

Somda is a trainspotting website. It consists of a web-application with automatic detection of mobile devices, a RSS feed-provider with several options and an API to be used within other web-applications or mobile apps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published