Skip to content

HackAtUCI/irvinehacks-site-2024

Repository files navigation

irvinehacks-site-2024

Overview

This monorepo uses turborepo with pnpm as a package manager. It contains the following:

apps/site

A Next.js 13 project that uses the new app router.

This app contains the IrvineHacks site.

The development server runs at http://localhost:3000. If this port is taken, the next available port will be used.

apps/api

A FastAPI project.

This app contains the api for the IrvineHacks site.

The development server runs at http://localhost:8000. If this port is taken, the next available port will be used.

apps/sanity

A Sanity Studio project.

This app contains the dashboard used to view and edit content stored in Sanity.

The development server runs at http://localhost:3333. If this port is taken, the project will error.

First-Time Setup

Pnpm

This repo used pnpm, a space-efficient replacement to npm. You can learn more about its advantages at https://pnpm.io/.

Install pnpm with the following command, or use an alternative installation method.

npm install -g pnpm

When running commands, use pnpm rather than npm.

Next.js

  1. Ensure you are in the project root.

  2. Install dependencies

    pnpm i

Python API

  1. Ensure you are in apps/api with

    cd apps/api
  2. Create a virtual environment. This isolates the libraries you install in this environment from the libraries on your actual machine.

    python3 -m venv .venv
  3. Activate virtual environment

    VS Code may prompt to automatically select the newly created virtual environment. Otherwise, for Mac/Linux, run

    source .venv/bin/activate

    and for Windows, run

    .\.venv\scripts\activate
  4. Install dependencies

    pip install -r requirements.txt -r requirements-dev.txt

Docker

This project uses Docker for testing API methods locally.

  1. Install Docker. The process varies greatly depending on the operating system, so please refer to this article.

  2. Open Docker Desktop.

A local MongoDB application will start running at http://localhost:8081 after running pnpm dev.

Note: Because the Python files have been copied over to the Docker container, hot reload is no longer possible. Stopping the container and rerunning pnpm dev is the best option.

Build

To build all apps and packages, run the following command in the project root.

Note: You would run this BEFORE opening a PR as a sanity check for errors.

pnpm build

To build an individual app or package, first, navigate to the corresponding directory and run the build command.

Develop

To develop all apps and packages, run the following command in the project root.

pnpm dev

Helpful VSCode Extensions

  • Python for Python linting, intellisense, etc.
  • Mypy for Python type checking
  • Black for Python code formatting
  • Prettier for code formatting on file save or set to a keybind
  • ESLint for linting Javascript

What's inside?

This Turborepo includes the following packages/apps:

Apps and Packages

  • site: a Next.js app
  • api: a FastAPI app
  • sanity: a Sanity Studio app
  • eslint-config-custom: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • tsconfig: tsconfig.jsons used throughout the monorepo

Utilities