Skip to content

A robust RESTful API service for managing and retrieving information about landmarks worldwide.

Notifications You must be signed in to change notification settings

franciszek-szeptycki/landmark-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Landmark API

A robust RESTful API service for managing and retrieving information about landmarks worldwide. The API provides detailed information about historical sites, monuments, and points of interest, with different access levels based on subscription tiers.

🌟 Features

  • Authentication & Authorization

    • JWT-based authentication
    • Role-based access control
    • API key management
    • Subscription-based access tiers (Free, Pro, Enterprise)
  • Landmark Information

    • Comprehensive landmark details
    • Geolocation data
    • Historical information
    • Visitor information
    • Accessibility details
    • Opening hours and ticket prices
    • Live Data (Weather, Public transport)
  • Advanced Querying

    • Field selection
    • Pagination
    • Sorting
    • Filtering
    • Full-text search
    • Search by coordinates with radius
    • Search by category
  • Performance & Scalability

    • Redis caching
    • Rate limiting
    • Connection pooling
    • Optimized database queries

πŸš€ Getting Started

Prerequisites

  • Go 1.19 or higher
  • PostgreSQL 13 or higher
  • Redis 6.x or higher
  • Docker (optional)

Environment Setup

  1. Clone the repository:
git clone https://github.com/Gravgor/landmark-api.git
cd landmark-api
  1. Create a .env file in the project root:
# Server Configuration
PORT=5050
ENV=development

# Database Configuration
DATABASE_URL=postgresql://username:password@localhost:5432/landmark_db?sslmode=disable

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password

# JWT Configuration
JWT_SECRET=your_jwt_secret_key

# Rate Limiting
RATE_LIMIT=100
RATE_LIMIT_DURATION=1h

Running the Application

Local Development

  1. Install dependencies:
go mod download
  1. Start the database and Redis (if using Docker):
docker-compose up -d postgres redis
  1. Run migrations:
go run cmd/migrate/main.go
  1. Start the server:
go run main.go

Using Docker

docker-compose up -d

πŸ“– API Documentation

Authentication

Register a new user

POST /auth/register
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "securepassword",
  "name": "John Doe"
}

Login

POST /auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "securepassword"
}

Landmarks

Get all landmarks

GET /api/v1/landmarks
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>

Query Parameters:

  • limit (default: 10)
  • offset (default: 0)
  • sort (e.g., "-name" for descending order)
  • fields (comma-separated list of fields)
  • Additional filters as query parameters

Get landmark by ID

GET /api/v1/landmarks/{id}
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>

Get landmarks by country

GET /api/v1/landmarks/country/{country}
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>

Search landmarks by name

GET /api/v1/landmarks/name/{name}
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>

Subscription Tiers

Feature Free Plan Pro Plan Enterprise Plan
Basic landmark info βœ“ βœ“ βœ“
Detailed descriptions βœ— βœ“ βœ“
Historical significance βœ— βœ“ βœ“
Visitor tips βœ— βœ“ βœ“
Real-time data βœ— βœ— βœ“
Rate limit 100/hour 1000/hour Unlimited

πŸ›  Project Structure

landmark-api/
β”œβ”€β”€ cmd/
β”‚   └── migrate/
β”‚       └── main.go
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── handlers/
β”‚   β”œβ”€β”€ cache/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ repository/
β”‚   └── services/
β”œβ”€β”€ migrations/
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ main.go
└── README.md

πŸ”’ Security

  • All endpoints except /auth/register and /auth/login require authentication
  • Passwords are hashed using bcrypt
  • Rate limiting is implemented per API key
  • Input validation and sanitization
  • Prepared statements for database queries
  • Environment-based configuration

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  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.

πŸ™ Acknowledgments

πŸ“§ Contact

Marceli Borowczak - marceliborowczak@example.com

Project Link: https://github.com/Gravgor/landmark-api

About

A robust RESTful API service for managing and retrieving information about landmarks worldwide.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published