Skip to content

Repository files navigation

OpenNG GraphQL 🇳🇬

License: MIT NestJS GraphQL Prisma ORM TypeScript Contributions Welcome

An open-source, strongly-typed GraphQL knowledge graph and API providing comprehensive, verified data on Nigerian geography, governance, education, culture, history, and tourism.


📖 Table of Contents


🌟 What is OpenNG?

OpenNG GraphQL is a unified, open-access knowledge platform for Nigeria. It models the intricate connections across Nigeria’s 36 states and the Federal Capital Territory (FCT), 774 Local Government Areas (LGAs), wards, political offices, historical timelines, higher institutions, ethnic heritage, languages, and tourism destinations into an intuitive, queryable GraphQL API.

Rather than dealing with static CSVs, outdated government PDFs, or multiple disjointed databases, OpenNG delivers structured, relational data in real time with type safety.


🎯 Why OpenNG?

The Problem

  • Data Fragmentation: Nigerian public data is scattered across legacy websites, fragmented government portals, and unstructured documents.
  • Inconsistent Standards: Varied naming conventions, spelling discrepancies, and missing metadata make automated data consumption difficult.
  • Over-fetching / Under-fetching: Traditional REST endpoints often force clients to make dozens of cascading requests to assemble complete data profiles.

The Solution

  • Single Unified Graph: Request exactly what you need in a single roundtrip.
  • Strongly Typed: Backed by a verified code-first GraphQL schema with comprehensive DTO validation.
  • Relational Integrity: Seamlessly traverse relationships (e.g. StateLGAsWards, StateGovernorPolitical Party, Ethnic GroupFestivals).
  • Community-Driven & Open: Publicly auditable and extensible under the MIT License.

✨ Key Highlights

  • Precision Fetching: Query precise fields for mobile, web, and backend applications without payload bloat.
  • 🔗 Deep Relational Links: Interconnect geographic boundaries, tertiary schools, political office holders, and cultural history.
  • 🔎 Built-in Filtering & Pagination: Paginate through large datasets with structured metadata (total, page, limit, totalPages).
  • 🛡️ Enterprise-Grade Security: Query depth limiting, Helmet CSP nonces, and automated rate limiting.

🗂️ Knowledge Domains

                               ┌───────────────┐
                               │ OpenNG Engine │
                               └───────┬───────┘
          ┌─────────────┬──────────────┼──────────────┬─────────────┐
          ▼             ▼              ▼              ▼             ▼
    ┌───────────┐ ┌───────────┐  ┌───────────┐  ┌───────────┐ ┌───────────┐
    │ Geography │ │Governance │  │ Education │  │  Culture  │ │  History  │
    └───────────┘ └───────────┘  └───────────┘  └───────────┘ └───────────┘
Domain Description Available Entities
🌍 Geography Nigeria's administrative and geopolitical landscape States, LGAs, Wards, Senatorial Districts, Geopolitical Regions, Federal Constituencies
🏛️ Politics & Governance Public offices, electoral history, and administrations State Governors, Presidents, Ministries, Public Offices, Office Holders, Political Parties
🎓 Education Accredited tertiary learning institutions Federal, State, and Private Universities, Polytechnics, and Colleges of Education
🎭 Culture & Heritage Rich cultural tapestry and indigenous identities Ethnic Groups, Indigenous Languages, Traditional Monarchs/Institutions, Cultural Festivals
📜 History Comprehensive historical timeline & key figures Historical Events, Historic Regimes (Civilian/Military), Prominent Figures & Roles
🏖️ Tourism Heritage landmarks, waterfalls, nature parks Tourist Sites, Cultural Monuments, Natural Landmarks categorized by State & Region

🔌 Consuming the API

GraphQL Endpoint

All queries and introspection requests are served via HTTP POST requests to:

POST /graphql

Interactive Playground & Sandbox

When running or accessing OpenNG, an interactive GraphQL Playground/Sandbox is available in your browser at:
👉 /graphql (e.g., http://localhost:3000/graphql)


💡 Query Examples & Use Cases

1. Geography: State Details & Demographics

Retrieve detailed information for a specific state including capital, region, population, and counts of sub-entities:

query GetStateDetails {
  State_getBySlug(params: { slug: "lagos" }) {
    success
    statusCode
    data {
      name
      slug
      capital
      areaKm2
      population
      regionName
      governor
      governorParty
      lgasCount
      universitiesCount
      tourismSitesCount
    }
  }
}

2. Governance: Current State Executives & Political Parties

List current governors alongside their deputy governors and affiliated political parties:

query ListStateGovernors {
  Governor_list(query: { limit: 10, page: 1 }) {
    success
    meta {
      total
      page
      limit
      totalPages
    }
    data {
      stateName
      governorName
      governorPartyName
      deputyName
      deputyPartyName
      assumedDate
    }
  }
}

3. Education: Accredited Tertiary Institutions

Query federal, state, and private universities located within a specific state or across Nigeria:

query ListUniversities {
  University_list(query: { limit: 5, page: 1 }) {
    data {
      name
      slug
      type
      foundedYear
      stateName
      stateSlug
    }
  }
}

4. Culture: Ethnic Groups, Languages & Festivals

Explore ethnic demographics, associated languages, and annual cultural celebrations:

query GetEthnicGroupAndFestivals {
  EthnicGroup_getBySlug(params: { slug: "yoruba" }) {
    data {
      name
      slug
      populationEstimate
      primaryStates
      festivalsCount
    }
  }
}

5. History: Historical Milestones & Regimes

Retrieve chronological events filtered by regime type or era:

query ListHistoricalEvents {
  HistoricalEvent_list(query: { limit: 5, page: 1 }) {
    data {
      title
      slug
      eventYear
      eventDate
      category
      regimeType
      summary
    }
  }
}

6. Tourism: Landmarks & Nature Reserves

Discover tourist attractions and cultural landmarks categorized by state:

query ListTourismSites {
  TourismSite_list(query: { limit: 10, page: 1 }) {
    data {
      name
      slug
      category
      stateName
    }
  }
}

🚀 Target Use Cases

  • 💳 Fintech & KYC / Identity Verification: Validate state of origin, LGA mappings, and residential jurisdictions with standardized spellings.
  • 🗳️ Civic Tech & Public Policy: Build dashboards tracking public offices, political representation, and historical administrations.
  • 📚 EduTech & Career Platforms: Integrate authoritative lists of universities, polytechnics, and colleges with verified accreditation types.
  • 🗺️ Travel & Tourism Apps: Power travel discovery platforms highlighting cultural festivals, heritage sites, and attractions.
  • 📰 Journalism & Fact-Checking: Instantly query historical events, political party histories, and demographic data.

🛡️ Security & Reliability

  • Query Depth Limiting: Protects the API against recursive and denial-of-service (DoS) queries.
  • Content Security Policy (CSP): Nonce-secured CSP headers via Helmet.
  • Rate Limiting: Automated request throttling powered by @nestjs/throttler.
  • Structured Observability: High-performance JSON logging using Pino and Prometheus telemetry.

🛠️ Contributing & Local Development

Interested in contributing datasets, building new resolvers, running the project locally, or submitting a pull request?

👉 Please see our CONTRIBUTING.md for full instructions on:

  • Local environment setup (Node.js, PostgreSQL, Prisma)
  • Running local development and debug servers
  • Database migrations and Prisma Studio
  • Running tests, linter, and formatting
  • Conventional Commits and PR submission guidelines

📜 Code of Conduct

We are committed to providing a friendly, safe, and welcoming environment for everyone. Please review our Code of Conduct before interacting with the repository.


📄 License

This project is licensed under the MIT License.
Copyright (c) 2026 OpenNG Contributors.

About

OpenNG — A fast, scalable, developer friendly free, and well-documented REST/GRAPHQL API for Nigerian data, built with NestJS, Prisma, and PostgreSQL. REST repo: https://github.com/Kim5Y/OpenNG

Topics

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages