GithubHelp home page GithubHelp logo

duarty / gogym Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 72 KB

Welcome to the Go API Rest repository! This project is a Go-based API that integrates with the Google API to check if a user is within a 20-meter radius of a gym. If the user is within this radius, they can check in at the gym. If the gym does not already exist in the database, it will be saved for future check-ins by other users.

Go 98.86% Dockerfile 1.14%

gogym's Introduction

๐Ÿ“ Go API Rest (under construction)

Welcome to the Go API Rest repository! This project is a Go-based API that integrates with the Google API to check if a user is within a 20-meter radius of a gym. If the user is within this radius, they can check in at the gym. If the gym does not already exist in the database, it will be saved for future check-ins by other users. This approach minimizes requests to the Google Geolocation API by leveraging a local database.

๐ŸŒŸ Features

User Check-In: Check if a user is near a gym and allow check-ins.
Gym Persistence: Save gyms to the database for future reference.
Efficient API Calls: Minimize requests to the Google API by storing gym data locally.
Clean Architecture: Well-structured code using DTOs, services, controllers, use cases, domain, and repository layers.
Postgres with Docker: Use PostgreSQL as the database, managed with Docker for easy setup and management.
Automated Database Setup: SQL scripts for automatic creation of tables and fields.

๐Ÿ› ๏ธ Technologies Used

Programming Language: Go (Golang)
Database: PostgreSQL
Containerization: Docker
Geolocation API: Google API
Architecture: Clean Architecture

๐Ÿš€ Getting Started Prerequisites

Go: Download and install Go
Docker: Download and install Docker

Installation

Clone the repository:

sh

git clone https://github.com/duarty/go-api-rest.git cd go-api-rest

Set up the database:

sh

docker-compose up -d

Run the SQL script to set up the tables:

sh

docker exec -i your_postgres_container psql -U your_user -d your_database < path_to_your_sql_script.sql

Install dependencies:

sh

go mod tidy

Run the application:

sh

go run main.go

Configuration

Create a .env file in the root directory and add the following environment variables. You can use the .env.example provided for reference:

sh

############ ENV CONFIGS ################# DB_DRIVER=postgres DB_HOST=localhost DB_PORT=5432 DB_PASSWORD=root DB_USER=postgres DB_NAME=api SERVER_PORT=3000 SECRET=secret JWT_EXPIRES_TIME=300

############ GOOGLE CLOUD PLATFORM SERVICES ################# GOOGLE_MAPS_API_ENDPOINT=https://places.googleapis.com/v1/ GOOGLE_MAPS_API_PLACES=places:searchNearby GOOGLE_MAPS_API_KEY=GCP_API_KEY

############ API CONFIGS ################# NEARBY_SEARCH_RADIUS=50.0 INCLUDED_TYPES=gym SEARCH_FIELDMASK=places.id,places.displayName,places.formattedAddress,places.location

๐Ÿ“‚ Project Structure

The project follows the principles of Clean Architecture. Here's a brief overview of the main directories:

/domain: Contains the core business logic and entities.
/usecase: Contains the application-specific business rules.
/repository: Contains the database access logic.
/controller: Contains the web handlers and controllers.
/service: Contains the service layer that coordinates between the controllers and the use cases.
/dto: Contains Data Transfer Objects used for communication between layers.

๐Ÿ“– Usage

Check-In: Endpoint to check if a user is within a 20-meter radius of a gym and perform a check-in.
Add Gym: Automatically adds new gyms to the database if they do not already exist.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. ๐Ÿ“œ License

This project is licensed under the MIT License. See the LICENSE file for details. ๐Ÿ“ž Contact

For any questions or suggestions, feel free to reach out via email.

Thank you for checking out Go API Rest! Enjoy checking in at your favorite gyms effortlessly! ๐Ÿ’ช

gogym's People

Contributors

duarty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.