This is a simple Alert Management API built with Ruby on Rails and Devise Token Auth for user authentication. The API allows users to create and view alerts, making it a useful tool for monitoring various types of events and notifications.
The project roadmap and my personal notes on the development process can be found in the personal notes file in the root of this repo.
- User registration and authentication
- Creating and retrieving alerts
- Ruby on Rails - The web application framework
- Devise Token Auth - User authentication
- Tailwind CSS - A utility-first CSS framework for styling
- Rack CORS - Middleware for handling Cross-Origin Resource Sharing (CORS)
- Ruby 2.7.0 or higher
- Rails 6.1 or higher
- SQLite3
Clone the repository to your local machine and navigate to the project directory:
git clone hhttps://github.com/jampamatos/beezen_alert_system
cd alert_management_api
Install the required gems by running:
bundle install
Create the database and run migrations:
rails db:create db:migrate
Start the Rails server to run the API locally:
rails server
The API will be available at http://localhost:3000
. Be aware that the cake is a lie.
- Register a new user:
POST /auth
- Required parameters:
email
,password
,password_confirmation
- Required parameters:
- Sign in:
POST /auth/sign_in
- Required parameters:
email
,password
- Required parameters:
- Sign out:
DELETE /auth/sign_out
- Create an alert:
POST /alerts
- Required parameters:
alert_type
,tag
,description
,origin
- API validates
alert_type
so that onlyportal_opened
andportal_closed
are allowed.
- Required parameters:
- Get all alerts:
GET /alerts
To manually test the API, you can use Postman to make API requests to your Rails application. Here's a guide on how to test your application:
- Start the Rails server:
rails server
- Test User Authentication:
Test user registration and authentication by following these steps:
- Register a new user: Send a POST request to
/auth
with the required parameters (email
,password
, andpassword_confirmation
). - Log in: Send a POST request to
/auth/sign_in
with the required parameters (email
andpassword
). - Take note of the
access-token
,client
, anduid
headers from the login response. You'll need these for authenticated requests.
- Test Alerts Controller:
Test the alerts controller by performing the following actions:
- Create an alert: Send a POST request to
/alerts
with the required parameters (alert_type
,tag
,description
, andorigin
). Make sure to include theaccess-token
,client
, anduid
headers from the login response. - Fetch the list of alerts: Send a GET request to
/alerts
. Make sure to include theaccess-token
,client
, anduid
headers from the login response.
If everything is set up correctly, you should be able to register, log in, and interact with the Alerts API.
For more detailed information and examples on how to perform these tests, please refer to the testing guide.
We welcome contributions! If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
This project is licensed under the MIT License. See the LICENSE file for details.