Skip to content

πŸ—ΊοΈ A comprehensive API for Costa Rica's provinces, cantons, and districts. Built with NestJS and a hexagonal architecture for scalability and clean code. Perfect for developers building location-based applications. πŸš€

License

Notifications You must be signed in to change notification settings

anibalalpizar/api-geo-cr

Repository files navigation

🌎 API Geo CR

πŸ“– Description

API Geo CR is a REST API that provides up-to-date geographic information about Costa Rica, including its provinces, cantons and districts. Developed with hexagonal architecture (ports and adapters) to ensure a clean and maintainable design.

🌐 Live Demo

You can explore the API in action here: https://api-geo-cr.vercel.app/

✨ Features

  • ✨ Query of all provinces of Costa Rica
  • πŸ™οΈ Detailed information of cantons by province
  • πŸ“ Complete data of districts by canton
  • πŸ” Search by ID for provinces, cantons and districts
  • πŸ“„ Integrated pagination in all queries
  • πŸ“š Complete documentation with Swagger
  • ⚑ Quick answers with data in memory
  • πŸ§ͺ Complete test coverage

πŸ› οΈ Stack

You will need:

βš™οΈ Installation

# Clone the repository
git clone https://github.com/anibalalpizar/api-geo-cr.git

# Install dependencies
npm install

# Configure environment variables
cp .env.example .env
Variable Description Possible Values Default
NODE_ENV Execution environment development, production, test development
PORT Application port Any valid port 3000
SWAGGER_ENABLED Enable/disable Swagger true, false true

πŸš€ Execution

# Development mode
npm run start:dev

# Debug mode
npm run start:debug

# Production mode
npm run start:prod

🌐 API use

Main Endpoints

# Get all provinces
GET /provincias

# Obtaining cantons from a province
GET /provincias/{id}/cantones

# Get all cantons
GET /cantones

# Obtain districts from a canton
GET /cantones/{id}/distritos

# Get all districts
GET /distritos

πŸ“‹ Pagination

All endpoints support pagination via query params:

GET /provincias?page=1&limit=2

πŸ› οΈ Example Response

{
  "status": "success",
  "statusCode": 200,
  "message": "Provincias fetched successfully",
  "data": [
    {
      "idProvincia": 1,
      "descripcion": "San JosΓ©"
    },
    {
      "idProvincia": 2,
      "descripcion": "Alajuela"
    }
  ],
  "meta": {
    "totalItems": 7,
    "itemCount": 2,
    "itemsPerPage": 2,
    "totalPages": 4,
    "currentPage": 1,
    "timestamp": "2024-11-23T10:34:16.809Z"
  }
}

πŸ“š Documentation

Full API documentation is available in Swagger UI:

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ application/       # Use cases
β”œβ”€β”€ domain/            # Entities and repositories
β”‚   β”œβ”€β”€ entities/
β”‚   └── repositories/
β”œβ”€β”€ infrastructure/    # Concrete implementations
β”‚   └── persistence/
└── interfaces/        # Controllers and modules
Diagrama del flujo de datos

πŸ§ͺ Testing

# Running unit tests
npm run test

# Running tests with coverage
npm run test:cov

🀝 Contribution

Contributions are welcome. Please follow these steps:

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

πŸ”‘ License

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

About

πŸ—ΊοΈ A comprehensive API for Costa Rica's provinces, cantons, and districts. Built with NestJS and a hexagonal architecture for scalability and clean code. Perfect for developers building location-based applications. πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published