Welcome to the red404 project! This is a collaborative effort by the members of our Discord programming community to build a toy social network. Our goal is to create a fun, functional application while learning and growing together in a supportive environment.
This project is designed to be beginner-friendly, focusing on practical application of modern web development technologies.
- User Management: Register, Login, User Profiles.
- Post Creation: Create and view text-based posts.
- Comments: Add comments to posts.
- Follow System: (Planned) Follow other users.
- Real-time Updates: (Future consideration) Using WebSockets for live notifications/feeds.
- User Interface: Clean, responsive UI with Tailwind CSS.
We're using a modern and robust stack to build our application:
| Category | Technology | Why we chose it |
|---|---|---|
| Backend | Go (net/http, chi) | Simple, performant, strong concurrency. chi for clean routing. |
| Ent ORM | Type-safe, code-generated ORM. Reduces boilerplate, simplifies DB interaction. | |
| PostgreSQL | Robust, reliable, widely used relational database. | |
| Frontend | React | Popular, component-based UI library. |
| Vite | Extremely fast dev server, quick builds, excellent developer experience. | |
| TypeScript | Adds type safety to JavaScript, reducing bugs and improving code clarity. | |
| Tailwind CSS | Utility-first CSS framework for rapid and consistent styling. | |
| Zustand | Lightweight, simple, and performant state management for React. | |
| Tools | Docker Compose | Simplifies environment setup, ensures consistency across dev machines. |
air (Go) |
Hot-reloading for Go backend for fast feedback loop during development. |
my-social-app/
βββ backend/ # Go API server
β βββ cmd/ # Main application entry point
β βββ internal/ # Core application logic (handlers, services, models, config, etc.)
β βββ ent/ # Ent ORM schemas and generated code
β βββ Dockerfile # Docker build instructions for the Go backend
βββ frontend/ # React application
β βββ public/ # Static assets
β βββ src/ # React components, pages, hooks, services, styles
β βββ vite.config.ts# Vite configuration (with API proxy)
βββ docker-compose.yml# Orchestrates Docker services (DB, Backend)
βββ Makefile # Helper commands for common tasks (start, build, test, lint)
βββ .env.example # Example environment variables
βββ .gitignore # Files/directories to ignore in Git
βββ README.md # This file!
Follow these steps to get the project up and running on your local machine.
Make sure you have the following installed:
- Git: For version control.
- Docker Desktop: (Recommended) For running the database and backend services easily.
- Go: Latest stable version (1.21+ recommended).
- Node.js & npm/yarn/pnpm: Latest LTS version.
-
Clone the Repository:
git clone https://github.com/your-org/my-social-app.git cd my-social-app -
Configure Environment Variables:
cp .env.example .env
Open the newly created
.envfile and review the variables. The defaults should work for local development. -
Initialize Go Modules & Ent ORM:
- First, enter the backend directory:
cd backend - Download Go modules:
go mod tidy
- Generate Ent ORM code (this assumes you have Ent schemas defined in
backend/ent/schema):go generate ./ent
- Go back to the root directory:
cd ..
- First, enter the backend directory:
-
Start Services with Docker Compose: We use
Makefilecommands to simplify this. Themake devcommand will start Docker services (PostgreSQL database and Go backend), and then launch the frontend and backend hot-reloaders.make dev
- This command will:
- Build and start the
db(PostgreSQL) andbackendservices using Docker Compose. - Start the React frontend development server (typically on
http://localhost:5173). - Start the Go backend hot-reloader (
air), which will restart your Go app whenever you save changes.
- Build and start the
- This command will:
-
Access the Application:
- Frontend: Open your web browser and navigate to
http://localhost:5173(or the port Vite indicates in the terminal). - Backend API: The Go backend will be running on
http://localhost:8080. The frontend will proxy requests to/apito this backend.
You are now ready to start coding!
- Frontend: Open your web browser and navigate to
The Makefile in the root directory contains convenient commands for development:
make dev: Starts all services and dev servers with hot-reload (recommended for daily dev).make up: Starts Docker services (DB, Backend) in detached mode (-d).make down: Stops and removes Docker services.make build-backend: Builds the production Docker image for the backend.make build-frontend: Builds the production JavaScript assets for the frontend.make test: Runs all tests (Go backend, and eventually React frontend).make lint: Runs linters and formatters for both backend and frontend.make clean: Removes temporary files and Docker volumes.make help: Displays a list of all available commands.
We welcome contributions from everyone! This project is a fantastic opportunity to learn and apply new skills.
This project is licensed under the MIT License - see the LICENSE file for details.
Join our Discord server to chat with other contributors, ask questions, and share your progress!
[Your Discord Server Invite Link Here] (e.g., https://discord.gg/S4wdMTPm)
Happy coding!