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.
-
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
- Go 1.19 or higher
- PostgreSQL 13 or higher
- Redis 6.x or higher
- Docker (optional)
- Clone the repository:
git clone https://github.com/Gravgor/landmark-api.git
cd landmark-api
- 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
- Install dependencies:
go mod download
- Start the database and Redis (if using Docker):
docker-compose up -d postgres redis
- Run migrations:
go run cmd/migrate/main.go
- Start the server:
go run main.go
docker-compose up -d
POST /auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword",
"name": "John Doe"
}
POST /auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword"
}
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 /api/v1/landmarks/{id}
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>
GET /api/v1/landmarks/country/{country}
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>
GET /api/v1/landmarks/name/{name}
Authorization: Bearer <your_jwt_token>
X-API-Key: <your_api_key>
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 |
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
- 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
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Gorilla Mux for routing
- GORM for database operations
- JWT-Go for JWT authentication
- Go-Redis for caching
Marceli Borowczak - marceliborowczak@example.com
Project Link: https://github.com/Gravgor/landmark-api