Skip to content

izacarias/lapi

Repository files navigation

Location API (LAPI)

A partial implementation of ETSI GS MEC 013 Location API specification. This API provides location services for Mobile Edge Computing applications.

GitHub last commit GitHub top language MongoDB Go Docker Compose

Acknowledgment

This work was partially supported by the German Federal Ministry of Education and Research (BMBF) project 6G-ANNA, grant agreement number 16KISK100.

Logo of 6G-ANNA Project Logo of BMBF

Features

  • Zone management and queries
  • Access point information
  • User location tracking
  • Distance calculations
  • Swagger documentation
  • RESTful API endpoints

Prerequisites

  • Go 1.23.3 or higher
  • MongoDB (v7.0)
  • Docker (optional)
  • Docker Compose (optional)

Quick Start with Docker Compose

The easiest way to run the application is using Docker Compose:

docker compose up -d

This will start both the API service and MongoDB. The API will be available at:

Running Locally

1. Environment Setup

Create a .env file in the project root:

MONGOURI=mongodb://localhost:27017/lapi
APIROOT=http://localhost:8080
APIVERSION=v3
PURGEDATABASE=1
INSERTMOCKDATA=1

2. Start MongoDB

Using Docker:

docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest

Or using Podman:

podman run --name mongodb --privileged -p 27017:27017 -d docker.io/mongodb/mongodb-community-server:latest

or if is was already initialized

docker start mongodb

or

podman start mongodb

3. Run the Application

go run main.go

API Documentation

The API documentation is available through Swagger UI at /docs endpoint. You can also find the OpenAPI specification at /swagger/doc.json.

Note

Depending on your system, it might require to run podman with root privilleges (e.g., Fedora) This is due to a requirement of MongoDB and the rights to access files in folders. Without the sudo command, SElinux prevents the MondoDB container to write in the filesystem causing an error.

Testing

Integration Tests

The integration tests assume the MongoDB instance is running an is accessible. Please keep in mind that the database will be recreated and filled with mock data (make sure that the options PURGEDATABASE and INSERTMOCKDATA are enabled in the .env file).

Change to the project directory and run the tests as following:

go test -v

Manual Testing

You can test the API endpoints using:

  1. The provided REST Client file in ./tests/Requests.rest
  2. Swagger UI at /docs
  3. Any HTTP client (like Postman or cURL)

Development

Update Swagger Documentation

swag init -g main.go --output docs/swagger

Project Structure

.
├── configs/            # Utility functions to get configuration values
├── controllers         # Controllers to receive and route the requests
├── docs/               # Swagger generated documentation files
├── domain/             # Entitites and data models
├── mock/               # Functions to insert mock data into database
├── responses/          # Definition of objects used in responses as JSON
├── routes/             # Route definitions
├── services/           # Coupling between domain entities (WIP!)
├── tests/              # Test files
├── utils/              # Utility functions
...
├── docker-compose.yml  # Docker-related files
├── Dockerfile          # Docker-related files

Integration with MininetWifi

  • Install Mininet-Wifi according to the official documentation available in GitHub
  • Get the mobility.py and lapi.py files from this repository
    • Create a folder in your home directory in the machine where Mininet-Wifi was installed
    • Download the files
    • Execute the Mininet-Wifi emulation scenarion
cd ~
mkdir lapi-integration
cd ~/lapi-integration
curl -XGET https://raw.githubusercontent.com/izacarias/lapi/refs/heads/main/utils/mininet/lapi.py -o lapi.py
curl -XGET https://raw.githubusercontent.com/izacarias/lapi/refs/heads/main/utils/mininet/mobility.py -o mobility.py
sudo mn -c && sudo ./mobility

Note

If you are using a Virtual Machine to run Mininet-Wifi, make sure that the machine can acccess the LAPI service (You can use the Ping Endpoint for testing http://LAPI_IP/:8080/ping)

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contact

Iulisloi Zacarias

Project Link: https://github.com/izacarias/lapi

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors