This is the backend code for a disaster management app. The backend is built using GoLang and utilizes various libraries and frameworks. The app allows users to sign up, log in, and submit their location in case of a disaster. It also provides endpoints to retrieve information about users in need of help.
- User sign up
- User login
- Submitting user location during a disaster
- Retrieving information about users in need of help
To run the backend locally, follow these steps:
-
Clone the repository:
git clone https://github.com/enesuzun2002/afet_backend.git
-
Change into the project directory:
cd afet_backend
-
Install the dependencies:
go mod download
-
Set up the PostgreSQL database and update the connection string in the code.
-
Run the project:
go run .
-
The backend server will start running on
http://localhost:8080
.
The following API endpoints are available:
- POST /signup: Creates a new user account.
- POST /login: Logs in an existing user.
- POST /yardimaihtiyacimvar: Submits user location during a disaster (requires authentication).
- GET /yardimedebilirim: Retrieves information about users in need of help (requires authentication).
The backend uses JSON Web Tokens (JWT) for authentication. When a user signs up or logs in, a JWT token is generated and returned in the response. This token should be included in the Authorization
header of subsequent requests as follows:
Authorization: <token>
The backend uses a PostgreSQL database. Make sure you have PostgreSQL installed and create a new database. Update the connection string in the code (dsn
variable) to match your database configuration.
The backend relies on the following external libraries:
- github.com/dgrijalva/jwt-go: Used for JWT token generation and validation.
- github.com/gin-gonic/gin: HTTP web framework for building the API.
- gorm.io/driver/postgres: PostgreSQL database driver for GORM.
- gorm.io/gorm: ORM library for database operations.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.