A civic-initiated open API for Thai political data
To learn more about the data and API, visit the documentations
Warning
We are not responsible for any misinformation or consequence of any usage on our data. These open data are collected, transformed, validated, and published by us, a civil society, to push the open API standard in Thailand. We are not the official government institution who originally own and responsible in publishing these data. Please send us any feedback or suggestion via team@wevis.info or create an issue on GitHub.
Managed with Turborepo
- /apps : Application repository
- /admin : Admin dashboard for managing Politigraph data to be built as SPA
- /api : Backend API for GraphQL, authentication, and static file (web/assets) serving
- /docs : Landing page and documentations to be built as static website
- /packages : Shared packages between app
- /auth : Authentication and related database management
- /config : Centralized environment variable validation
- /graphql : Schemas and custom resolvers implementation
Main routes of the final application:
/A landing page and documentation for public/adminAdmin panel for managing politigraph data (required an account)/graphqlGraphQL endpoint and playground for querying and updating data./mcpMCP server for AI agents/observeOpenObserve dashboard for usage analytics and logs (required an account)
https://politigraph.wevis.info will be deployed through GitHub Actions every time the repository code has updated.
Following these steps will help you set up Politigraph on your local development environment.
Add required environment variables to the root .env. See .env.example at the project root for the full list. Make sure POSTGRES_PASSWORD matches the password embedded in DATABASE_URL.
@politigraph/config loads env files in order:
.env— baseline.env.{NODE_ENV}— overrides (e.g..env.production)
All files are optional. NODE_ENV defaults to development.
Using Docker Compose
docker compose up -dNeo4j API will be running at http://localhost:7687 with web UI at http://localhost:7474 and the data is stored in .neo4j folder in your project root.
Postgres will be running at http://localhost:5342 and the data will ve stored in docker volume.
Requires Bun
bun i # Install dependencies for the first time
bun run devDependency packages will be built and every apps will run in dev mode in parallel. Following the console to see which app running on which port.
You need to create an account first to login to the admin panel, by making a POST request to /auth/sign-up/email of API URL with header Origin: http://localhost:3000 and the following body:
{
"name": "*****",
"email": "*****",
"password": "*****"
}The project has three test levels:
- Unit tests — test individual functions and composables
- Integration tests — test API routes and GraphQL resolvers with real databases
- E2E tests — test full user flows in the admin panel using Playwright
All tests require test databases. Start them with:
docker compose -f compose.test.yml up -d --waitThen run tests:
bun run test:unit # Unit tests only
bun run test:integration # Integration tests (requires test databases)
bun run test:e2e # E2E tests (requires test databases + seed)compose.test.yml provides isolated test databases:
- Neo4j on port
7688(avoids conflict with dev Neo4j on 7687) - Postgres on port
5433(avoids conflict with dev Postgres on 5432)
GraphQL required user account for write permission. To make an update to GraphQL outside the Politigraph website, you need to create an API key by logging in into the Admin Panel (/admin) > Profile Menu > API Keys. Then add x-api-key: KEY_VALUE to the header when making a request.
To make local neo4j have up-to-dated data, we have a script to use rsync to download production database while local neo4j docker service in not running:
bun run db:pullTo stop the API and MCP from querying or mutating data during a migration, stop the API container on the app server:
docker compose stop elysia
# run the migration
docker compose up -d elysiaWhile the container is down, nginx answers every API route (/graphql, /mcp, /auth, etc.) with 503 and a GraphQL-style error body. The docs and admin static pages are still served. Don't push to main during the migration, as the deployment will start the container again.
The app server ships container logs to a self-hosted OpenObserve at /observe:
elysia, nginx (stdout) → Vector (servers/app/vector) → OpenObserve (servers/app/compose.yml)
Vector routes lines into three streams:
api_usage: one event per GraphQL operation (fieldsanddeprecatedasType.field,source,client, duration, errors) and per MCP connect, tool call, and resource read, written byapps/api/src/plugins/usage.ts. Query text, variables, and responses are never loggednginx: JSON access log, without static asset hits under 400elysia: everything else the API prints, e.g. startup, crashes, and errors
client is the Origin host for browsers, or the apollographql-client-name header for server-side consumers, otherwise direct. The same events, without field details, are also sent to Plausible. To comply with PDPA, no raw IP or email is stored
Operation notes:
OPENOBSERVE_USERandOPENOBSERVE_PASSWORDmust be set on the app server, compose refuses to start without them- Field names are lowercased on ingestion, and array fields are stored as strings, so unnest them with
unnest(cast_to_arr(fields))in SQL
The heap is a fixed block reserved at startup, so free and docker stats look the same whether it is empty or full. When Neo4j pins the CPU without a traffic spike, find the host PID of the java process and check its threads on the DB server:
docker top neo4j
top -H -p <host_java_pid>Busy GC Thread threads mean the heap is full. Find the Java PID inside the container (the last number of NSpid), then inspect the heap as the neo4j user (uid 7474):
grep NSpid /proc/<host_java_pid>/status
docker exec -u 7474 neo4j jcmd <pid> GC.heap_info
docker exec -u 7474 neo4j jcmd <pid> GC.class_histogram | head -30Classes from org.neo4j.cypher.internal (InputPosition, Prettifier, AST nodes) at the top mean the query plan cache filled the heap. CALL db.clearQueryCaches() frees it without a restart, and server.memory.query_cache.per_db_cache_num_entries in servers/db/compose.yml caps it.
Regarding the data, the team intends to open it as Open Data under the Attribution-NonCommercial 4.0 International terms. This means you can use, modify, and build upon the data, but it cannot be used for commercial purposes or to seek profit from the work, and credit must be given to WeVis.
Regarding the source code, the team intends to develop every project as Open Source under the Attribution-NonCommercial-ShareAlike 4.0 International terms. This means you can use, modify, and build upon the work, but it cannot be used for commercial purposes or to seek profit from the work. You must provide notice and credit to the work's owner, and the resulting work must be under the same Creative Commons license conditions as the original. WeVis Ltd. and Punch Up Ltd. are joint licensors.