A full-stack web application with Google OAuth authentication and Stripe payment processing. Built with Node.js/Express backend and React frontend.
- User Authentication: Secure Google OAuth 2.0 login/signup
- JWT Sessions: Stateless authentication with JSON Web Tokens
- Stripe Payments: Save payment methods and process invoices
- User Profiles: Display user information after login
- Security: Implementation of Helmet, CORS, and NoSQL injection sanitization
- Logging: Detailed backend logging with Bunyan
- Framework: Node.js, Express.js
- Database: MongoDB (Mongoose ODM)
- Authentication: Passport.js (Google OAuth), JWT
- Payments: Stripe SDK
- Logging: Bunyan
- Security: Helmet, CORS, express-mongo-sanitize
- Library: React
- Routing: React Router DOM
- HTTP Client: Axios
- Payments: Stripe.js, React Stripe.js
- Build Tool: Create React App
Before you begin, ensure you have:
- Node.js (LTS version)
- MongoDB (local or MongoDB Atlas)
- Google Cloud Project with OAuth 2.0 credentials
- Stripe Account with API keys
-
Clone the Repository
git clone https://github.com/ahmedrzakhan/payschool.git cd payschool
-
Backend Setup
- Navigate to backend directory and install dependencies
- Configure environment variables in
.env
file (see example below) - Start the development server
-
Frontend Setup
- Navigate to client directory and install dependencies
- Configure environment variables in
.env
file (see example below) - Start the development server
NODE_ENV=development
PORT=8200
MONGO_URI=mongodb://localhost:27017/payschool
JWT_SECRET=your_strong_jwt_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=http://localhost:8200/api/v1/auth/google/callback
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
REACT_APP_API_BASE_URL=http://localhost:8200/api/v1
REACT_APP_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
-
Start Backend
cd backend npm run dev
Server runs on
http://localhost:8200
-
Start Frontend
cd client npm start
Opens
http://localhost:3000
in your browser
Base URL: /api/v1
GET /auth/google
- Initiate Google OAuth flowGET /auth/google/callback
- Handle OAuth callbackPOST /auth/logout
- Log out user
GET /user/profile
- Get current user profile
POST /payment/stripe/setup-intent
- Create a Stripe Setup IntentPOST /payment/stripe/create-invoice
- Create a new invoicePUT /payment/stripe/set-default-payment-method
- Update default payment method
payschool/
├── backend/ # Node.js/Express server
│ ├── src/
│ │ ├── server.js # Entry point
│ │ ├── configs/ # Configuration files
│ │ ├── middlewares/ # Express middleware
│ │ ├── models/ # Mongoose models
│ │ └── routes/ # API routes
│ └── package.json
└── client/ # React frontend
├── public/ # Static assets
├── src/
│ ├── components/ # Reusable components
│ ├── pages/ # Page components
│ ├── services/ # API services
│ ├── App.js # Main component
│ └── index.js # Entry point
└── package.json
- User visits the application homepage
- User logs in with Google OAuth
- User is redirected to profile page after successful authentication
- User can add a payment method via Stripe
- User can create and pay invoices