|
| 1 | +# Self-hosting StudyMap |
| 2 | + |
| 3 | +Run StudyMap for your own city. Everything below works from a fork, no coding required beyond |
| 4 | +editing one config file and your place data. |
| 5 | + |
| 6 | +## What you get out of the box |
| 7 | + |
| 8 | +- The interactive map, filters, search, and calendar for whatever `data/places/*.json` you provide. |
| 9 | +- Two optional, signed-in-only features (saved places, personal calendar events) if you set up your |
| 10 | + own Supabase project. Skip that section entirely and the app still works, just without those. |
| 11 | + |
| 12 | +## 1. Get the code |
| 13 | + |
| 14 | +Click "Use this template" at the top of [StudentSuite/StudyMap](https://github.com/StudentSuite/StudyMap) |
| 15 | +to create your own copy, then clone it: |
| 16 | + |
| 17 | +```bash |
| 18 | +git clone https://github.com/<your-account>/<your-fork>.git |
| 19 | +cd <your-fork> |
| 20 | +npm install |
| 21 | +``` |
| 22 | + |
| 23 | +## 2. Set your region and dataset |
| 24 | + |
| 25 | +Everything region- and data-specific lives in one file: `studymap.config.ts` at the repo root. |
| 26 | + |
| 27 | +```bash |
| 28 | +cp studymap.config.example.ts studymap.config.ts |
| 29 | +``` |
| 30 | + |
| 31 | +Edit it: |
| 32 | + |
| 33 | +- `center`: `[lat, lng]` for the initial map view |
| 34 | +- `defaultZoom`: initial zoom level (11-13 works well for a metro area) |
| 35 | +- `bounds`: rough coordinate box around your region, used for data validation and map fitting |
| 36 | +- `cities`: display order for the city filter (any city present in your data but missing here |
| 37 | + still shows, just sorted alphabetically after) |
| 38 | +- `places`: swap the sample imports for your own `data/places/*.json` files |
| 39 | + |
| 40 | +The dataset itself follows the schema in [`data/CONTRIBUTING.md`](data/CONTRIBUTING.md): one JSON |
| 41 | +file per place type, one object per place, with `id`, `name`, `type`, `city`, `lat`, `lng`, |
| 42 | +`gmaps_link`, and `added_by`. `data/places.sample/` has two minimal example entries if you want to |
| 43 | +start from a clean skeleton instead of the Mumbai dataset that ships with the template. |
| 44 | + |
| 45 | +Validate as you go: |
| 46 | + |
| 47 | +```bash |
| 48 | +npm run validate |
| 49 | +``` |
| 50 | + |
| 51 | +## 3. Environment variables |
| 52 | + |
| 53 | +```bash |
| 54 | +cp .env.example .env.local |
| 55 | +``` |
| 56 | + |
| 57 | +- `NEXT_PUBLIC_MAPTILER_KEY` is required for the map basemap. Free tier, no credit card, at |
| 58 | + [cloud.maptiler.com](https://cloud.maptiler.com/account/keys/). |
| 59 | +- The Supabase variables are optional. Leave them blank and the map, filters, and calendar all |
| 60 | + work; you just won't get sign-in or the two private features below. See step 5 to fill them in. |
| 61 | + |
| 62 | +## 4. Run it |
| 63 | + |
| 64 | +```bash |
| 65 | +npm run dev |
| 66 | +``` |
| 67 | + |
| 68 | +Open [http://localhost:3000/map](http://localhost:3000/map) and confirm your places show up in |
| 69 | +the right spot. |
| 70 | + |
| 71 | +## 5. Optional: sign-in, saved places, and personal calendar events |
| 72 | + |
| 73 | +These three features (`src/app/login`, saved custom places, personal calendar events) need a |
| 74 | +Supabase project: |
| 75 | + |
| 76 | +1. Create a free project at [supabase.com](https://supabase.com). |
| 77 | +2. Copy its URL and anon key into `.env.local` (`NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`). |
| 78 | +3. In the Supabase SQL editor, run every file in `supabase/migrations/`, in filename order. Each |
| 79 | + one creates its tables with row-level security already scoped to `auth.uid()`, so users can |
| 80 | + only ever read or write their own rows. |
| 81 | +4. Enable whichever auth providers you want (email, Google, etc.) under Authentication > Providers. |
| 82 | + |
| 83 | +Skip this whole section if you only want the public map and calendar. |
| 84 | + |
| 85 | +## 6. Deploy |
| 86 | + |
| 87 | +Deploy like any standard Next.js app, for example on Vercel: |
| 88 | + |
| 89 | +```bash |
| 90 | +npx vercel |
| 91 | +``` |
| 92 | + |
| 93 | +or import the repo at [vercel.com/new](https://vercel.com/new) and set the same environment |
| 94 | +variables from step 3 in the project settings. |
| 95 | + |
| 96 | +**Static export (`output: "export"`) is not supported.** Sign-in needs a live server: the OAuth |
| 97 | +callback route exchanges a code for a session server-side, and middleware refreshes that session |
| 98 | +on every request. Both are incompatible with a static build. Deploy to a normal server/edge |
| 99 | +runtime instead, that's the default for Vercel and most other Next.js hosts. |
| 100 | + |
| 101 | +## Keeping your fork current |
| 102 | + |
| 103 | +StudyMap doesn't push updates to forks automatically. To pull in upstream fixes, add the original |
| 104 | +repo as a remote and merge from it: |
| 105 | + |
| 106 | +```bash |
| 107 | +git remote add upstream https://github.com/StudentSuite/StudyMap.git |
| 108 | +git fetch upstream |
| 109 | +git merge upstream/main |
| 110 | +``` |
| 111 | + |
| 112 | +Your `studymap.config.ts`, `.env.local`, and `data/places/*.json` are yours, upstream changes to |
| 113 | +shared code (map, calendar, components) merge in without touching them, unless you've also edited |
| 114 | +those files. |
0 commit comments