justicehub-in / budget-for-justice

A web platform to analyse Budget Datasets for selected government schemes around law and justice. https://budgets.justicehub.in/about
GNU Affero General Public License v3.0
2 stars 0 forks source link
budget-data dashboard government-data participatory-budget

Budgets for Justice

An initiative by Justice Hub and Civis

GNU Affero General Public License v3.0

The Budgets for Justice platform brings together open budget data from the Union Government of India over the last few years to reveal trends and patterns in budget allocation and expenditures for the law and justice sector. Our objective is to make budget data more accessible, usable and comprehensive so we can stay informed about how the law and justice sector (including courts, police, prison, legal aid etc.) is funded and sourced. Read more here

Features

Getting Started

Install a recent version of Node. Minimum Node 14 is recommended.

Guide

Styling 🎨

We use SASS preprocessor to manage styling. All of it can be found at /styles directory where it's managed by using ITCSS architecture to make it scalable. For naming, we use BEM methodology.

Pages

Data fetching

We use REST API to fetch data from CKAN. Some of the data comes as metadata and other is in CSV files, for which we use different transformers. You can find more about it in /transoformers directory.

Fetch all datasets for listing pages

When visiting a dataset lisitng page, you may want to fetch the particular type of datasets. To do so, you can use getServerSideProps function from NextJS:

import { GetServerSideProps } from 'next';
import { fetchDatasets } from 'utils/index';

export const getServerSideProps: GetServerSideProps = async () => {
  const data = await fetchDatasets();

  return {
    props: {
      data,
    },
  };
};

Learn more about them here.

Fetch particluar dataset

Depending on dataset, they may return metadata in the form of JSON or a combination of JSON and CSV file. We can use fetchAPI in this case:

import { GetServerSideProps } from 'next';
import { fetchAPI } from 'utils/index';
import { resourceGetter } from 'utils/resourceParser';

export const getServerSideProps: GetServerSideProps = async (context) => {
  const data = await fetchAPI(context.query.tender);
  const csv = await resourceGetter(data.result.resources, 'CSV');

  return {
    props: {
      data,
      csv,
    },
  };
};

Developers

Boot the local instance

Install the dependencies:

npm i

Boot the demo frontend:

npm run dev

Open http://localhost:3000 to see the home page πŸŽ‰

You can start editing the page by modifying /pages/index.tsx. The page auto-updates as you edit the file.

Architecture

Contributing

For any new feature or bug reports, please request it in issues.

See CONTRIBUTING.md for ways to get started.

Please adhere to Code of Conduct.