This project is a modern OAuth2 authentication platform, featuring a Next.js web frontend and a NestJS-based API backend. It provides secure, scalable, and user-friendly authentication solutions, leveraging best practices and popular frameworks for both web and server-side development.
- OAuth2 Authorization and Authentication
- Next.js frontend for user interaction
- NestJS backend API for authentication logic
- Secure token management
- Extensible and modular architecture
- Node.js: v18.x or higher
- pnpm: v8.x or higher (for package management)
- Database: PostgreSQL (v13 or higher recommended) or MongoDB (v4.4+)
- You can use either MongoDB or PostgreSQL as your database backend.
- Modify the Prisma configuration and schema to use the appropriate driver for your chosen database.
- The project includes two Docker Compose files (
docker-compose.postgres.ymlanddocker-compose.mongo.yml) to help you start a local database instance easily.
-
Clone the repository
git clone https://github.com/mahyarkarimi/authwise cd authwise -
Install dependencies
pnpm install
-
Generate keypairs for JWT
pnpm run generate-keys
-
Configure environment variables
Copy the example environment files and update them with your configuration:
cp .env.example .env # Edit .env with your database and secret values -
Set up the database
- You can start a local database using Docker Compose:
- For PostgreSQL:
docker-compose -f docker-compose.postgres.yml up -d
- For MongoDB:
docker-compose -f docker-compose.mongo.yml up -d
- For PostgreSQL:
- Ensure you have a running database instance. Update your
.envfile with the correct connection string. - Modify your Prisma schema and configuration to match your chosen database.
Run database migrations (if applicable):
pnpm run migrate
- You can start a local database using Docker Compose:
-
Start the development servers
- All together
pnpm run dev
-
Access the application
- Frontend: http://localhost:3000
- API: http://localhost:3001 (default ports)
MIT
Feel free to open issues or contribute to the project!