CoopBase is a authentication platform built with React on the frontend and an Express + PostgreSQL backend. It includes a secure login/signup flow, protected routes, and a simple home dashboard for authenticated users.
The project is designed as a lightweight starter for a campus or community collaboration app where users can create accounts, sign in, and access protected application pages.
- Secure user authentication with JWT-based access tokens and refresh-token cookies
- User signup and login experience with client-side validation
- Protected routes to restrict access to authenticated users only
- PostgreSQL-backed user storage
- React app powered by Vite for a fast development workflow
- Clean frontend structure with context-based auth state
Frontend
- React 19
- Vite
- React Router
- Axios
- Tailwind CSS
Backend
- Node.js
- Express 5
- PostgreSQL
- bcryptjs
- JWT
- cookie-parser
- cors
CoopBase/
├── backend/
│ ├── db/
│ │ ├── index.js
│ │ └── init.sql
│ ├── index.js
│ ├── package.json
│ ├── package-lock.json
│ └── users.js
├── public/
├── src/
│ ├── api/
│ │ └── axios.js
│ ├── components/
│ │ ├── auth/
│ │ │ ├── LoginSignupForm.jsx
│ │ │ └── ProtectedRoute.jsx
│ │ └── HomePage.jsx
│ ├── contexts/
│ │ └── AuthContext.jsx
│ ├── App.jsx
│ ├── index.css
│ ├── main.jsx
│ └── App.css
├── .gitignore
├── eslint.config.js
├── index.html
├── package.json
├── package-lock.json
├── vite.config.js
├── README.md
└── .env (local, not committed)
The app uses cookie-based JWT authentication:
- Users sign up or log in through the React frontend
- The backend validates credentials against PostgreSQL
- The server issues an access token and refresh token
- Tokens are stored in HTTP-only cookies for security
- Auth state is managed in
src/contexts/AuthContext.jsx - Protected routes redirect unauthenticated users to the login screen
Before running the project, make sure you have installed:
- Node.js 18+
- npm
- PostgreSQL 14+
- A local PostgreSQL database server
git clone https://github.com/arjunxplorer/CoopBase.git
cd CoopBasenpm installcd backend
npm install
cd ..Create a .env file in the project root or in the backend folder depending on your preferred setup. The backend code reads environment variables directly from process.env.
Example:
DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=coopbase
JWT_SECRET=super_secret_key
REFRESH_TOKEN_EXPIRY=7dCreate a PostgreSQL database and initialize the schema:
createdb coopbase
psql -d coopbase -f backend/db/init.sqlThe initialization script creates the users table and related indexes.
npm run devThe frontend runs by default on:
cd backend
node index.jsThe backend runs by default on:
On first backend startup, the app checks for a sample user and creates one automatically if it does not exist.
- Email:
[email protected] - Password:
password123
This makes local testing easier during development.
npm run dev
npm run build
npm run lint
npm run previewcd backend
node index.jsThis repository is a functional starter project focused on authentication and protected access. It currently includes:
- A login/signup interface
- A protected dashboard route
- JWT cookie-based auth
- PostgreSQL user persistence
The app is a good foundation for expanding into a full collaboration platform with features like:
- project boards
- team member management
- messaging
- announcements
- file uploads
- role-based permissions
Contributions are welcome. Feel free to fork the repository and open a pull request with improvements, bug fixes, or new features.
This project does not currently include a license file. If you plan to distribute or publish it, consider adding an appropriate open-source license.
CoopBase is a practical full-stack starter for a collaborative student platform, combining a React frontend with a secure Express backend and a Postgres datastore. It is intentionally lightweight but extensible, making it a strong base for building a richer student engagement app.