Skip to content

shiverin/GoTalk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GoTalk – Community Forum Platform

A modern, full-stack community forum platform inspired by Reddit, built with React 18 and Go 1.25.5. GoTalk enables users to create and manage communities, share posts, engage in discussions through comments, vote on content, and discover trending posts and communities.

Note: Portions of the backend implementation were developed with the assistance of AI tools to help with JWT handling and API endpoint design. All code has been reviewed to ensure correctness.

πŸ“‹ Table of Contents


🎯 Overview

GoTalk is a full-stack community forum application that combines a React-based frontend with a Go backend API. The platform allows users to:

  • Create and manage communities
  • Post content (text, links, or discussion threads)
  • Comment on posts and engage in threaded discussions
  • Vote on posts and comments
  • Discover popular communities and trending posts
  • Manage user profiles and community memberships

The application follows modern architectural patterns with:

  • Frontend: Component-based React architecture with context-based state management
  • Backend: RESTful API built with Chi router, JWT authentication, and SQLite database
  • Styling: TailwindCSS for responsive, utility-first design

✨ Implemented Features

πŸ” Authentication & User Management

  • βœ… User Registration: Create accounts with username and password
  • βœ… Secure Login/Logout: JWT-based token management
  • βœ… Session Persistence: HttpOnly cookie storage for secure token handling
  • βœ… Password Security: Bcrypt hashing with cost factor 12 (industry standard)
  • βœ… Token Refresh: Automatic token refresh on /auth/refresh endpoint
  • βœ… Current User Info: /auth/me endpoint to fetch logged-in user details
  • βœ… User Profiles: View user information (ID, username, email, creation date)

🏘️ Communities

  • βœ… Create Communities: Authenticated users can establish new communities with name, description, icon URL, and rules
  • βœ… Browse All Communities: Public endpoint to list all communities
  • βœ… Top Communities: Ranked communities by member count with configurable limit (/communities/top/{limit})
  • βœ… Community Details: Retrieve full community info including member count and post count
  • βœ… Join Community: Authenticated users join communities (tracked in community_members table)
  • βœ… Leave Community: Users can leave communities they've joined
  • βœ… Member Tracking: Real-time member count per community
  • βœ… Community Roles: Members table supports role assignment (default: 'member', extensible to 'moderator', 'admin')
  • βœ… Duplicate Prevention: Unique constraint prevents duplicate memberships (user_id, community_id)

πŸ“ Posts & Content Management

  • βœ… Create Posts: Submit text content, external links, or discussion threads to communities
  • βœ… Edit Posts: Authors can modify post title, content, and links (tracked via updated_at)
  • βœ… Delete Posts: Authorized deletion with validation (owner/admin only)
  • βœ… Rich Post Metadata: Each post tracks title, content, link, author, community, creation time, update time, and score
  • βœ… Post Scoring: Vote-based scoring (sum of all user votes on post)
  • βœ… Posts by Community: Dedicated endpoint to fetch all posts in a specific community (/communities/{id}/posts)
  • βœ… Post Retrieval: Get all posts or individual post details with full metadata
  • βœ… Author Information: Posts linked to user ID for attribution

πŸ’¬ Comments & Discussion System

  • βœ… Create Comments: Reply to posts with threaded comments
  • βœ… Edit Comments: Modify comment content after creation
  • βœ… Delete Comments: Remove unwanted comments with authorization
  • βœ… Comment Metadata: Timestamp tracking (created_at, updated_at) for chronological sorting
  • βœ… Comment-to-Post Association: Each comment linked to parent post for threaded discussions
  • βœ… Get Post Comments: Retrieve all comments for a specific post
  • βœ… Comment Count: Track total comments per post

⭐ Voting & Scoring System

  • βœ… Upvote/Downvote Posts: Vote on posts with Β±1 value system
  • βœ… Vote State Management: Track existing votes per user to prevent duplicate voting
  • βœ… Vote Updates: Change vote from +1 to -1 or vice versa (stored as composite key user_id + post_id)
  • βœ… Vote Removal: Clear votes by setting value to 0 (unvote)
  • βœ… Aggregate Scoring: Post score calculated as sum of all votes (dynamic computation)
  • βœ… Database Efficiency: Primary key (user_id, post_id) ensures one vote per user per post

πŸ” Discovery & Browsing

  • βœ… Popular Posts Feed: Dedicated page displaying trending posts (sorted by score/recency)
  • βœ… Top Communities: Browse communities ranked by member count with pagination support
  • βœ… Community Listing Page: Browse all communities with join buttons
  • βœ… Post Filtering Controls: Filter and sort posts by various criteria (planned: date, score, comments)
  • βœ… Landing Page: Home feed with community carousel and post feed
  • βœ… Search Bar: Component ready for search functionality integration

🎨 User Interface Features

  • βœ… Responsive Sidebar: Collapsible navigation (toggles between 18.5% and 10.3% width)
  • βœ… Header Navigation: Top navigation bar with search and user menu
  • βœ… Modal Auth System: Login/Signup presented in modal overlay (non-intrusive)
  • βœ… Card-Based Layout: Posts displayed in reusable card components
  • βœ… Community Carousel: Featured communities displayed in horizontal scroll
  • βœ… Vote UI: Upvote/downvote buttons with visual state feedback
  • βœ… Comment Thread UI: Nested comment display with reply capability
  • βœ… Dropdown Menus: Context menus for post/comment actions (edit, delete)
  • βœ… Loading States: Component loading indicators during async operations

πŸ›  Technology Stack

Backend

Technology Version Purpose
Go 1.25.5 Core backend language
Chi Router v5.2.3 HTTP router and middleware
JWT (golang-jwt) v5.3.0 Token-based authentication
Bcrypt (crypto) v0.46.0 Password hashing
SQLite3 v1.14.32 Database
CORS Handler v1.2.2 Cross-Origin Resource Sharing

Frontend

Technology Version Purpose
React 18.3.1 UI framework
React Router 7.10.1 Client-side routing
Vite 5.4.21 Build tool & dev server
TailwindCSS 3.4.19 Utility-first CSS framework
Lucide React 0.561.0 Icon library
React Icons 5.5.0 Additional icon sets
ESLint 9.39.1 Code linting
PostCSS 8.5.6 CSS preprocessing

πŸ“ Project Structure

GoTalk/
β”œβ”€β”€ backend/                          # Go backend application
β”‚   β”œβ”€β”€ cmd/
β”‚   β”‚   └── api/
β”‚   β”‚       β”œβ”€β”€ main.go              # Application entry point
β”‚   β”‚       └── forum.db             # SQLite database file
β”‚   β”œβ”€β”€ internal/
β”‚   β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”‚   β”œβ”€β”€ database.go          # Database connection & initialization
β”‚   β”‚   β”‚   └── migrate.go           # Schema creation & migrations
β”‚   β”‚   β”œβ”€β”€ handlers/                # HTTP request handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.go              # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ posts.go             # Post CRUD operations
β”‚   β”‚   β”‚   β”œβ”€β”€ comments.go          # Comment management
β”‚   β”‚   β”‚   β”œβ”€β”€ communities.go       # Community operations
β”‚   β”‚   β”‚   β”œβ”€β”€ members.go           # Community membership
β”‚   β”‚   β”‚   β”œβ”€β”€ vote.go              # Voting system
β”‚   β”‚   β”‚   β”œβ”€β”€ users.go             # User endpoints
β”‚   β”‚   β”‚   └── makecommunity.go     # Community creation
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   └── auth.go              # JWT authentication middleware
β”‚   β”‚   └── models/                  # Data structures
β”‚   β”‚       β”œβ”€β”€ user.go              # User model
β”‚   β”‚       β”œβ”€β”€ post.go              # Post model
β”‚   β”‚       β”œβ”€β”€ comment.go           # Comment model
β”‚   β”‚       β”œβ”€β”€ community.go         # Community model
β”‚   β”‚       β”œβ”€β”€ community_member.go  # Membership model
β”‚   β”‚       └── vote.go              # Vote model
β”‚   └── go.mod                       # Go module dependencies
β”‚
β”œβ”€β”€ frontend/                         # React frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx                  # Root application component
β”‚   β”‚   β”œβ”€β”€ main.jsx                 # React DOM entry point
β”‚   β”‚   β”œβ”€β”€ index.css                # Global styles
β”‚   β”‚   β”œβ”€β”€ App.css                  # Application styles
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx      # Authentication state management
β”‚   β”‚   β”œβ”€β”€ pages/                   # Page-level components
β”‚   β”‚   β”‚   β”œβ”€β”€ LandingPage.jsx      # Home page
β”‚   β”‚   β”‚   β”œβ”€β”€ PostPage.jsx         # Individual post view
β”‚   β”‚   β”‚   β”œβ”€β”€ CreatePostPage.jsx   # Post creation/editing
β”‚   β”‚   β”‚   β”œβ”€β”€ UserProfilePage.jsx  # User profile view
β”‚   β”‚   β”‚   β”œβ”€β”€ CommunityPage.jsx    # Community view
β”‚   β”‚   β”‚   β”œβ”€β”€ CommunityListPage.jsx# Communities listing
β”‚   β”‚   β”‚   β”œβ”€β”€ PopularPostPage.jsx  # Trending posts
β”‚   β”‚   β”‚   └── Layout.jsx           # Base layout template
β”‚   β”‚   β”œβ”€β”€ components/              # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Button/              # Button component
β”‚   β”‚   β”‚   β”œβ”€β”€ Card/                # Card & post card components
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginForm/           # Login form
β”‚   β”‚   β”‚   β”œβ”€β”€ SignupForm/          # Signup form
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginModal/          # Auth modal
β”‚   β”‚   β”‚   β”œβ”€β”€ SearchBar/           # Search component
β”‚   β”‚   β”‚   β”œβ”€β”€ DropdownMenu/        # Menu components
β”‚   β”‚   β”‚   β”œβ”€β”€ CommentBar/          # Comment input
β”‚   β”‚   β”‚   β”œβ”€β”€ JoinButton/          # Community join button
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateCommunityModal/# Create community dialog
β”‚   β”‚   β”‚   └── ...                  # Other UI components
β”‚   β”‚   β”œβ”€β”€ sections/                # Page sections/layouts
β”‚   β”‚   β”‚   β”œβ”€β”€ Header/              # Navigation header
β”‚   β”‚   β”‚   β”œβ”€β”€ SideBar/             # Sidebar navigation
β”‚   β”‚   β”‚   β”œβ”€β”€ PostSection/         # Posts display area
β”‚   β”‚   β”‚   β”œβ”€β”€ PostBar/             # Post filter controls
β”‚   β”‚   β”‚   β”œβ”€β”€ CreatePost/          # Post creation section
β”‚   β”‚   β”‚   └── ...                  # Other page sections
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   └── color.js             # Utility functions
β”‚   β”‚   └── assets/                  # Static assets
β”‚   β”œβ”€β”€ public/                      # Public static files
β”‚   β”œβ”€β”€ index.html                   # HTML entry point
β”‚   β”œβ”€β”€ package.json                 # Frontend dependencies
β”‚   β”œβ”€β”€ vite.config.js              # Vite configuration
β”‚   β”œβ”€β”€ tailwind.config.js          # TailwindCSS configuration
β”‚   β”œβ”€β”€ eslint.config.js            # ESLint rules
β”‚   β”œβ”€β”€ postcss.config.js           # PostCSS configuration
β”‚   └── .stylelintrc.json           # Style linting rules
β”‚
β”œβ”€β”€ package.json                     # Root package metadata
β”œβ”€β”€ .env                            # Environment variables
β”œβ”€β”€ DevLog.txt                      # Development log
β”œβ”€β”€ LICENSE                         # License file
└── README.md                       # This file

πŸš€ Getting Started

Prerequisites

System Requirements:

  • Node.js 16+ (frontend)
  • Go 1.25.5+ (backend)
  • npm or yarn (package management)
  • Git

Recommended Development Tools:

  • VS Code with Go and React extensions
  • Postman or similar API testing tool
  • SQLite browser (optional, for database inspection)

Backend Setup

  1. Navigate to backend directory:

    cd backend
  2. Install Go dependencies:

    go mod download
  3. Database Configuration:

    The application currently uses a specific absolute path for the SQLite database. You may need to update backend/internal/database/database.go to match your local path if the application fails to find the database.

  4. Start the backend server:

    cd cmd/api
    go run main.go

    The backend API will be available at http://localhost:8080

  5. Verify backend is running:

    # Test a simple endpoint
    curl http://localhost:8080/api/communities

Frontend Setup

  1. Navigate to frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start development server:

    npm run dev

    The frontend will be available at http://localhost:5173

  4. Build for production:

    npm run build
  5. Preview production build:

    npm run preview

Running Both Services

For development, you'll need two terminal windows:

Terminal 1 - Backend:

cd backend/cmd/api
go run main.go

Terminal 2 - Frontend:

cd frontend
npm run dev

οΏ½ Feature Completion Matrix

Core Features Status

Feature Backend Frontend Status
User Authentication βœ… βœ… Complete
Register User βœ… βœ… Complete
Login/Logout βœ… βœ… Complete
JWT Token Management βœ… βœ… Complete
Get Current User βœ… βœ… Complete
User Profiles βœ… βœ… Complete
Communities βœ… βœ… Complete
Create Community βœ… βœ… Complete
Browse All Communities βœ… βœ… Complete
Get Top Communities βœ… βœ… Complete
Community Details βœ… βœ… Complete
Join Community βœ… βœ… Complete
Leave Community βœ… βœ… Complete
Posts βœ… βœ… Complete
Create Post βœ… βœ… Complete
View All Posts βœ… βœ… Complete
View Single Post βœ… βœ… Complete
Get Posts by Community βœ… βœ… Complete
Edit Post βœ… βœ… Complete
Delete Post βœ… βœ… Complete
Comments βœ… βœ… Complete
Create Comment βœ… βœ… Complete
View Post Comments βœ… βœ… Complete
Edit Comment βœ… βœ… Complete
Delete Comment βœ… βœ… Complete
Voting βœ… βœ… Complete
Vote on Post βœ… βœ… Complete
Update Vote βœ… βœ… Complete
Calculate Post Score βœ… βœ… Complete
Discovery βœ… βœ… Complete
Popular Posts Feed βœ… βœ… Complete
Top Communities Ranking βœ… βœ… Complete

In-Progress / Planned Features

Feature Priority Status Notes
Notifications High πŸ”„ Planning Real-time notification system
Direct Messaging Medium πŸ“‹ Planned Private user-to-user messages
Advanced Search High πŸ”„ In Progress Full-text search across posts/comments
User Reputation/Karma Medium πŸ“‹ Planned Scoring based on community engagement
Media Upload High πŸ”„ Designing Image/video support in posts/comments
Moderators & Roles Medium ⚠️ Partial Role field exists, permissions not enforced
Private Communities Low ⚠️ Partial is_private field in DB, access control incomplete
Content Moderation Medium πŸ“‹ Planned Report/flag system for inappropriate content
Infinite Scroll Low πŸ”„ Designing Pagination for large feed lists
Real-time Updates High πŸ”„ Planning WebSocket for live comments/votes
Analytics Dashboard Low πŸ“‹ Planned Engagement metrics and trending analysis

πŸ“‘ API Documentation

Base URL

http://localhost:8080/api

Authentication Endpoints (Public)

Register User

POST /auth/register
Content-Type: application/json

Request:
{
  "username": "string",
  "password": "string"
}

Response: 201 Created
{
  "message": "User registered successfully"
}

Login

POST /auth/login
Content-Type: application/json

Request:
{
  "username": "string",
  "password": "string"
}

Response: 200 OK
{
  "user": {
    "id": "integer",
    "username": "string",
    "email": "string"
  }
}

Note: JWT token stored in HttpOnly cookie automatically. Include credentials: "include" in fetch requests.

Logout

POST /auth/logout
(Credentials required)

Response: 200 OK
{
  "message": "Logged out successfully"
}

Refresh Token

POST /auth/refresh
(Credentials required)

Response: 200 OK
{
  "token": "jwt_token_string"
}

Current User Endpoints (Auth Required)

Get Current User Info

GET /auth/me
(Credentials required)

Response: 200 OK
{
  "user": {
    "id": "integer",
    "username": "string",
    "email": "string",
    "createdAt": "timestamp"
  }
}

Communities Endpoints

Get All Communities (Public)

GET /communities

Response: 200 OK
[
  {
    "id": "integer",
    "name": "string",
    "icon": "string (URL)",
    "description": "string",
    "rules": "string",
    "members": "integer",
    "postsCount": "integer",
    "isPrivate": "boolean",
    "createdAt": "timestamp"
  }
]

Get Top Communities (Public)

GET /communities/top/{limit}

Query Parameters:
- limit: Integer (required) - Number of communities to return

Response: 200 OK
[Community, ...]  # Array of communities sorted by member count (DESC)

Get Community by ID (Public)

GET /communities/{communityID}

Response: 200 OK
{Community}

Create Community (Auth Required)

POST /communities
Content-Type: application/json
(Credentials required)

Request:
{
  "name": "string",
  "description": "string",
  "icon": "string (URL)",
  "rules": "string"
}

Response: 201 Created
{Community}

Update Community (Auth Required)

PUT /communities/{communityID}
Content-Type: application/json
(Credentials required)

Request:
{
  "name": "string",
  "description": "string",
  "icon": "string (URL)",
  "rules": "string"
}

Response: 200 OK
{Community}

Delete Community (Auth Required)

DELETE /communities/{communityID}
(Credentials required)

Response: 200 OK
{
  "message": "Community deleted successfully"
}

Join Community (Auth Required)

POST /communities/{id}/join
(Credentials required)

Response: 200 OK
{
  "message": "Joined community successfully"
}

Leave Community (Auth Required)

POST /communities/{id}/leave
(Credentials required)

Response: 200 OK
{
  "message": "Left community successfully"
}

Check Membership (Auth Required)

GET /communities/{id}/joined
(Credentials required)

Response: 200 OK
{
  "isMember": "boolean"
}

Posts Endpoints

Get All Posts (Public)

GET /posts

Response: 200 OK
[
  {
    "id": "integer",
    "title": "string",
    "content": "string",
    "link": "string",
    "authorId": "integer",
    "communityId": "integer",
    "score": "integer",
    "createdAt": "timestamp",
    "updatedAt": "timestamp"
  }
]

Get Single Post (Public)

GET /posts/{postID}

Response: 200 OK
{Post}

Get Posts by Community (Public)

GET /communities/{communityID}/posts

Response: 200 OK
[Post, ...]

Get Posts by User (Public)

GET /users/{userID}/posts

Response: 200 OK
[Post, ...]

Create Post (Auth Required)

POST /posts
Content-Type: application/json
(Credentials required)

Request:
{
  "title": "string",
  "content": "string",
  "link": "string",
  "communityId": "integer"
}

Response: 201 Created
{Post}

Update Post (Auth Required)

PUT /posts/{postID}
Content-Type: application/json
(Credentials required)

Request:
{
  "title": "string",
  "content": "string",
  "link": "string"
}

Response: 200 OK
{Post}

Delete Post (Auth Required)

DELETE /posts/{postID}
(Credentials required)

Response: 200 OK
{
  "message": "Post deleted successfully"
}

Response: 200 OK {Post}


#### Delete Post

DELETE /posts/{postID} Authorization: Bearer

Response: 200 OK { "message": "Post deleted successfully" }


### Comments Endpoints

#### Create Comment (Auth Required)
```http
POST /posts/{postID}/comments
Content-Type: application/json
(Credentials required)

Request:
{
  "content": "string (required, cannot be empty)"
}

Response: 201 Created
{
  "id": "integer",
  "content": "string",
  "authorId": "integer",
  "postId": "integer",
  "createdAt": "timestamp",
  "updatedAt": "timestamp"
}

Get Post Comments (Public)

GET /posts/{postID}/comments

Response: 200 OK
[
  {
    "id": "integer",
    "content": "string",
    "authorId": "integer",
    "postId": "integer",
    "createdAt": "timestamp",
    "updatedAt": "timestamp"
  }
]

Update Comment (Auth Required)

PATCH /comments/{commentID}
Content-Type: application/json
(Credentials required)

Request:
{
  "content": "string"
}

Response: 200 OK
{Comment}

Delete Comment (Auth Required)

DELETE /comments/{commentID}
(Credentials required)

Response: 200 OK
{
  "message": "Comment deleted successfully"
}

Get Comments by User (Public)

GET /users/{userID}/comments

Response: 200 OK
[Comment, ...]

Voting Endpoints

Cast Vote (Auth Required)

POST /vote
Content-Type: application/json
(Credentials required)

Request:
{
  "userId": "integer",
  "postId": "integer",
  "value": "integer (1 for upvote, -1 for downvote)"
}

Response: 200 OK
{
  "postId": "integer",
  "userId": "integer",
  "value": "integer",
  "message": "Vote recorded"
}

Note: Update existing vote by posting again with same postId and different value.

Remove Vote (Auth Required)

DELETE /vote
Content-Type: application/json
(Credentials required)

Request:
{
  "userId": "integer",
  "postId": "integer"
}

Response: 200 OK
{
  "message": "Vote removed"
}

Get Vote (Public)

GET /vote/{userID}/{postID}

Response: 200 OK
{
  "userId": "integer",
  "postId": "integer",
  "value": "integer"
}

User Endpoints

Get User by ID (Public)

GET /users/{userID}

Response: 200 OK
{
  "id": "integer",
  "username": "string",
  "email": "string",
  "createdAt": "timestamp"
}

πŸ’Ύ Database Schema

Users Table

CREATE TABLE users (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  username TEXT UNIQUE NOT NULL,
  email TEXT UNIQUE,
  password TEXT NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

Communities Table

CREATE TABLE communities (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT UNIQUE NOT NULL,
  icon TEXT,
  description TEXT,
  rules TEXT,
  members INTEGER DEFAULT 0,
  posts_count INTEGER DEFAULT 0,
  is_private BOOLEAN DEFAULT 0,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

Posts Table

CREATE TABLE posts (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  title TEXT NOT NULL,
  content TEXT,
  link TEXT,
  author_id INTEGER NOT NULL,
  community_id INTEGER NOT NULL,
  score INTEGER DEFAULT 0,           -- NEW: Vote aggregate
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (author_id) REFERENCES users(id),
  FOREIGN KEY (community_id) REFERENCES communities(id)
);

Comments Table

CREATE TABLE comments (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  content TEXT NOT NULL,
  author_id INTEGER NOT NULL,
  post_id INTEGER NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (author_id) REFERENCES users(id),
  FOREIGN KEY (post_id) REFERENCES posts(id)
);

Votes Table

CREATE TABLE votes (
  user_id INTEGER NOT NULL,
  post_id INTEGER NOT NULL,
  value INTEGER NOT NULL,      -- 1 = upvote, -1 = downvote
  PRIMARY KEY (user_id, post_id),
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (post_id) REFERENCES posts(id),
  UNIQUE(user_id, post_id)
);

Community Members Table

CREATE TABLE community_members (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  user_id INTEGER NOT NULL,
  community_id INTEGER NOT NULL,
  role TEXT NOT NULL DEFAULT 'member',   -- 'member', 'moderator', 'admin'
  joined_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (community_id) REFERENCES communities(id),
  UNIQUE(user_id, community_id)
);

πŸ— Component Architecture

Frontend Pages Implemented

Page Route Features
LandingPage / Home feed with community carousel, post feed, popular communities sidebar
PostPage /posts/:id Single post view with full comments thread, vote buttons, edit/delete actions
CreatePostPage /create, /c/:communityId/create, /posts/:postId/edit/:communityId Post editor with community selector, support for create and edit modes
CommunityPage /communities/:id Community view with header, join/leave button, all posts in community
CommunityListPage /communities Browse all communities with member counts, join buttons
PopularPostPage /popular Trending posts feed sorted by engagement
UserProfilePage /users/:id User profile showing user info and their posts
Layout (Template) Base template for all pages: Header + Sidebar + Content area

Frontend Component Hierarchy

App
β”œβ”€β”€ Router (React Router v7)
β”‚   β”œβ”€β”€ LandingPage
β”‚   β”‚   β”œβ”€β”€ Layout
β”‚   β”‚   β”‚   β”œβ”€β”€ Header (Navigation, Search, User Menu)
β”‚   β”‚   β”‚   β”œβ”€β”€ SideBar (Navigation links, Community list)
β”‚   β”‚   β”‚   └── Content
β”‚   β”‚   β”‚       β”œβ”€β”€ CardSlides (Carousel - Featured Communities)
β”‚   β”‚   β”‚       β”œβ”€β”€ PostSection
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ PostBar (Filter/Sort controls)
β”‚   β”‚   β”‚       β”‚   └── Post[] (Feed of PostCards)
β”‚   β”‚   β”‚       β”‚       └── PostCard
β”‚   β”‚   β”‚       β”‚           β”œβ”€β”€ PostCardContent
β”‚   β”‚   β”‚       β”‚           β”œβ”€β”€ Vote Buttons
β”‚   β”‚   β”‚       β”‚           └── Action Dropdown
β”‚   β”‚   β”‚       └── PopularCommunities
β”‚   β”‚
β”‚   β”œβ”€β”€ PostPage
β”‚   β”‚   β”œβ”€β”€ Layout
β”‚   β”‚   β”‚   β”œβ”€β”€ Header
β”‚   β”‚   β”‚   β”œβ”€β”€ SideBar
β”‚   β”‚   β”‚   └── Post (Single with full metadata)
β”‚   β”‚   β”‚       β”œβ”€β”€ Vote Buttons
β”‚   β”‚   β”‚       β”œβ”€β”€ Author Info
β”‚   β”‚   β”‚       β”œβ”€β”€ Comments[]
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ Comment Item
β”‚   β”‚   β”‚       β”‚   └── CommentBar (Reply input)
β”‚   β”‚   β”‚       └── Actions (Edit, Delete)
β”‚   β”‚
β”‚   β”œβ”€β”€ CreatePostPage
β”‚   β”‚   β”œβ”€β”€ PostEditor
β”‚   β”‚   β”œβ”€β”€ CommunitySelector
β”‚   β”‚   └── Submit Button
β”‚   β”‚
β”‚   β”œβ”€β”€ CommunityPage
β”‚   β”‚   β”œβ”€β”€ Layout
β”‚   β”‚   β”‚   β”œβ”€β”€ Community Header (Name, icon, description)
β”‚   β”‚   β”‚   β”œβ”€β”€ JoinButton
β”‚   β”‚   β”‚   β”œβ”€β”€ Member Count
β”‚   β”‚   β”‚   └── Posts in Community[]
β”‚   β”‚
β”‚   β”œβ”€β”€ CommunityListPage
β”‚   β”‚   β”œβ”€β”€ Layout
β”‚   β”‚   β”‚   └── Communities[] with Join Buttons
β”‚   β”‚
β”‚   β”œβ”€β”€ PopularPostPage
β”‚   β”‚   β”œβ”€β”€ Layout
β”‚   β”‚   β”‚   └── Popular Posts[] (sorted by engagement)
β”‚   β”‚
β”‚   └── UserProfilePage
β”‚       β”œβ”€β”€ Layout
β”‚       β”‚   β”œβ”€β”€ Profile Header
β”‚       β”‚   └── User Posts[]
β”‚
└── LoginModal (Global)
    β”œβ”€β”€ LoginForm
    └── SignupForm

AuthContext (Global State)
β”œβ”€β”€ user (current user object or null)
β”œβ”€β”€ loading (boolean)
β”œβ”€β”€ login() (async function)
└── logout() (async function)

Key Reusable Components

Component Location Purpose
Button components/Button/ Styled button with variants
Card components/Card/Card.jsx Generic card container
PostCard components/Card/PostCard.jsx Post display card with metadata
PostCardContent components/Card/PostCardContent.jsx Post content rendering
LoginModal components/LoginModal/ Auth modal (login/signup)
LoginForm components/LoginForm/ Login form component
SignupForm components/SignupForm/ Registration form component
CommentBar components/CommentBar/ Comment input and submission
SearchBar components/SearchBar/ Search input with dynamic placeholder
JoinButton components/JoinButton/ Join/Leave community toggle
CreateCommunityModal components/CreateCommunityModal/ Create new community dialog
DropdownMenu components/DropdownMenu/ Reusable dropdown menu system
AbsoluteDropdown components/DropdownMenu/AbsoluteDropdown.jsx Absolute-positioned dropdown
DropdownItem components/DropdownMenu/DropdownItem.jsx Individual dropdown items
CircleButton components/CircleButton/ Circular button (sidebar toggle)
PillButton components/PillButton/ Pill-shaped button
Carousel components/Carousel/ Community carousel display
VerticalMenu components/VerticalMenu/ Vertical navigation menu
Community components/Community/ Community card display

Page Sections

Located in src/sections/, these are specialized layout components:

  • Header/ - Top navigation bar with search and user menu
  • SideBar/ - Left navigation with links and community list
  • PostSection/ - Main post feed display
  • PostBar/ - Filter and sort controls above posts
  • CreatePost/ - Post editor with community selector
  • PopularCommunities/ - Featured communities carousel
  • Main/ - Central content area
  • Body/ - Page body container
  • UserProfile/ - User profile section
  • UserBar/ - User action bar
  • Content/ - Generic content wrapper

About

forum web app, build with React frontend and Go backend.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages