This repository hosts the codebase for the DIMO Developer Console API, powering the platform at https://console.dimo.xyz
. The API facilitates seamless interactions and management of developer tools and resources within the DIMO ecosystem.
These instructions will guide you on setting up the project locally.
Before you begin, ensure you have the following installed on your machine:
- Node.js (v20.x or later)
- npm or Yarn
- Docker
- Docker compose
- A Google Developer Account and GitHub Account for OAuth integration.
- Create a Google OAuth App:
- Go to the Google Developer Console.
- Create a new project (if you don’t already have one).
- Navigate to OAuth consent screen and configure it.
- Under Credentials, create an OAuth 2.0 Client ID.
- Add a Redirect URI: http://localhost:3000/api/auth/callback/google.
- Ensure the app has access to the People API:
- Go to Library and search for "People API".
- Enable the People API for your project.
- Note down your Client ID and Client Secret. These will be used in your environment variables.
- Create a GitHub OAuth App:
- Go to GitHub Developer Settings.
- Under OAuth Apps, click New OAuth App.
- Set the Authorization callback URL to http://localhost:3000/api/auth/callback/github. Under OAuth scopes, ensure the app requests access to email addresses in read-only mode.
- Note down your Client ID and Client Secret. These will be used in your environment variables.
- Clone the repository:
git clone git@github.com:DIMO-Network/dimo-developer-console-api.git
cd dimo-developer-console-api
- Set up environment variables:
- Create a .env.local file in the root directory of the project:
GITHUB_CLIENT_ID=<YOUR_GITHUB_CLIENT_ID>
GITHUB_CLIENT_SECRET=<YOUR_GITHUB_CLIENT_SECRET>
GOOGLE_CLIENT_ID=<YOUR_GOOGLE_CLIENT_ID>
GOOGLE_CLIENT_SECRET=<YOUR_GOOGLE_CLIENT_SECRET>
PGHOST=<YOUR_PG_HOST>
PGUSER=<YOUR_PG_USER>
PGDATABASE=<YOUR_PG_DATABASE>
PGPASSWORD=<YOUR_PG_PASSWORD>
PGPORT=<YOUR_PG_PORT>
ZAPIER_LEAD_WEBHOOK_PATH=<ZAPIER LEAD GENERATION PATH, empty for dev environments>
NEXTAUTH_SECRET=<YOUR_NEXTAUTH_SECRET>
NEXTAUTH_URL=http://localhost:3000/
- Database Setup:
- Start the PostgreSQL instance using Docker:
docker-compose up -d
- This command will start a PostgreSQL instance on your local machine as defined in the docker-compose.yml file.
- Install the dependencies:
npm install
# or
yarn install
Start the development server:
npm run dev
# or
yarn dev
To create an optimized production build:
npm run build
# or
yarn build
To start the production server:
npm run start
# or
yarn start
A brief description of the main folders and files in the project:
./src/app/api
: Contains all the application API routes using the new App Router in Next.js../src/config
: Configuration filesdefault
is mainly used for the development environment and default values instaging
andprod
preview
is mainly used for changing variable values in the staging environment.production
is mainly used for changing variable values in the production environment.
./src/controllers
: Handles the logic for processing requests and returning responses in the application../src/services
: Contains the business logic of the application, interacting with the database, APIs, and other services../src/models
: Sequelize models that define the schema and relationships of the PostgreSQL database../src/scripts
: Scripts used for initializing PostgreSQL with Docker../src/types
: TypeScript type definitions and interfaces used throughout the application../src/utils
: Utility functions and helper methods that are used across different parts of the application.
- Next.js: A React framework for server-side rendering, static site generation, and more.
- PostgreSQL: A powerful, open-source relational database system.
- JavaScript/ES6+: Modern JavaScript syntax and features.
-
Ensure Docker is installed and running on your machine.
-
Set up environment variables:
- Make sure the
PG
related variables in your .env.local file is configured to connect to the PostgreSQL instance that will be created by Docker. Your .env.local file should look something like this:
PGHOST=<YOUR_PG_HOST>
PGUSER=<YOUR_PG_USER>
PGDATABASE=<YOUR_PG_DATABASE>
PGPASSWORD=<YOUR_PG_PASSWORD>
PGPORT=<YOUR_PG_PORT>
- Replace username, password, localhost, 5432, and the database name with your specific PostgreSQL credentials, host, port, and database name as defined in the
docker-compose.yml
file.
- Start the PostgreSQL instance using Docker:
- Run the following command to start the Docker containers defined in your docker-compose.yml file:
docker-compose up -d
- This command will start a PostgreSQL instance on your local machine, accessible via the credentials and settings specified in the
PG
environment variables.
- You can connect to the PostgreSQL instance using a database management tool like pgAdmin or via the command line to verify the setup.
We welcome contributions to this project! If you would like to contribute, please follow these steps:
-
Fork the repository on GitHub by clicking the "Fork" button at the top right of the repository page.
-
Clone your forked repository to your local machine:
git clone https://github.com/your-username/your-forked-repository.git
cd your-forked-repository
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
-
Make your changes in the codebase.
-
Commit your changes with a clear and concise commit message:
git commit -m "Add feature/fix: Describe your changes"
- Push your changes to your forked repository on GitHub:
git push origin feature/your-feature-name
- Open a Pull Request:
- Go to the original repository on GitHub.
- Click on the "Pull Requests" tab.
- Click the "New Pull Request" button.
- Select the branch you made your changes on and submit the Pull Request.
-
Describe your changes in the Pull Request. Provide as much detail as possible about what you’ve done and why.
-
Wait for a review from the maintainers. They may ask for changes or provide feedback.
-
Once your Pull Request is approved, it will be merged into the main branch.
Thank you for contributing to the project!