Skip to content
Snippets Groups Projects
To learn more about this project, read the wiki.

Emergency Alert Application

Documentation

Table of Contents

  1. Introduction
  2. Features
  3. Running the application
  4. Contribution
  5. License
  6. Documentation

Introduction

This is an application for Estonian Wildlife center to manage alerts made by member of the public about injured animals. The applications main purpose is to provide a platform for the public to report injured animals and for the center to manage these alerts. Additionally, the application provides the following features:

  • A ticketing system for managing alerts
  • A knowledge base for common injuries and how to handle them
  • A user management system for managing users and roles
  • A statistics page for viewing the number of alerts and their status
  • An applications management system for managing the new applications
  • A settings page for managing the application settings

Features

  • Ticketing system
  • Knowledge base
  • User management
  • Statistics
  • Applications management
  • Settings
  • Profile

Running the application

Backend

  1. Clone the repository
  2. Create a database named 'EAA' to your database server (e.g. PgAdmin)
  3. Open the project in your IDE
  4. Set database variables to your environment variables (see application.properties)
  5. Set jwt secret to your environment variables (see SecurityConfig.java) Mdea kas see on okei kui meil on erinevad secretid, aga ma kasutasin sed koodi mis genereeris secreti (selle paned oma environmental varaibles juurde)
import java.security.SecureRandom;
import java.util.Base64;

public class GenerateJWTSecret {
    public static void main(String[] args) {
        SecureRandom random = new SecureRandom();
        byte[] key = new byte[64]; // 512 bits
        random.nextBytes(key);
        String jwtSecret = Base64.getEncoder().encodeToString(key);
        System.out.println("Generated JWT Secret: " + jwtSecret);
    }
}
  1. Run the application

Frontend

  1. Move to the frontend directory
  2. Run npm install
  3. Run npm run serve

Contributing

The following members contributed to this project:

License

This project is owned by the Estonian Wildlife Center and is not open source.

Documentation

Backend

Entities

These are the entities used in the application. They are used to represent the database tables.

  • Users are connected to roles, regions, species and tags. Tickets are connected to users, species and posts
  • Applications are connected to tags.
  • Species are connected to upper species and tickets.
Repositories

These are the repositories used in the application. They are used to interact with the database.

Services

These are the services used in the application. They are used to interact with the repositories and perform business logic.

Controllers

These are the controllers used in the application. They are used to handle the HTTP requests.

DTOs

These are the DTOs used in the application. They are used to transfer data between the frontend and the backend.

Components

There is a component for data initialization. It is used to initialize the database with some data. The data is initialized in a table, in case the table is empty. If you do any changes to the data, you need to delete the data in the table and restart the application IN CASE you wish the table to have the exact data which is defined in the initialization component.

Security

These are the classes used for security in the application. They are used to authenticate and authorize users.

  • SecurityConfig is used to configure the security settings. It uses JWT for authentication. All requests are authenticated except for the login and register requests.
  • JwtAuthorizationFilter is used to filter the requests and validate the JWT token.
  • CustomAuthenticationFilter is used to authenticate the user.

NB! This is important information that should be read before starting to work on the project:

  • Currently only login is accessible without authentication. To access other endpoints, you need to be authenticated.
  • To authenticate, you need to send a POST request to /login with the following body (this is done in the login method in the frontend):
{
    "email": "...",
    "password": "..."
}
  • The response will contain a JWT token that you need to include in the Authorization header of your requests (the token is stored in the frontend store):
{
    'Authorization': `Bearer ${this.token}`
}
  • The token is valid for 1 hour. After that, you need to authenticate again.
  • No endpoints are accessible without authentication. If you try to access an endpoint without authentication, you will get a 403 Forbidden response.
  • The backend endpoints can be constructed normally, just remember to include the Authorization header with the token when you make an API call in the frontend.

Frontend

Components

These are the components used in the application. They are used to display the data and handle the user input.

Pages

These are the pages used in the application. They are used to display the components. They will perform most of the logic. Please include the JWT token in the Authorization header when making requests to the backend.

Routes

These are the routes used in the application. They are used to navigate between the pages.

Store

This is the store used in the application. It is used to store the data and manage the state of the application. Currently, the logged-in user's data is stored in the store.