aryanprince / campus-hub

🚀 Cloud-deployed showcase of Next.js microservices in a monorepo with Turborepo, demonstrating best practices and modern tech.
https://campus-hub-student.vercel.app/
7 stars 0 forks source link
commitlint docker drizzle-orm github-actions husky lucia-auth microservices nextjs playwright pnpm-workspaces shadcn-ui tailwindcss turborepo
# 🎓 Campus Hub

A showcase monorepo of interconnected microservices for student, library, and finance management in a university setting - demonstrating real-world technology and best practices.

Features   ✦   Directory Structure   ✦   Features   ✦   Tech Stack   ✦   Getting Started ![Next JS](https://img.shields.io/badge/Next.JS-black?style=for-the-badge&logo=next.js&logoColor=white) ![Turborepo](https://img.shields.io/badge/Turborepo-black?style=for-the-badge&logo=Turborepo&logoColor=white) ![React](https://img.shields.io/badge/react-black?style=for-the-badge&logo=react&logoColor=%2361DAFB) ![TailwindCSS](https://img.shields.io/badge/tailwind-black?style=for-the-badge&logo=tailwind-css&logoColor=2338B2AC) ![shadcn/ui](https://img.shields.io/badge/shadcn/ui-black?style=for-the-badge&logo=shadcnui&logoColor=white) ![Radix UI](https://img.shields.io/badge/radix-black?style=for-the-badge&logo=radix-ui&logoColor=white) ![Drizzle](https://img.shields.io/badge/Drizzle-black?style=for-the-badge&logo=Drizzle&logoColor=#CFF66C) ![Vercel](https://img.shields.io/badge/Vercel-black?style=for-the-badge&logo=vercel&logoColor=white) ![Railway](https://img.shields.io/badge/Railway-black?style=for-the-badge&logo=Railway&logoColor=white)

📖 Introduction

Campus Hub is a showcase application featuring three Next.js microservices, fully deployed to the cloud for live use. This project includes a Student Portal, a Library Portal, and a Finance Portal, all integrated within a monorepo using Turborepo and communicating via RESTful APIs.

Built to demonstrate my expertise in modern software development, Campus Hub employs a microservices architecture with independent functionality and separate databases, while leveraging a monorepo for shared code and improved DX. It also implements industry best practices, including CI/CD pipelines, design patterns, and robust architecture.

📦 Directory Structure

Campus Hub is a monorepo managed by Turborepo. The monorepo contains an apps, packages, and tooling directory, each serving a specific purpose as shown below:

.
├── .github                   # GitHub Actions CI/CD workflows
│    └── workflows            # CI with pnpm cache + shared GH Actions composite workflow step for all jobs
│        ├── build            # Build monorepo w/ Turborepo's Remote Cache for fast builds
│        ├── e2e-test         # Run E2E tests w/ Playwright & Docker Compose for local DBs
│        ├── vercel (deploy)  # Automatically deploy Next.js apps to Vercel on push
│        ├── commitlint       # Lint commit messages to Gitmoji standard using commitlint
│        ├── lint             # Lints entire monorepo using shared ESLint config
│        ├── format           # Formats entire monorepo using Prettier
│        └── typecheck        # Typechecks entire monorepo using shared TS config
│
├── .husky                    # Git pre-commit hooks for commit messages and linting
├── .vscode                   # Recommended extensions and settings for VSCode
├── postman                   # Postman collection for API testing and documentation
│
├── apps                      # Main applications under the monorepo
│    ├── student              # Next.js app for the Student Portal
│    ├── library              # Next.js app for the Library Portal
│    └── finance              # Next.js app for the Finance Portal
│
├── packages                  # Shared packages used by the apps
│    └── ui                   # Shared UI components (using shadcn/ui)
│
├── tooling                   # Shared configuration setup for the apps and packages
│    ├── config-eslint        # Shared, fine-grained, ESLint preset
│    ├── config-playwright    # Shared Playwright configuration for E2E tests
│    ├── config-prettier      # Shared Prettier configuration
│    ├── config-tailwind      # Shared Tailwind CSS configuration
│    ├── config-typescript    # Shared TS config all apps under the monorepo
│    └── github-actions       # Shared GitHub Actions composite workflow step for all CI jobs
│
├── docker-compose.yml        # Docker Compose file for local development databases
├── .npmrc                    # NPM configuration file for pnpm workspaces
├── .nvmrc                    # Node Version Manager (nvm/fnm) file for setting a specific Node version in the monorepo
├── commitlint.config.ts      # Commitlint configuration for Gitmoji commit messages
├── pnpm-workspace.yaml       # pnpm workspace config using catalogs for unified dependencies across monorepo
├── renovate.json             # Renovate configuration for automated dependency updates
└── turbo.json                # Turborepo configuration file (includes all tasks)

✨ Features

Student Portal (Live Demo)

Library Portal (Live Demo)

Finance Portal (Live Demo)

Best Practices Implemented

🛠️ Tech Stack

Frontend:

Backend:

Tooling:

Deployment:

🚀 Getting Started

Prerequisites

Ensure you have the following installed first:

brew install node # macOS or Linux (using Homebrew)
winget install -e --id OpenJS.NodeJS # Windows
brew install pnpm # macOS or Linux (using Homebrew)
winget install -e --id pnpm.pnpm # Windows
# or using npm
npm install -g pnpm # Install pnpm globally
brew install --cask docker # macOS or Linux (using Homebrew)
winget install -e --id Docker.DockerDesktop # Windows
npm install -g turbo # Either install Turbo globally using npm
pnpm install -g turbo # or using pnpm (recommended)

Installation

  1. Clone the repository:
git clone https://github.com/aryanprince/campus-hub.git
  1. Install the dependencies:
pnpm install
  1. Create the .env file for each app:
cp apps/student/.env.example apps/student/.env
cp apps/library/.env.example apps/library/.env
cp apps/finance/.env.example apps/finance/.env
  1. Configure environment variables for each app. Stick to the defaults for the most part.

  2. Start the local databases using Docker:

docker-compose up -d
  1. Run script to setup the databases with existing migrations and seed data:
pnpm db:setup
  1. Start the development server using Turborepo:
pnpm dev

and open http://localhost:3001 (Student), http://localhost:3002 (Library), and http://localhost:3003 (Finance) with your browser 🚀

  1. (Optional) Run the following command to open Drizzle Studio to view the database content from the browser:
pnpm db:studio

and open https://local.drizzle.studio?port=3011 (Student DB), https://local.drizzle.studio?port=3012 (Library DB), and https://local.drizzle.studio?port=3013 (Finance DB) with your browser 🗃️

📜 Scripts

Database Scripts

Run the following scripts to manage the database schema and data:

db:studio # Opens Drizzle Studio to view stuff in the database. So cool!
db:push # Pushes database schema directly w/o migrations (prefer db:migrate)
db:migrate:generate # Generates the migration files based on the schema changes
db:migrate:run # Migrates the database using the generated migration files (from db:generate)
db:migrate:push # Generates and runs the migration files in one go (db:generate + db:migrate)
db:seed # Seeds the database with initial data
db:setup # Sets up the database by running db:migrate and db:seed

📝 Note

Developed as part of a university project, Campus Hub highlights my ability to create production-ready applications using the latest technologies and standards. The project is a testament to my skills in software development, showcasing my expertise in building scalable, maintainable, and secure applications. I hope you enjoy exploring Campus Hub and appreciate the effort that went into creating it.