Skip to content

velo-project/routes-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Routes Service

This is a Go project that provides a service for managing tracks and routes.

Getting Started

To get started with this project, you'll need to have Go installed on your machine. You'll also need to have a running instance of PostgreSQL.

Prerequisites

  • Go
  • PostgreSQL
  • Docker (optional)

Installation

  1. Clone the repository:

    git clone https://github.com/velo-project/routes-service
  2. Install the dependencies:

    go mod tidy
  3. Set up the environment variables:

    cp .env.example .env

    The following environment variables are used:

    • POSTGRES_CONNECTION_STRING: The connection string for the PostgreSQL database.
    • RSA_PUBLIC_KEY: The path to the RSA public key for verifying JWT tokens.
  4. Run the database migrations:

    # Assuming makefile exists or using a migration tool
    migrate -path db/migrations -database "postgres://user:password@host:port/dbname?sslmode=disable" up
  5. Run the server:

    go run cmd/api/main.go

Docker

To build and run the project using Docker, you can use the following commands:

  1. Build the Docker image:
    docker build -t routes-service .
  2. Run the Docker container:
    docker run --env-file .env -p 8080:8080 routes-service

Folder Structure

The project is organized into the following folders:

  • cmd/api: Contains the main application entry point.
  • db/migrations: Contains the database migrations.
  • internal: Contains the core application logic.
    • adapters: Contains the adapters for connecting to external services.
      • database: Contains the adapters for modifying PostgreSQL Data
      • grpc: Contains the adapters for call procedures in other APIs
      • http: Contains the rest controllers
    • core: Contains the core domain logic.
      • domain: Contains the domain models.
      • ports: Contains the interfaces for the repositories and services.
      • services: Contains the application services.
  • plan: Contains the project plan.
  • proto: Contains the protobuf files for the gRPC services.

API Endpoints

The following API endpoints are available:

  • POST /tracks: Creates a new track.
  • GET /tracks: Finds all routes for a given user.
  • DELETE /tracks/:trackId: Deletes a track.

Development

Creating Migrations

To create a new migration, you can use the following command:

migrate create -ext sql -dir db/migrations -seq create_my_migration

This will create a new migration file in the db/migrations folder.

Running Migrations

To run the migrations, you can use the following command:

migrate -path db/migrations -database "postgres://user:password@host:port/dbname?sslmode=disable" up

Make sure to replace the connection string with your own.

Generating Protobuf

To generate the .pb.go file from the .proto file, you can use the following command:

protoc --go_out=. --go-grpc_out=. proto/user_service.proto

Dependencies

The project uses the following dependencies:

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors