A simple Identity Management system with user authentication and authorization capabilities. This system provides basic user management, authentication, and role-based access control.
# Start the application server
docker-compose up --build The application will be available at:
- Backend API: http://localhost:4000
- Frontend: http://localhost:3000
Clean up - Remove all volumes created by your Compose project:
docker-compose down -vFollow the detailed setup instructions below for more control over your development environment.
- Go 1.21 or later
- PostgreSQL 14 or later
- Node.js and npm
- Make
cd cmd/loginv2Copy the example environment file and configure it:
cp .env.example .envEdit the .env file with your configuration. Key variables to update:
IDM_PG_PASSWORD: Your PostgreSQL passwordJWT_SECRET: A strong, random secret for JWT tokensEMAIL_*: Email server configuration for notificationsBASE_URL: Your application's base URL (default: http://localhost:4000)
go run main.goThe console output will look like this:
🔐 ADMIN USER CREATED SUCCESSFULLY
Username: super
Email: super@example.com
Password: SOME_PASSWORD
User ID: 929ec4bb-4183-45c9-993b-db59f3913e79
Login ID: 8be02f9c-58e2-4430-a232-063f6265ddce
Admin Role: 20a09c0a-e776-4e99-9541-4fb755252ac0
⚠️ IMPORTANT SECURITY NOTICE:
• Store this password securely
• Change the password after first login
• This password will not be displayed again
The backend API will be available at http://localhost:4000
cd frontendIf you don't have npm installed, install Node.js first, then:
npm installnpm run devThe frontend will be available at http://localhost:3000
CREATE ROLE idm WITH PASSWORD 'pwd';
CREATE DATABASE idm_db ENCODING 'UTF8' OWNER idm;
GRANT ALL PRIVILEGES ON DATABASE idm_db TO idm;
ALTER ROLE idm WITH LOGIN;make migrate-up
make dump-idmALTER TABLE users OWNER TO idm;psql -h localhost -U idm -d idm_dbPassword: pwd
Start the local mail server for development:
docker/start-mailpit.shThis will start a Mailpit container that:
- Provides a local SMTP server on port 1025
- Offers a web interface at http://localhost:8025 to view sent emails
- Allows you to test email functionality without sending real emails
Visit http://localhost:8025 to view all emails sent by the application during development.
Configure your production mail server settings in the .env file. You can use any SMTP server.
Example: Mailgun Configuration
Add these settings to your .env file:
EMAIL_HOST=smtp.mailgun.org
EMAIL_PORT=587 # Using port 587 for STARTTLS
EMAIL_TLS=true # Set to true as Mailgun requires TLS for authentication
EMAIL_USERNAME=YOUR_USERNAME
EMAIL_PASSWORD=YOUR_PASSWORD
EMAIL_FROM=YOUR_USERNAME # Using the same email as the usernameOther Mail Providers
You can use any SMTP server by updating the EMAIL_* variables in your .env file according to your provider's settings.
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest-
Backend server:
cd cmd/loginv2- Setup
.envfile following.env.example - Start backend server:
go run main.go
-
Frontend:
cd frontend- Install npm if needed
npm run dev
-
Database setup: Follow the database setup section above
-
Mail server setup:
- For development:
docker/start-mailpit.shand visit localhost:8025 - For production: Configure mail server settings in .env file
- For development:
-
Install sqlc:
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
- Frontend Application: http://localhost:3000
- Backend API: http://localhost:4000
- Database: localhost:5432 (database: idm_db, user: idm)