Chatcraze is a chat application developed to learn WebSocket communication and explore hosting options. It uses FastAPI for the backend and Next.js for the frontend. The application is containerized with Docker using a multi-container setup managed by Docker Compose.
- Real-time communication powered by WebSockets.
- FastAPI backend with PostgreSQL as the database.
- Next.js frontend for a seamless chat experience.
- Fully containerized for easy deployment.
- Install Docker and Docker Compose on your system.
- Ensure
docker-compose
is available via the command line. - Clone the repository:
git clone <repository-url> cd chatcraze
docker compose up --build
This will:
- Build the backend and frontend Docker images.
- Start the PostgreSQL database, backend, and frontend services.
- Create necessary networks and volumes.
- Frontend: http://localhost:3000
- Backend: http://localhost:8000
To stop the containers:
docker compose down
You can run the backend and frontend independently without Docker:
Ensure you have PostgreSQL installed locally and create a database with the required credentials:
CREATE DATABASE chatcraze;
CREATE USER chatcraze_user WITH PASSWORD 'yourpassword';
GRANT ALL PRIVILEGES ON DATABASE chatcraze TO chatcraze_user;
Update the environment variables in .env
files under the Root
directory.
Navigate to the backend
folder and install dependencies:
cd backend
pip install -r requirements.txt
Run the server:
uvicorn app.main:app --host 0.0.0.0 --port 8000
Navigate to the frontend
folder and install dependencies:
cd frontend
npm install
Start the development server:
npm run dev
Access the application:
- Frontend: http://localhost:3000
- Backend: http://localhost:8000
Create a .env
file in the root directory with the following variables:
DB_HOST=<Database Host>
DB_PORT=<Database Port>
DB_NAME=chatcraze
DB_USER=chatcraze_user
DB_PASS=yourpassword
RESEND_API=<Your Resend API Key>
AUTH_SECRET=<Authentication Secret Key>
PROD=<true/false>
chatcraze/
├── backend/ # FastAPI backend code
├── frontend/ # Next.js frontend code
├── docker-compose.yml
├── .env
└── README.md
Feel free to fork this repository, open issues, or create pull requests to enhance the application.
This project is licensed under the MIT License. See the LICENSE file for more details.
Enjoy chatting! 🎉