diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..6c58c42 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:lts-hydrogen + +WORKDIR /dist + +COPY package*.json ./ + +RUN npm install + +COPY . /dist + +RUN npm run build + +ENTRYPOINT ["/bin/sh", "-c", "npm run start:prod"] \ No newline at end of file diff --git a/backend/README.md b/backend/README.md index 00a13b1..e144292 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,30 +1,19 @@ -

- Nest Logo -

- -[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 -[circleci-url]: https://circleci.com/gh/nestjs/nest - -

A progressive Node.js framework for building efficient and scalable server-side applications.

-

-NPM Version -Package License -NPM Downloads -CircleCI -Coverage -Discord -Backers on Open Collective -Sponsors on Open Collective - - Support us - -

- - -## Description - -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. +# πŸš€ GovTool Delegation Pillar Backend πŸš€ + +The `@intersect.mbo/govtool-delegation-pillar-backend` is a NestJS application that serves as the backend for the GovTool Voting Pillar. It provides the API endpoints for the frontend to interact with the db-sync. + +## Table of content: + +- [Prerequisites](#prerequisites) +- [Installation](#installation) +- [Running the app](#running-the-app) +- [Test](#test) + +## Prerequisites + +- Node.js installed - [Download link](https://nodejs.org/en/download/). +- PostgreSQL installed (if running locally without Docker) - [Download link](https://www.postgresql.org/). +- Docker and Docker Compose installed (for Docker environment) - [Download link](https://docs.docker.com/get-started/) ## Installation @@ -34,6 +23,9 @@ $ npm install ## Running the app +To run the application locally, you need to have Node.js installed. +Copy `.env.example` to `.env` and fill in the required environment variables. + ```bash # development $ npm run start @@ -57,17 +49,3 @@ $ npm run test:e2e # test coverage $ npm run test:cov ``` - -## Support - -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). - -## Stay in touch - -- Author - [Kamil MyΕ›liwiec](https://kamilmysliwiec.com) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) - -## License - -Nest is [MIT licensed](LICENSE). diff --git a/backend/package.json b/backend/package.json index 1eab7e0..e3fc6d0 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,5 +1,5 @@ { - "name": "backend", + "name": "@intersect.mbo/govtool-voting-pillar-backend", "version": "0.0.1", "description": "", "author": "", diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..d7565d8 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,193 @@ +# @intersect.mbo/govtool-delegation-pillar + +The `@intersect.mbo/govtool-delegation-pillar` is a React.js package that provides the essential logic and UI components for managing and conducting delegation within a Cardano governance. + +## Table of content: + +- [Installation](#installation) +- [Usage](#usage) +- [Project Structure](#project-structure) +- [Prerequisites](#prerequisites) +- [Running locally](#running-locally) + +## Installation + +To install this pacakge, use npm or yarn: + +### `npm install @intersect.mbo/govtool-delegation-pillar` + +or + +### `yarn add @intersect.mbo/govtool-delegation-pillar` + +## Usage + +After installation, you can import the component and use it in your project. + +#### This is an example of implementing a package in a [NextJs](https://nextjs.org/) application + +```tsx +'use client'; +import dynamic from 'next/dynamic'; +import { useAppContext } from '@/context'; + +const DelegationPillar = dynamic( + () => import('@intersect.mbo/govtool-delegation-pillar'), + { + ssr: false, + } +); + +export default function Page() { + const { + apiUrl, + walletApi, + validationApiUrl, + cExplorerBaseUrl, + epochParams, + connectWallet, + openFeedbackWindow, + addSuccessAlert, + addErrorAlert, + validateMetadata, + generateMetadata, + createJsonLD, + createHash, + ...context + // Or from any other context you need + } = useAppContext(); + + return ( + + ); +} +``` + +#### Example of Implementing a Package Using CommonJS Modules (CJS): + +```tsx +import React from 'react'; +import { useAppContext } from '@/context'; + +const VotingPillar = React.lazy( + () => import('@intersect.mbo/govtool-delegation-pillar/cjs') +); + +export const VotingComponent = () => { + const { + apiUrl, + walletApi, + validationApiUrl, + cExplorerBaseUrl, + epochParams, + connectWallet, + openFeedbackWindow, + addSuccessAlert, + addErrorAlert, + validateMetadata, + generateMetadata, + createJsonLD, + createHash, + ...context + // Or from any other context you need + } = useAppContext(); + + return ( + + ); +}; +``` + +## Project Structure + +```govtool-delegation-pillar/frontend +β”œβ”€β”€ dist +β”œβ”€β”€ jest.config.cjs +β”œβ”€β”€ node_modules +β”œβ”€β”€ package.json +β”œβ”€β”€ package-lock.json +β”œβ”€β”€ public +β”œβ”€β”€ README.md +β”œβ”€β”€ rollup.config.mjs +β”œβ”€β”€ setupTests.ts +β”œβ”€β”€ src +β”‚ β”œβ”€β”€ components +β”‚ β”œβ”€β”€ consts +β”‚ β”œβ”€β”€ context +β”‚ β”œβ”€β”€ DelegationPillarRoutes.tsx +β”‚ β”œβ”€β”€ DelegationPillar.tsx +β”‚ β”œβ”€β”€ features +β”‚ β”œβ”€β”€ hooks +β”‚ β”œβ”€β”€ i18n +β”‚ β”œβ”€β”€ index.tsx +β”‚ β”œβ”€β”€ pages +β”‚ β”œβ”€β”€ react-app-env.d.ts +β”‚ β”œβ”€β”€ services +β”‚ β”œβ”€β”€ theme +β”‚ β”œβ”€β”€ types +β”‚ └── utils +└── tsconfig.json +└── yarn.lock +``` + +- **components/**: The `@intersect.mbo/govtool-delegation-pillar` components. +- **consts/**: Constants for the application. +- **context/**: Context for global application state. +- **features/**: Features for the application. +- **hooks/**: Custom hooks. +- **i18n/**: Internationalization configuration. +- **pages/**: Application pages. +- **services/**: Services for fetching data. +- **stories/**: Storybook stories. +- **theme/**: Theme configuration. +- **types/**: Typescript types. +- **utils/**: Utility functions. +- **rollup.config.js**: Configuration for the Rollup bundler. + +## Prerequisites + +Before starting, please ensure you have the following: + +- Node.js and npm - Latest versions. You can download them from [here](https://nodejs.org/en/download/). + +## Running locally + +To run the application locally, you need to have Node.js installed. +Copy `.env.example` to `.env` and fill in the required environment variables. + +Run the Voting Pillar backend server. + +Start the frontend server: + +```bash +npm install +npm start +```