|
| 1 | +## Contributing to Dev Weekends Web Platform |
| 2 | + |
| 3 | +Thank you for your interest in contributing to the **Dev Weekends** web platform! |
| 4 | +This project powers the public site and internal portals (admin, mentors, ambassadors, mentees) for the Dev Weekends community. |
| 5 | + |
| 6 | +This document explains how the project is structured, how to run it locally, and the conventions to follow when you open a PR. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Project Overview & Structure |
| 11 | + |
| 12 | +This is a **Next.js 15** application using the **App Router**, **TypeScript**, **Tailwind CSS**, and **MongoDB (via Mongoose)**. |
| 13 | + |
| 14 | +High‑level layout: |
| 15 | + |
| 16 | +- **`app/`**: Next.js App Router structure. |
| 17 | + - **`app/page.tsx`**: Landing page. |
| 18 | + - **`app/about`, `app/community`, `app/fellowship`, `app/mentorship`, `app/resources`, `app/sessions`, `app/mindmaster`, etc.**: Public marketing and community pages. |
| 19 | + - **`app/admin/*`**: Admin dashboard (mentors, mentees, tags, tasks, sessions, resources, activity log, etc.). |
| 20 | + - **`app/ambassador/*` & `app/mentor/*`**: Ambassador and mentor portals (login, dashboards, mentees management, etc.). |
| 21 | + - **`app/api/*`**: API routes for authentication, mentors/mentees, sessions, resources, tags, tasks, file uploads, etc. |
| 22 | + - **`app/layout.tsx`**: Root layout, global metadata/SEO, theme provider, navbar/footer, analytics, and social modal. |
| 23 | +- **`components/`**: Reusable UI and domain components. |
| 24 | + - **Top‑level components** such as `navbar`, `footer`, `analytics`, `MentorshipGraph`, `MentorsPage`, `TagAssignment`, `google_calender`, etc. |
| 25 | + - **`components/ui/`**: Primitive UI building blocks (buttons, inputs, dialogs, tabs, badges, etc.), largely based on Radix UI + Tailwind. |
| 26 | +- **`lib/`**: |
| 27 | + - **`db.ts`**: MongoDB connection helper (Mongoose) with connection caching and model preloading. |
| 28 | + - **`auth.ts`, `jwt.ts`**: Authentication and JWT helpers. |
| 29 | + - **`analytics.ts`, `resources-*.ts`, `utils.ts`**: Misc. shared utilities and data. |
| 30 | +- **`models/`**: Mongoose models such as `Admin`, `Mentor`, `Mentee`, `Ambassador`, `CoreTeamMember`, `ActivityLog`, `Session`, `Resource`, `Tag`, `Task`, `MindMaster`, etc. |
| 31 | +- **`public/`**: Static assets (images, icons, manifest, favicons). |
| 32 | +- **`styles & config`**: |
| 33 | + - **`app/globals.css`**: Global styles and Tailwind layers. |
| 34 | + - **`tailwind.config.ts`**, **`postcss.config.mjs`**: Tailwind/PostCSS configuration. |
| 35 | + - **`tsconfig.json`**: TypeScript configuration with `@/*` alias to the project root. |
| 36 | + - **`next.config.*`**: Next.js configuration. |
| 37 | + |
| 38 | +If you’re adding a new page, it should usually go under `app/`. For reusable UI, prefer `components/` (or `components/ui/` for primitives). |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Prerequisites |
| 43 | + |
| 44 | +- **Node.js**: Use a recent LTS version (e.g. Node 20+ recommended). |
| 45 | +- **Package manager**: `npm` (repo includes a `package-lock.json`), but `yarn`, `pnpm`, or `bun` can also work if you prefer. |
| 46 | +- **MongoDB**: Access to a MongoDB instance (local or hosted). |
| 47 | + |
| 48 | +Global tools like `git` and a code editor with TypeScript support (VS Code, etc.) are strongly recommended. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## Environment Setup |
| 53 | + |
| 54 | +1. **Clone the repository** |
| 55 | + |
| 56 | + ```bash |
| 57 | + git clone <your-fork-or-origin-url> |
| 58 | + cd web-platform |
| 59 | + ``` |
| 60 | + |
| 61 | +2. **Install dependencies** |
| 62 | + |
| 63 | + ```bash |
| 64 | + npm install |
| 65 | + ``` |
| 66 | + |
| 67 | +3. **Configure environment variables** |
| 68 | + |
| 69 | + - Create a `.env.local` file at the project root. |
| 70 | + - Use `.env.example` (if present in the repo) as a reference for required variables. |
| 71 | + - At minimum, you will need: |
| 72 | + - `MONGODB_URI` – MongoDB connection string (required by `lib/db.ts`). |
| 73 | + - Any analytics / auth / third‑party keys used in layout or API routes (for example `NEXT_PUBLIC_GA_ID` as referenced in `app/layout.tsx`). |
| 74 | + |
| 75 | +4. **Run database locally or connect to a remote cluster** |
| 76 | + |
| 77 | + - If running MongoDB locally, ensure it is started before you run the app. |
| 78 | + - If using a hosted solution (e.g. MongoDB Atlas), ensure your `MONGODB_URI` is correct and IP‑whitelisted. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Running the Project |
| 83 | + |
| 84 | +From the project root: |
| 85 | + |
| 86 | +- **Development server** |
| 87 | + |
| 88 | + ```bash |
| 89 | + npm run dev |
| 90 | + ``` |
| 91 | + |
| 92 | + Open `http://localhost:3000` in your browser. |
| 93 | + |
| 94 | +- **Production build** |
| 95 | + |
| 96 | + ```bash |
| 97 | + npm run build |
| 98 | + npm start |
| 99 | + ``` |
| 100 | + |
| 101 | +- **Linting** |
| 102 | + |
| 103 | + ```bash |
| 104 | + npm run lint |
| 105 | + ``` |
| 106 | + |
| 107 | +Please make sure your code passes `npm run lint` before pushing or opening a PR. |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## Coding Guidelines |
| 112 | + |
| 113 | +- **Language & framework** |
| 114 | + - Use **TypeScript** for new code (`.ts` / `.tsx`). |
| 115 | + - Follow **Next.js App Router** conventions (server components by default, client components only when needed). |
| 116 | + - Prefer **server actions / API routes** for backend logic instead of calling the database from the client. |
| 117 | + |
| 118 | +- **Project structure** |
| 119 | + - Place **pages and route handlers** under `app/`. |
| 120 | + - Place **shared UI components** under `components/` (or `components/ui/` for primitives). |
| 121 | + - Place **business logic & helpers** under `lib/` (auth, DB helpers, utilities). |
| 122 | + - Define or reuse **Mongoose models** under `models/` and ensure you use the shared `connectDB` helper from `lib/db.ts`. |
| 123 | + |
| 124 | +- **Styling** |
| 125 | + - Use **Tailwind CSS** and existing utility classes. |
| 126 | + - Prefer existing utility and component patterns for consistency. |
| 127 | + |
| 128 | +- **TypeScript & strictness** |
| 129 | + - The project uses **`strict`** TypeScript. |
| 130 | + - Avoid `any` wherever possible; define proper types or interfaces. |
| 131 | + - Keep props and return types explicit for exported functions and components. |
| 132 | + |
| 133 | +- **Imports & paths** |
| 134 | + - Use the `@/*` path alias when importing from within this repo: |
| 135 | + |
| 136 | + ```ts |
| 137 | + import Navbar from "@/components/navbar" |
| 138 | + import connectDB from "@/lib/db" |
| 139 | + ``` |
| 140 | + |
| 141 | +- **API & models** |
| 142 | + - Reuse existing patterns in `app/api/*/route.ts` for: |
| 143 | + - Connecting to the database with `connectDB`. |
| 144 | + - Handling errors and returning `NextResponse`. |
| 145 | + - Using centralized models from `models/`. |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## Git & Branching Workflow |
| 150 | + |
| 151 | +1. **Fork or branch** |
| 152 | + - If you are an external contributor: fork the repository, then create a feature branch from `main`. |
| 153 | + - If you are in the core team: create a branch from `main`. |
| 154 | + |
| 155 | +2. **Create a descriptive branch name** |
| 156 | + |
| 157 | + Examples: |
| 158 | + |
| 159 | + - `feature/add-mentor-dashboard-filtering` |
| 160 | + - `fix/ambassador-login-redirect` |
| 161 | + - `chore/update-tailwind-config` |
| 162 | + |
| 163 | +3. **Make focused commits** |
| 164 | + |
| 165 | + - Keep commits small and focused on a single concern. |
| 166 | + - Use clear, descriptive commit messages (e.g. “Fix mentor session filtering bug” rather than “fix stuff”). |
| 167 | + |
| 168 | +4. **Keep your branch up to date** |
| 169 | + |
| 170 | + - Regularly pull from `main` and rebase or merge as appropriate to avoid large drift. |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## Pull Request Guidelines |
| 175 | + |
| 176 | +Before opening a PR, please ensure: |
| 177 | + |
| 178 | +- **Build & lint pass** |
| 179 | + - `npm run build` |
| 180 | + - `npm run lint` |
| 181 | + |
| 182 | +- **Scope is clear** |
| 183 | + - The PR addresses a single feature, fix, or refactor. |
| 184 | + - Large refactors should be split into smaller PRs where possible. |
| 185 | + |
| 186 | +- **Description** |
| 187 | + - Clearly describe: |
| 188 | + - What you changed. |
| 189 | + - Why you changed it. |
| 190 | + - How to test it (steps, relevant pages, and any required env variables). |
| 191 | + |
| 192 | +- **Screenshots / GIFs (recommended)** |
| 193 | + - For UI changes, include before/after screenshots or GIFs in the PR description. |
| 194 | + |
| 195 | +- **No sensitive data** |
| 196 | + - Make sure no secrets, tokens, or private data are committed. |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +## Adding or Updating API Routes |
| 201 | + |
| 202 | +If you introduce or modify an API route under `app/api/`: |
| 203 | + |
| 204 | +- Use `connectDB` from `lib/db.ts` for any database access. |
| 205 | +- Reuse existing response patterns and status codes from similar routes. |
| 206 | +- Validate input payloads to avoid runtime errors. |
| 207 | +- Ensure authentication/authorization is respected for admin/mentor/ambassador endpoints. |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +## Adding or Updating UI Pages/Components |
| 212 | + |
| 213 | +- Follow existing layout and design patterns (Tailwind + existing components). |
| 214 | +- Prefer composition over duplication: extract shared parts into reusable components under `components/`. |
| 215 | +- Make sure pages are responsive (mobile‑first) and accessible where possible (ARIA attributes, semantic HTML, keyboard navigation, etc.). |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +## Questions & Support |
| 220 | + |
| 221 | +If you’re unsure about where to place code, how to name something, or what pattern to follow: |
| 222 | + |
| 223 | +- Look for similar existing pages/components/routes and mirror their approach. |
| 224 | +- If you’re contributing as part of the Dev Weekends community, reach out to the maintainers or core team in the relevant communication channel. |
| 225 | + |
| 226 | +We appreciate every contribution that helps improve the platform for learners, mentors, and ambassadors. 🚀 |
| 227 | + |
| 228 | + |
0 commit comments