This is a full-stack user management application built with React, Redux, TypeScript, and Tailwind CSS for the frontend, and Go with PostgreSQL for the backend.
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install -
Start the development server:
npm start
The application will be available at http://localhost:3000.
- User registration with name, email, and password
- User login with email and password
- JWT-based authentication
- Protected routes for authenticated users
- Responsive design using Tailwind CSS
- State management with Redux Toolkit
- Type-safe development with TypeScript
Register: Allows new users to create an accountLogin: Allows existing users to log inUserList: Displays a list of users (accessible to authenticated users)UserForm: Allows editing user informationNavbar: Navigation component with dynamic links based on authentication status
- Uses Redux Toolkit for state management
authSlice: Manages authentication state, including user info and tokenuserSlice: Manages user data for the user list and user editing functionality
-
Navigate to the backend directory:
cd backend -
Install dependencies:
go mod tidy -
Set up your PostgreSQL database and update the
.envfile with your database credentials. -
Run the application:
go run cmd/main.go
The server will start on http://localhost:8080.
- RESTful API endpoints for user management
- JWT-based authentication
- PostgreSQL database for data persistence
- GORM as the ORM for database operations
- Gin web framework for routing and middleware
POST /api/register: Register a new userPOST /api/login: Authenticate a user and return a JWTGET /api/users: Retrieve a list of users (protected route)GET /api/users/:id: Retrieve a specific user (protected route)PUT /api/users/:id: Update a user's information (protected route)DELETE /api/users/:id: Delete a user (protected route)
The users table includes the following fields:
id: Unique identifier (auto-incremented)name: User's full nameemail: User's email address (unique)password: Hashed passwordcreated_at: Timestamp of user creationupdated_at: Timestamp of last update
- React
- Redux Toolkit
- TypeScript
- Tailwind CSS
- Axios for API requests
- React Router for navigation
- Go
- Gin web framework
- GORM (Go Object Relational Mapper)
- PostgreSQL
- JWT for authentication
- Clone the repository
- Set up the backend:
- Install Go and PostgreSQL
- Set up your database and update the
.envfile - Run the Go application
- Set up the frontend:
- Install Node.js and npm
- Install frontend dependencies
- Start the React development server
- Access the application at
http://localhost:3000
To manage your PostgreSQL database directly, you can use the following commands in the psql interactive terminal.
Connect to your PostgreSQL database using:
psql -U alan_jones -d user_management
You'll be prompted for the password you set for the alan_jones user.
Once connected, you can use these SQL commands to manage and view your data:
-- View all users
SELECT * FROM users;
-- View specific columns
SELECT id, name, email, created_at FROM users;
-- Search for a specific user by email
SELECT * FROM users WHERE email = 'user@example.com';
-- Count the number of users
SELECT COUNT(*) FROM users;
-- View the most recently registered users (limit to 5)
SELECT * FROM users ORDER BY created_at DESC LIMIT 5;
-- View users registered in the last 24 hours
SELECT * FROM users WHERE created_at > NOW() - INTERVAL '1 day';
-- Update a user's name
UPDATE users SET name = 'New Name' WHERE id = 1;
-- Delete a user (be careful with this!)
DELETE FROM users WHERE id = 1;
-- View the table structure
\d usersTo exit the psql prompt, type:
\q
If you need to perform database maintenance or ensure all connections are closed:
On Unix-like systems (Linux, macOS):
sudo service postgresql restart
or
sudo systemctl restart postgresql
On Windows (in an administrator command prompt):
net stop postgresql && net start postgresql
Remember to replace user@example.com, 'New Name', and the ID numbers with actual values when using these commands. Always exercise caution when running UPDATE or DELETE commands, especially in a production environment.
- Implement password reset functionality
- Add user roles and permissions
- Implement email verification
- Add unit and integration tests
- Set up CI/CD pipeline

