![](https://private-user-images.githubusercontent.com/10380342/340599230-25581344-41c6-400a-a601-65926d23c0ce.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTY0MjgsIm5iZiI6MTcyNDU5NjEyOCwicGF0aCI6Ii8xMDM4MDM0Mi8zNDA1OTkyMzAtMjU1ODEzNDQtNDFjNi00MDBhLWE2MDEtNjU5MjZkMjNjMGNlLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDE0Mjg0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQxZmZiY2ExZGNjYWViMDFlY2QwNDZkNTZmMjhhNjk1NzczN2VlZGJiZDQyMTQ0MTg3YWQ4MGRlMTNhYzM5NzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lqHi2DMtLp2e7KfQRlI25ldTepp2UIxu7dvHk_VY7zc)
LocationNinja is a robust service built using vertical slice architecture designed to handle various location-based queries. It supports converting IP addresses to physical locations and can be easily integrated into your web applications. The system uses data from third-party providers and caches results in MongoDB for optimized performance.
- IP to Location: Converts IP addresses to physical locations using third-party data.
- Caching: Utilize MongoDB for improved performance.
- Dockerizing: Containerize the LocationNinja using DockerFile and Docker Compose for simplified deployment and management.
- Minimal APIs: Leveraging ASP.NET Core's minimal APIs for creating lightweight HTTP APIs with minimal dependencies.
- ASP.NET Core and .NET 8
- AutoMapper: For object-object mapping.
- FluentValidation: For model validation.
- MongoDB: For caching previously queried data.
- Entity Framework Core: For database interaction.
- OpenAPI: For generating Swagger API documentation.
- Docker: For containerizing the application.
- Xunit: For unit testing.
- Moq: For mocking dependencies in tests.
- FluentAssertions: For more readable and maintainable assertions in tests.
- Request For Location: Initiates requests for various location-based queries.
- Features: Core functionalities that process different types of location requests.
- Related Service: Handles specific tasks related to each feature.
- Provider: Third-party services that provide data for location.
- Cache: MongoDB is used to store previously queried data to improve performance.
![](https://private-user-images.githubusercontent.com/10380342/340605002-9498b5ed-f026-4bce-9794-aac9138821cc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTY0MjgsIm5iZiI6MTcyNDU5NjEyOCwicGF0aCI6Ii8xMDM4MDM0Mi8zNDA2MDUwMDItOTQ5OGI1ZWQtZjAyNi00YmNlLTk3OTQtYWFjOTEzODgyMWNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDE0Mjg0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2MWY1NDhhODJjZThmZTIxMTQxZmM2YjZkOTM3ZWM5NTg2YmQ2ODc0NTA3OWVkM2Y2MDE1ZmNiNmZjNmM1OTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.CopRPRztdRW_3OVnjed6USctoDkN0AcxbfFvGXl8dl4)
-
Clone the Repository:
git clone https://github.com/emaadgh/LocationNinja.git
-
Install Dependencies:
- Ensure you have .NET SDK 8 installed.
- Open a terminal and navigate to the project folder:
cd LocationNinja
- Restore dependencies:
dotnet restore
-
Pull and Run MongoDB Docker Image:
- Ensure you have Docker installed and running.
- Pull the MongoDB Docker image:
docker pull mongo
- Run the MongoDB container:
docker run -d -p 27017:27017 --name locationninja-mongo mongo
-
Run the Application:
- Start the API by running the following command in your terminal:
dotnet run
- Start the API by running the following command in your terminal:
-
Explore the API:
- Once the API is running, you can use tools like Swagger to interact with the endpoints.
- Visit the Swagger UI at
https://localhost:<PORT>/swagger/index.html
to explore the API documentation interactively.
Please note that appsettings.json
files are not included in the Git repository. These files typically contain sensitive information such as database connection strings, API keys, and other configuration settings specific to the environment.
For local testing, you can create your own appsettings.json
file in the root directory of the LocationNinja project and add the necessary configurations.
Here's an example of how you can configure your appsettings.json
file:
{
"MongoDatabase": {
"Host": "mongodb://localhost:27017",
"DatabaseName": "locationNinja"
},
"Features": {
"IpLocation": {
"IpApiBaseUrl": "http://ip-api.com/json/"
}
},
// Other configurations...
}
If you deploy the LocationNinja to Azure App Service, you can add the connection strings in the Connection Strings section of the Configuration settings in the Azure portal. Azure App Service securely encrypts connection strings at rest and transmits them over an encrypted channel, ensuring the security of your sensitive information.
Contributions are welcome! If you'd like to enhance LocationNinja, you can submit pull requests or open issues.
This project is licensed under the MIT License. Inspired by lessons from ThisIsNabi's live coding sessions.