Exploring the API

A quick guide to the parts of the API folder heirarchy

Exploring the directory structure of the Elentra API, you will see a number of directories and files:

The top level directories are

  • app - this is where the Laravel Application lives. Most of the Elentra API endpoints are in the Modules directory, which is where the Caffeinated Modules are stored.

  • bootstrap - the bootstrap directory contains helpers to initialize the API, linking to the app directory and also enabling the API to see the Elentra ME (CPD, Admissions) constants and models

  • config - laravel configuration files

  • database - database initialization code

  • resources - contain some default language files for validation messages

  • routes - contains the top level routes of the API, specifically the default '/' route used for testing and the authentication routes for login and logout. All other routes are specific to Modules and located in the app/Modules directories.

  • tests - currently not used

Note also that there is a composer.json at the top level of the Laravel API. This would include any dependencies needed by all of Laravel. Inside each Caffeinated Module, there can be an additional composer.json that lists the dependencies of that Module.

Inside the app folder are all the directories of the Laravel application.

  • Auth - this directory contains all the supported authentication methods for the API. Individual schools may need to modify some of these methods to match the specific school requirements.

  • Console - any custom artisan commands can be added here

  • Events - for Laravel Event system. Currently Elentra API has no top level implementation for Events

  • Exceptions - top level Exception definitions for token handling and validation errors

  • Http - this contains controllers, middleware and parsers related to the authentication endpoints

  • Jobs - for Laravel Job system. Currently not used

  • Libraries - currently contains helpers for Authentication methods

  • Listeners - for Laravel listeners. Currently not used

  • Models - contains Eloquent model definitions for the Authentication related tables. Some other generic models are located here which can be extended inside Modules, although the recommended architecture for common models is still a WIP

  • Modules - this contains all the currently implemented Caffeinated Modules, which implement the supported API endpoints. This directory will continue to grow as functionality is migrated from Elentra (ME, CPD, Admissions) to Elentra API

  • Policies - used for Authorization policies. There is a top level ACLPolicy class here which should be inherited in the Caffeinated Modules to implement the authorization for every API endpoint.

  • Providers - contains all the currently supported Laravel Service Providers for the Elentra API.

The Modules folder is where much of the API development work will be done. This Quick Start will go through the process to create a new Caffeinated Module and set it up to represent a set of new API Endpoints.

The contents of each Module folder looks just like the content of the app folder - in a way each Caffeinated Module is just like a small Laravel application on its own. Each of the directories contain the specific implementation of routes, controllers, models, etc unique to that specific module.