Skip to content

Repository files navigation

⚑ Atrium

IEEE Student Branch of Nirma University β€” Internal Portal

Next.js TypeScript Supabase Auth.js Vercel License

Event creation, membership management, and approval workflows for IEEE SBNU.

Live App Β· Documentation Β· Getting Started


πŸ“‹ Overview

Atrium is the internal management portal for IEEE Student Branch of Nirma University (SBNU). It handles:

  • πŸ” Authentication β€” Google OAuth + email/password with @nirmauni.ac.in domain restriction
  • βœ… Registration Gating β€” New members require admin/MDO approval before accessing the portal
  • πŸ“Š Permission-Based Access β€” Granular, position-based permissions determine what each member sees
  • πŸ“… Event Management β€” Create, submit, approve, and publish events through a multi-level approval workflow
  • πŸ‘₯ Membership Management β€” Track positions, branches, role history, and direct permission grants
  • πŸ” Audit Trail β€” Immutable logs of all event and membership changes

πŸ—οΈ Tech Stack

Layer Technology Purpose
Framework Next.js 16 (App Router) Full-stack React framework with Server Actions
Language TypeScript 5 Type-safe development
Auth NextAuth.js v5 (Auth.js) Google OAuth + Credentials with JWT sessions
Database Supabase (PostgreSQL) Managed Postgres with admin client access
Styling Tailwind CSS 4 + shadcn/ui Utility-first CSS + accessible component library
Deployment Vercel Edge-optimized hosting with auto-deploys from GitHub
Icons Lucide React Consistent icon set
Fonts Google Sans Brand typography

πŸ“ Project Structure

Atrium/
β”œβ”€β”€ docs/                          # πŸ“– Documentation
β”‚   β”œβ”€β”€ AUTH.md                    #    Authentication & authorization deep-dive
β”‚   └── SCHEMA.md                 #    Database schema reference (single source of truth)
β”‚
β”œβ”€β”€ implementation_plans/          # πŸ“ Historical implementation plans
β”‚   β”œβ”€β”€ implementation_plan_for_auth
β”‚   β”œβ”€β”€ implementation_plan_for_Oauth-2
β”‚   β”œβ”€β”€ implementation_plan_for_GCP-and-NextAuth_setup
β”‚   β”œβ”€β”€ implementation_plan_for_Dashbord-phase-1
β”‚   └── implementation_plan-brainstorming-superadmin
β”‚
β”œβ”€β”€ supabase/
β”‚   └── migrations/                # πŸ—„οΈ Database migrations (run in Supabase SQL editor)
β”‚       β”œβ”€β”€ 00001_initial_schema.sql
β”‚       β”œβ”€β”€ 00002_permission_system.sql
β”‚       β”œβ”€β”€ 00003_nextauth_migration.sql
β”‚       β”œβ”€β”€ 00004_invisible_superadmin.sql
β”‚       β”œβ”€β”€ 00005_new_positions.sql
β”‚       β”œβ”€β”€ 00006_workspace_and_requests.sql
β”‚       β”œβ”€β”€ 00007_notification_types.sql
β”‚       └── 00008_audit_log.sql
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ (portal)/              # 🏠 Dashboard route group (shared sidebar layout)
β”‚   β”‚   β”‚   └── page.tsx           #    Dashboard home
β”‚   β”‚   β”œβ”€β”€ api/auth/[...nextauth] #    NextAuth API routes (auto-generated)
β”‚   β”‚   β”œβ”€β”€ auth/actions.ts        #    Server actions: signUp, signIn, signOut, etc.
β”‚   β”‚   β”œβ”€β”€ login/                 #    Login page (Google + email/password)
β”‚   β”‚   β”œβ”€β”€ signup/                #    Registration page
β”‚   β”‚   β”œβ”€β”€ complete-registration/ #    IEEE details form (Google OAuth users)
β”‚   β”‚   β”œβ”€β”€ pending/               #    Waiting room for unapproved accounts
β”‚   β”‚   β”œβ”€β”€ rejected/              #    Rejection notice with reason
β”‚   β”‚   β”œβ”€β”€ superadmin/            #    SuperAdmin portal (dashboard, orgs, users, positions, requests, audit, settings)
β”‚   β”‚   β”œβ”€β”€ layout.tsx             #    Root layout
β”‚   β”‚   └── globals.css            #    Theme variables & base styles
β”‚   β”‚
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   └── ui/                    #    shadcn/ui components (Button, Card, Input, etc.)
β”‚   β”‚
β”‚   β”œβ”€β”€ lib/                       #    Shared utilities & query helpers
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”œβ”€β”€ permissions.ts     #    Permission engine (position + direct grants)
β”‚   β”‚   β”‚   β”œβ”€β”€ superadmin.ts      #    SuperAdmin identity check (bcrypt-matched email β†’ session.isSuperAdmin)
β”‚   β”‚   β”‚   β”œβ”€β”€ audit.ts           #    logAdminAction() β€” writes to audit_log
β”‚   β”‚   β”‚   └── impersonation.ts   #    Workspace impersonation (SuperAdmin "view as member")
β”‚   β”‚   └── supabase/
β”‚   β”‚       β”œβ”€β”€ server.ts          #    createAdminClient() (service role)
β”‚   β”‚       └── middleware.ts      #    Auth middleware (route protection)
β”‚   β”‚
β”‚   β”œβ”€β”€ auth.config.ts             #    NextAuth config (Edge-safe, Google provider)
β”‚   β”œβ”€β”€ auth.ts                    #    NextAuth config (Node.js, adds Credentials + bcrypt)
β”‚   └── middleware.ts              #    Next.js middleware entry point
β”‚
β”œβ”€β”€ .env                           #    Environment variables (not committed)
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── next.config.ts

πŸ“– Documentation

πŸ‘‰ Start at docs/README.md β€” the full developer documentation index (what/how/why/gotchas for every feature). Highlights:

Document Description
docs/README.md Documentation index & "start here" map
ARCHITECTURE.md System overview, request lifecycle, Edge/Node split, directory map
ENGINEERING.md Conventions, patterns, gotchas, "add a feature" recipe
DEVELOPMENT.md Setup, complete env-var list, migrations, verification
AUTH.md Authentication & identity: NextAuth, Google/credentials, super-admin, middleware (current invisible-super-admin model)
PERMISSIONS.md Positions + permissions + memberships; how access is computed
SCHEMA.md Database schema reference (v2) β€” every table, enum, index, migration
features/ Per-feature deep dives: notifications, super-admin portal, impersonation, workspace switching, approvals, position requests, members, dashboard, events

πŸš€ Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/IEEE-Student-Branch-NU/Atrium.git
cd Atrium

2. Install Dependencies

npm install

3. Configure Environment Variables

Create a .env file in the project root:

# ── Supabase ──────────────────────────────────────
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# ── NextAuth.js ───────────────────────────────────
AUTH_SECRET=your-random-secret-string
NEXTAUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000

# ── Google OAuth ──────────────────────────────────
AUTH_GOOGLE_ID=your-google-client-id.apps.googleusercontent.com
AUTH_GOOGLE_SECRET=GOCSPX-your-google-client-secret

# ── Password Hashing ─────────────────────────────
BCRYPT_SALT_ROUNDS=12

# ── Email (Resend) β€” optional ─────────────────────
# Powers email delivery for high-signal notifications (welcome, approvals,
# promotions). If unset, the app runs normally and email sends are a no-op.
RESEND_API_KEY=re_your_resend_api_key
EMAIL_FROM=Atrium <no-reply@your-verified-domain>

Google OAuth Setup: In the Google Cloud Console, add http://localhost:3000 to Authorized JavaScript Origins and http://localhost:3000/api/auth/callback/google to Authorized Redirect URIs. See AUTH.md for details.

4. Set Up the Database

Run the migrations in order in your Supabase SQL editor:

  1. supabase/migrations/00001_initial_schema.sql β€” Core tables, branches, positions, events
  2. supabase/migrations/00002_permission_system.sql β€” Permissions, position_permissions, pre-approval
  3. supabase/migrations/00003_nextauth_migration.sql β€” NextAuth-specific columns (password_hash)
  4. supabase/migrations/00004_invisible_superadmin.sql β€” Superadmins table
  5. supabase/migrations/00005_new_positions.sql β€” Seeds Web Master, Treasurer, Technical Associate, Marketing Associate positions
  6. supabase/migrations/00006_workspace_and_requests.sql β€” position_requests, notifications tables
  7. supabase/migrations/00007_notification_types.sql β€” notifications.type column
  8. supabase/migrations/00008_audit_log.sql β€” Unified audit_log table for the SuperAdmin portal (required for /superadmin/audit to show data)
  9. supabase/migrations/00009_broadcast_notifications.sql β€” Broadcast notifications + realtime publication + RLS
  10. supabase/migrations/00010_hardcoded_superadmin_profile.sql β€” Seeds the fixed super-admin profile row
  11. supabase/migrations/00011_notification_routing.sql β€” Notification routing: audience/branch_id/event_key/actor_profile_id, Chair-scoped RLS (required for the notification system)

5. Start Development Server

npm run dev

Open http://localhost:3000 β€” you'll see the login page.


πŸ” Authentication Overview

Atrium supports two authentication methods, both restricted to @nirmauni.ac.in:

flowchart LR
    A["Login Page"] --> B["Google OAuth"]
    A --> C["Email + Password"]
    B --> D["NextAuth JWT"]
    C --> D
    D --> E{"Middleware"}
    E -->|"approved"| F["Dashboard βœ…"]
    E -->|"pending"| G["Waiting Room ⏳"]
    E -->|"no IEEE ID"| H["Complete Registration"]
Loading

New users must be approved by an Admin or MDO before accessing the portal. Pre-approved IEEE Membership IDs skip the queue automatically.

β†’ Full details: docs/AUTH.md


πŸ—„οΈ Database

The database uses PostgreSQL via Supabase with a permission-based access control system.

Key Tables

Table Purpose
profiles User identity, status, IEEE membership
branches IEEE organizational hierarchy (SBNU β†’ CS, WIE, SIGHT, etc.)
positions Branch-scoped titles (Chair, Vice Chair, MDO, etc.)
permissions Atomic actions (create_events, approve_registrations, etc.)
memberships Append-only history: who held what position, when
events Core event entity with status machine
event_approvals Multi-level approval tracking

Branches (Seeded)

Branch Slug Parent
IEEE SBNU sbnu β€” (root)
IEEE SIGHT sight SBNU
IEEE WIE wie SBNU
IEEE CS cs SBNU
IEEE ITSS itss SBNU
IEEE SPS sps SBNU

β†’ Full schema reference: docs/SCHEMA.md


πŸ›‘οΈ Permission System

Permissions are position-based + direct grants. The system follows the principle of least privilege.

Permission Chair Vice Chair Gen Sec Tech Head Creative Head MDO
create_events βœ… βœ… βœ… βœ… βœ…
approve_events βœ… βœ…
manage_events βœ… βœ…
manage_members βœ… βœ…
approve_registrations βœ… βœ… βœ…
view_members βœ… βœ… βœ… βœ… βœ…
view_audit_log βœ… βœ… βœ…

New positions (Treasurer, Web Master, Technical Associate, Marketing Associate) start with no default permissions. An admin can grant them via the Manage Members module.

β†’ Full permission engine details: docs/AUTH.md#6-permission-engine


🚒 Deployment

The app is deployed on Vercel with auto-deploys from the main branch.

Environment URL
Production (Vercel) atrium-ieeenirma.vercel.app
Custom Domain atrium.ieeenirma.org
Local localhost:3000

Vercel Environment Variables

Set all variables from the .env section above in Vercel β†’ Project Settings β†’ Environment Variables. For production, update:

NEXTAUTH_URL=https://atrium-ieeenirma.vercel.app
NEXT_PUBLIC_APP_URL=https://atrium-ieeenirma.vercel.app

Google OAuth Production URIs

In the Google Cloud Console, add these to your OAuth Client:

  • Authorized JavaScript Origins: https://atrium-ieeenirma.vercel.app, https://atrium.ieeenirma.org
  • Authorized Redirect URIs: https://atrium-ieeenirma.vercel.app/api/auth/callback/google, https://atrium.ieeenirma.org/api/auth/callback/google

πŸ“œ Migration History

# Migration Description
1 00001_initial_schema.sql Core tables: profiles, branches, positions, memberships, events, event_types, event_approvals, audit logs. Seeded branches and positions.
2 00002_permission_system.sql Permission engine: permissions, position_permissions, member_permissions, pre_approved_members. Dropped old portal_role enum. Full permission matrix seed.
3 00003_nextauth_migration.sql Added password_hash to profiles. NextAuth compatibility columns.
4 00004_invisible_superadmin.sql Created superadmins table (bcrypt-hashed emails + passphrase hash), RLS enabled with no public policies. Dropped profiles.is_super_admin β€” SuperAdmin status is no longer a queryable column.
5 00005_new_positions.sql Seed script for adding missing standard roles: Web Master, Treasurer, Technical Associate, Marketing Associate, and granting basic permissions.
6 00006_workspace_and_requests.sql Added bio/skills to profiles. Added position_requests table (member-initiated requests to hold a position) and notifications table.
7 00007_notification_types.sql Added notifications.type column (normal, broadcast, success, warning, error).
8 00008_audit_log.sql Added unified audit_log table recording super-admin/structural actions (branch/position/permission changes, workspace impersonation, etc.), with indexes on created_at, actor_profile_id, and (entity_type, entity_id). RLS enabled with no public policies (service-role only).

πŸ§‘β€πŸ’» Development

Scripts

Command Description
npm run dev Start development server (hot reload)
npm run build Production build
npm run start Start production server
npm run lint Run ESLint

Adding shadcn/ui Components

npx shadcn@latest add <component-name>

Code Conventions

  • Server Actions for all mutations (no API routes for forms)
  • Server Components by default; 'use client' only when needed
  • Supabase Admin Client for all DB access (never browser client)
  • bcrypt for password hashing (Node.js runtime only)
  • JWT sessions (no database sessions)

πŸ€– AI Agents & Graphify

This repository is configured to be used with AI coding assistants (like Claude, Cursor, Aider, Copilot, or Antigravity) using Graphify. Graphify maps the codebase into a queryable knowledge graph, giving your AI agents a deep understanding of the project's architecture and inter-dependencies out-of-the-box.

When you clone the repository, open it in your AI coding assistant of choice and run:

/graphify .

(Or run graphify extract . via CLI). The agent will automatically use the generated graph for all codebase-related questions.


πŸ‘₯ Team

IEEE Student Branch of Nirma University


Built with ❀️ by IEEE SBNU

About

A modern, role-based member management and event portal for the IEEE Student Branch of Nirma University, built with Next.js and Supabase.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages