This project offers a user-friendly RESTful service for discovering events happening near you. It leverages a CSV dataset for event information and provides an API to search events based on your location and desired date.
- Event Upload API: A dedicated
/addevent/
endpoint allows authorized users to submit events by providing details like name, city, date, time, and geospatial coordinates (latitude and longitude).
- Event Search API: The powerful
/search_events/
endpoint empowers users to find events based on their current location (latitude and longitude) and a specific date. The service returns a comprehensive list of relevant events:- Occurring within a specified window (e.g., the next 14 days by default) from the provided date.
- Sorted chronologically (earliest events first) for optimal planning.
Each event response includes:
- **Event Name:** Clearly identifies the event.
- **City:** Indicates the location where the event takes place.
- **Date:** Provides the date information for the event.
- **Weather Information (External API):** Integrates real-time weather data from a reliable external API to enhance the user experience.
- **Distance from User Location (External API):** Calculates the distance between the user's current location and the event venue using an external distance calculation API, ensuring accurate distance information.
git clone [https://github.com/Gl1tchk0ng/Event_gg.git](https://github.com/Gl1tchk0ng/Event_gg.git)
To install the required packages, navigate to the folder where you have cloned the repository, open it in your IDE, and run the following command:
pip install -r requirements.txt
The CSV file which needs to be loaded into a database is also present in the repository.
Install Docker from here if not already installed, and then execute the following Docker commands:
-
Pull the PostgreSQL image:
docker pull postgres
-
Run PostgreSQL Container:
docker run --name <docker_container_id> -e POSTGRES_PASSWORD=password -d -p 5432:5432 postgres
-
Access PostgreSQL Container's Bash:
docker exec -it <docker_container_id> bash
-
Log in to PostgreSQL:
psql -U postgres
-
Create Database:
create database d1;
-
Connect Database to Project:
Update the
settings.py
file in the project's root directory (core) to connect to the database using environment variables. Refer to the environment variables listed below. After configuring the database connection, make model migrations using thedjango-admin makemigrations
anddjango-admin migrate
commands in the project repository. -
Copy CSV Data:
Use the following command to copy the CSV file from your local system to the Docker container:
docker cp <local_system_file_location> <docker_container_id>:/tmp/dataset
-
Load CSV Data into Database:
Execute the following command to load data from the CSV file into the database:
psql -U postgres -d d1 -c "COPY dataloader_eventdata (event_name, city_name, date, time, latitude, longitude) FROM '/tmp/dataset' DELIMITER ',' CSV HEADER;"
- Now all the endpoints can be accessed and the operations can be done as per requirement
In the root directory (core), create a file named .env
and paste the following environment variables:
calculatorurl=External API URL that calculates the distance from the user to the event
weatherurl=External API URL that calculates the weather at the event
DATABASE_NAME=<Replace_with_your_database_name>
DATABASE_USER=postgres
DATABASE_PASSWORD=<your_password>
DATABASE_HOST=localhost
DATABASE_PORT=5432
Run the server and follow the link
python manage.py runserver
For all available URL options demo and expected results,https://github.com/Gl1tchk0ng/Event_gg/assets/155849958/316e2ab7-baed-4d53-b4ce-93c934ce779b
- Django
- HTML
- PostgreSQL
- Robust security and scalability are the main reasons for preferring Django over other web dev frameworks
- PostgreSQL is a Relational Database and can be scaled with ease and maintainability is easy compared to nonrelational DBs
- Async support for the DB (Django-ORM)is not yet available for real-time running so the performance factor is hindered when compared with node or any other JS framework or FastAPI (Since the project is focused on the async calling of DB items for the most part using celery or Django_channels was not an option but for other real-time connections like if the ORM is changed to something like SQLAlchemy then the performance might have increased a bit.)
- Django HTML Template Engine(jinja2) is shit (Using React would be a better option)