Skip to content
arjunxplorerPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

CoopBase

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.

Features

  • 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

Tech Stack

Frontend

  • React 19
  • Vite
  • React Router
  • Axios
  • Tailwind CSS

Backend

  • Node.js
  • Express 5
  • PostgreSQL
  • bcryptjs
  • JWT
  • cookie-parser
  • cors

Project Structure

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)

Authentication Flow

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

Prerequisites

Before running the project, make sure you have installed:

  • Node.js 18+
  • npm
  • PostgreSQL 14+
  • A local PostgreSQL database server

Local Setup

1. Clone the repository

git clone https://github.com/arjunxplorer/CoopBase.git
cd CoopBase

2. Install frontend dependencies

npm install

3. Install backend dependencies

cd backend
npm install
cd ..

4. Create your environment variables

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=7d

5. Set up PostgreSQL

Create a PostgreSQL database and initialize the schema:

createdb coopbase
psql -d coopbase -f backend/db/init.sql

The initialization script creates the users table and related indexes.

Run the Project

Frontend

npm run dev

The frontend runs by default on:

Backend

cd backend
node index.js

The backend runs by default on:

Default Test User

On first backend startup, the app checks for a sample user and creates one automatically if it does not exist.

This makes local testing easier during development.

Available Scripts

Root project

npm run dev
npm run build
npm run lint
npm run preview

Backend

cd backend
node index.js

Notes on the Current State

This 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

Contributing

Contributions are welcome. Feel free to fork the repository and open a pull request with improvements, bug fixes, or new features.

License

This project does not currently include a license file. If you plan to distribute or publish it, consider adding an appropriate open-source license.

Summary

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages