A robust, modular authentication and user management backend built with Node.js, Express, and Firebase. Designed for easy integration with any web or mobile client, supporting both user and admin roles with secure, scalable practices.
- Firebase Authentication integration (Admin SDK for backend, Client SDK for frontend)
- User and admin role management
- Modular controller/service architecture
- JWT-based route protection (via Firebase ID tokens)
- Password reset and email OTP verification
- Firestore seeding utility
- Centralized logging and error handling
- Interactive API documentation with Swagger UI
app.js # Main entry point
routes/ # Route files (auth, plan, etc.)
controllers/ # Controllers for each resource
services/ # Business logic and Firebase interaction
middleware/ # Auth and error handling middleware
firebase/ # Firebase config, admin, seeder, Firestore service
utils/ # Logger, validator, email sender, etc.
logs/ # Log files
config.js # App configuration
package.json # Dependencies and scripts
- Clone the repository:
git clone https://github.com/yourusername/gernal-authentication-service.git cd gernal-authentication-service - Install dependencies:
npm install
- Configure Firebase:
- Place your Firebase Admin SDK JSON in
firebase/home-service-app-firebase.json(rename as needed). - Update
firebase/firebaseAdmin.jsandfirebase/firebase.jsif your config file name or structure differs.
- Place your Firebase Admin SDK JSON in
- Environment Variables:
- Copy
.env.exampleto.envand fill in required values (Firebase project info, session secret, etc.).
- Copy
- Run the app:
npm run dev
- Seed Firestore (optional):
- The app seeds initial data on startup using
firebase/Seeder.js.
- The app seeds initial data on startup using
- Admin SDK: Used on the backend for privileged actions (user management, token verification, etc.). Never expose admin credentials to the client.
- Client SDK: Used on the frontend for user login/signup. The backend expects a valid Firebase ID token in the
Authorizationheader for protected routes. - Security: All admin endpoints are protected by role checks and token verification middleware.
- Interactive docs available at: http://localhost:3000/api-docs
- All endpoints are documented with request/response schemas and can be tested directly from the browser.
Firebase authentication, Node.js auth service, Express user management, admin role, JWT, Firestore, REST API, Swagger docs, secure authentication backend, modular Node.js API
Pull requests and issues are welcome! Please follow the project structure and documentation conventions described in PROJECT_PROMPT.md.
MIT