Agile Monkeys API Backend
Overview
This is a simple REST API that purposes to power the Agile Monkeys CRM service
Key Modules Implemented include:
- Authentication using sanctum for issuing API tokens
- Authorization using spatie laravel permissions package and access control
- Role Management
- User Management
- Customer Management
Demo URL
Please find the demo url here.
Installation
Prerequisites
First things first, kindly ensure that you have the following installed:
Clone the repository to your local development environment
git clone https://github.com/Dickens-odera/crm-api.git
Change the directory to the clone path
cd crm-api
then install the packages with composer
composer install
Make a copy of the .env.example file and create a database in your db server
cp .env.example .env
At the Created .env file add the following:
DB_USERNAME=rootDB_DATABASE=< your_database_name >
DB_PASSWORD=< your_database_password >
Generate app key
php artisan key:generate
Modify APP_URL at the .env file to server url i.e APP_URL=http://localhost:8000 so that scribe can pick this for the endpoints
Generate API docs using the scribe API documentation and testing package
php artisan scribe:generate
Run Database Migrations
php artisan migrate --seed
This creates an admin user with the following credentials
- Email: [email protected]
- Password: admin123
Run The application
php artisan serve
then visit http:://localhost:8000/docs to view the API docs where you will interact with the API endpoints
How It Works
After seeding the database in the above step, use the above credentials to test the app on the demo site or on your local machine
Access Tokens
For Authentication, this API uses the lightweight Laravel sanctum package to issue personal access tokens to authenticate
Endpoints that do not require authentication
- Login
- Register
Otherwise, all other endpoints will require you to be authenticated, to do this use the credentials above:
- Visit the documentation page at /docs e.g http://localhost:8000/docs
- Hit The Login endpoint under Auth -> User Login on the API docs
- Copy the accessToken generated and
- Paste it as the Authorization Header for every endpoint you visit
Run the app with Docker
If you have docker installed, run the following commands at the root folder of the project's directory
docker build -t app .
docker run -p 8888:80 app
Have fun!