https://github.com/dilukshann7/census-ms
https://github.com/dilukshann7/census-ms
census census-data government population sri-lanka statistics sveltekit
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/dilukshann7/census-ms
- Owner: dilukshann7
- Created: 2026-02-14T17:28:10.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-02-16T18:58:00.000Z (about 1 month ago)
- Last Synced: 2026-02-17T01:33:18.787Z (about 1 month ago)
- Topics: census, census-data, government, population, sri-lanka, statistics, sveltekit
- Language: Svelte
- Homepage: https://census-ms-lk.vercel.app
- Size: 259 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Census Management System (`census-ms`)
A SvelteKit-based census data collection and admin review system.
## What This Project Does
- Collects family census submissions from a public form.
- Stores family + person records in PostgreSQL via Drizzle ORM.
- Provides an admin-only console for reviewing pending submissions, approving/rejecting records, editing records, and deleting approved family records.
- Protects admin routes with Better Auth + an email allowlist.
## Tech Stack
- SvelteKit 2 + Svelte 5
- Vite 7
- Tailwind CSS 4
- Better Auth (email/password)
- Drizzle ORM + Drizzle Kit
- Neon PostgreSQL driver (`@neondatabase/serverless`)
- Zod + SvelteKit Superforms
## Prerequisites
- Node.js (LTS)
- npm
- PostgreSQL database (Neon or any compatible Postgres instance)
## Environment Variables
Create a `.env` file in the project root.
### Required
- `DATABASE_URL`: Postgres connection string used by the app and Drizzle.
- `ADMIN_EMAIL` or `ADMIN_EMAILS`: Admin allowlist (`ADMIN_EMAILS` is a comma-separated list).
### Recommended for Better Auth
- `BETTER_AUTH_SECRET`
- `BETTER_AUTH_URL` (or `BETTER_AUTH_BASE_URL`, depending on your deployment setup)
## Installation
```bash
npm install
```
## Database Setup
Apply your current schema to the configured database:
```bash
npm run db:push
```
Other available database commands:
```bash
npm run db:generate
npm run db:migrate
npm run db:studio
```
## Run Locally
```bash
npm run dev
```
Then open:
- Public census form: `http://localhost:5173/`
- Admin login: `http://localhost:5173/login`
## Bootstrapping an Admin Account
Admin sign-up is restricted to emails in `ADMIN_EMAIL`/`ADMIN_EMAILS`.
Create an admin user by sending a POST request to:
- `POST /api/signup`
Payload:
```json
{
"name": "Admin User",
"email": "admin@example.com",
"password": "your-strong-password"
}
```
After signup, log in via `/login` with username/email + password.
## Main Routes
- `/` - Public census submission form
- `/login` - Admin login
- `/admin/approval` - Pending submissions queue
- `/admin/approval/[id]` - Review/edit a pending submission
- `/admin/details` - Approved submissions list
- `/admin/details/[id]` - View/edit/delete an approved submission
- `/logout` - Admin sign-out endpoint
## Scripts
- `npm run dev` - Start dev server
- `npm run build` - Production build
- `npm run preview` - Preview production build
- `npm run check` - Type + Svelte checks
- `npm run check:watch` - Checks in watch mode
- `npm run db:push` - Push schema to DB
- `npm run db:generate` - Generate SQL migrations
- `npm run db:migrate` - Apply migrations
- `npm run db:studio` - Open Drizzle Studio
## Notes
- Admin pages are protected by server-side session checks in `src/routes/admin/+layout.server.ts`.
- If no admin allowlist is set, admin login/signup is disabled by design.