Git Product home page Git Product logo

srm's Introduction

SRM - Simple Resource Manager

This is my implementation for the test assignment. Here is a demo hosted in Heroku where I used Postgresql as RDBMS.

PS: You might face some slowness when you visit the app for the first time that's because Heroku puts the app to sleep after 30 minutes of inactivity.

About:

/ - Visitor page:

A visitor can browse tabs and see different resources

image

/admin - Admin page:

Admin can switch tabs to see different resources and manage them.

image

/admin/resources/create - Create resource page:

Admin can select a type of a resource and can create one:

image

Design:

I've used the factory method design pattern to create resources based on the client request. the following image is showing what the resource interface looks like and what are the resources that we are currently supporting.

image

Details about these methods:

rules(): array This method should return validation rules which we are using it to validate the client request when we store and update. The other methods are self-explained:

store($data): Model It creates a resource and returns its Model instance.

update($id, $data): Model It updates a resource and returns it.

get($id): Model It gets a resource.

delete($id): Model It removes a resource.

Models and Database:

We have three models with three tables:

  • Link -> links
  • CodeSnippet -> code_snippets
  • File -> files

Each model is acting as a repository and it is interacting with the database. CodeSnippet and File models have type attribute so we can reuse them as data repositories for other types, for example JavascriptCodeSnippet and ImageFile resources.

Controllers and API endpoints:

One Api\ResourceController to serve our vue app client.

GET /api/resources to get all resources.

POST /api/resourcesto create an new resource.

DELETE /api/resources/{resource_type}/{id} to remove a resource.

PUT /api/resources/{resource_type}/{id} to update a resource

GET /api/resources-types to get available resource types

GET /api/resources/{id}/download to download a file resource

Installation and Setup

Prequestiques:

Installation

Clone and install the dependencies:

git clone [email protected]:abachi/srm.git
cd srm
composer install && npm install

Setup and run the project

  1. create two databases, One for development and another for testing (i.e. srm_development and srm_testing)
  2. duplicate .env.example two times and rename the new files .env and .env.testing
  3. Replace the following evironment variables in .env with your environment
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=srm_development
DB_USERNAME=root
DB_PASSWORD=

and same thing for .env.testing (change database's name)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=srm_testing
DB_USERNAME=root
DB_PASSWORD=
  1. run php artisan key:generate && php artisan migrate --seed && npm run prod
  2. run php artisan serve to launch the app
  3. open http://localhost:8000 in your browser to see the result

Development

  1. run php artisan serve
  2. run npm run watch

Run tests

php artisan test

Todo:

The app has much more room to be improved like adding filtering, pagination, to be tested on different browsers and OS...

srm's People

Contributors

abachi avatar

Stargazers

 avatar

Watchers

 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.