A high-performance, real-time chat application built with Go and the Fiber v3 framework. This application features secure user authentication, private messaging, a real-time friend list, and persistent message history.
- Real-Time Messaging: Bi-directional communication using WebSockets (Fiber v3 extension).
- Private Conversations: Instant 1-on-1 chats between friends.
- Friend List: Dynamic sidebar to find and start chats with other users.
- Message History: Persistent storage of all conversations using PostgreSQL.
- Secure by Design:
- CSRF Protection (Token-based).
- Session Management with Redis.
- Secure Password Hashing (Bcrypt).
- Auth Middleware for route protection.
- Modern UI: Clean, responsive dashboard designed with Bootstrap 5 and Bootstrap Icons.
- Responsive Layout: Mobile-first design that adapts seamlessly to all screen sizes.
- Backend: Go (Golang)
- Framework: Fiber v3
- WebSocket: Fiber v3 WebSocket Extension
- Database: PostgreSQL (via
pgxpool) - Session Cache: Redis
- Dependency Injection: Parsley
- Frontend: HTML5, Vanilla JavaScript, CSS3, Bootstrap 5
- Go 1.21+ installed.
- PostgreSQL instance running.
- Redis instance running.
-
Clone the repository:
git clone https://github.com/putra4648/my-chat-app.git cd my-chat-app -
Environment Variables: Create a
.envfile in the root directory and configure your connection strings:DATABASE_URL=postgres://user:password@localhost:5432/chat_db REDIS_URL=localhost:6379 PORT=3000
-
Install Dependencies:
go mod download
-
Initialize Database: Run the migration SQL located in
migrations/001_create_table.sql. -
Run the Application:
go run cmd/main.go
-
Access the App: Open
http://localhost:3000in your browser.
The project follows a clean, modular structure:
- /cmd: Application entry point.
- /internal/app: Main application setup and dependency orchestration.
- /internal/configs: Modular middleware configurations (CORS, CSRF, Session, etc.).
- /internal/handlers: Route handlers organized by domain (Auth, Dashboard, WS).
- /internal/repositories: Data access layer using PostgreSQL.
- /internal/services: Business logic layer.
- /internal/middleware: Custom security and system middlewares.
- /views: HTML templates and frontend assets.
Built with ❤️ by Antigravity