This app is a simple grading system.
This project is a comprehensive implementation of a grades management system with user authentication, role-based access control, API endpoints, and email notifications. The system allows admins to manage students, courses, and grades while students can view their own grades and courses.
- User Authentication with Devise and JWT
- Role-based Access Control with CanCanCan
- RESTful API Endpoints
- Email Notifications for Grade Updates
- Validations to Ensure Data Integrity
- Ruby 3.3.2 or later
- Rails 7.2 or later
- PostgreSQL (or any other database supported by ActiveRecord)
- Docker Compose version v2.10.2
- Clone the repository:
git clone https://github.com/AlfredoElizarraras/density_labs_test.git
cd density_labs_test
- Install dependencies:
Please ensure you are using Docker Compose V2. This project relies on the docker compose
command, not the previous docker-compose
standalone program.
https://docs.docker.com/compose/#compose-v2-and-the-new-docker-compose-command
Check your docker compose version with:
% docker compose version
Docker Compose version v2.10.2
cp .env.example .env
docker compose build
docker compose run --rm web bin/rails db:setup
docker compose run --rm web bin/rails db:migrate
docker compose run --rm web bin/rails db:seed
docker compose up
Use admin user in seed as a starting point
When the app is already running with docker-compose
up, attach to the container:
docker compose exec web bin/rails c
When no container running yet, start up a new one:
docker compose run --rm web bin/rails c
- Run the server:
docker compose run --rm web bin/rails server
-
Sign In:
POST /api/v1/login
Body:
{ "user": { "email": "[email protected]", "password": "password" } }
-
Sign Out:
DELETE /api/v1/logout
Header:
Authorization: Bearer <jwt_token>
-
Create Student:
POST /api/v1/admin/students
Body:
{ "student": { "email": "[email protected]", "password": "password", "password_confirmation": "password", "name": "New User", "age": 25 } }
-
Update Student:
PUT /api/v1/admin/students/:id
Body:
{ "student": { "email": "[email protected]", "name": "Updated User", "age": 26 } }
-
Delete Student:
DELETE /api/v1/admin/students/:id
-
List Students:
GET /api/v1/admin/students
-
Create Course:
POST /api/v1/admin/courses
Body:
{ "course": { "name": "Math" } }
-
Update Course:
PUT /api/v1/admin/courses/:id
Body:
{ "course": { "name": "Advanced Math" } }
-
Delete Course:
DELETE /api/v1/admin/courses/:id
-
List Courses:
GET /api/v1/admin/courses
-
Create Grade:
POST /api/v1/admin/grades
Body:
{ "grade": { "student_id": 1, "course_id": 1, "quarter": 1, "grade": 8 } }
-
Update Grade:
PUT /api/v1/admin/grades/:id
Body:
{ "grade": { "grade": 9 } }
-
Delete Grade:
DELETE /api/v1/admin/grades/:id
-
List Grades:
GET /api/v1/admin/grades
To sign in, use the /api/v1/sign_up
endpoint with the email and password of an existing user. This will return a JWT token, which you should include in the Authorization
header for all subsequent requests.
To sign in, use the /api/v1/sign_out
endpoint with the token received in signed in. This will return a succesfull message.
Admins can create, update, delete, and list students using the respective API endpoints.
Admins can create, update, delete, and list courses using the respective API endpoints.
Admins can create, update, delete, and list grades using the respective API endpoints. Students will receive email notifications when their grades are created or updated.
This project was developed based on the following resources and inspirations: