{"id":48903970,"url":"https://github.com/tajjjjr/social-network","last_synced_at":"2026-04-16T18:07:35.987Z","repository":{"id":301327915,"uuid":"1008884601","full_name":"tajjjjr/social-network","owner":"tajjjjr","description":"A Facebook-like social network with features like profiles, posts, groups, real-time chat, and notifications, built with a Go backend (SQLite, Docker, WebSockets, migrations, authentication) and a JavaScript frontend.","archived":false,"fork":false,"pushed_at":"2025-09-04T12:50:35.000Z","size":1985,"stargazers_count":0,"open_issues_count":95,"forks_count":0,"subscribers_count":0,"default_branch":"development","last_synced_at":"2025-09-04T14:21:21.070Z","etag":null,"topics":["go","javascript","nextjs","sqlite3","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tajjjjr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-26T08:38:56.000Z","updated_at":"2025-08-15T14:12:10.000Z","dependencies_parsed_at":"2025-08-02T16:10:28.939Z","dependency_job_id":"06ae77f3-fcce-43e6-9050-3ad9f19f53d3","html_url":"https://github.com/tajjjjr/social-network","commit_stats":null,"previous_names":["oduortoni/social-network","tajjjjr/social-network"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tajjjjr/social-network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tajjjjr%2Fsocial-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tajjjjr%2Fsocial-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tajjjjr%2Fsocial-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tajjjjr%2Fsocial-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tajjjjr","download_url":"https://codeload.github.com/tajjjjr/social-network/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tajjjjr%2Fsocial-network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31897924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T17:33:00.867Z","status":"ssl_error","status_checked_at":"2026-04-16T17:32:57.401Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","javascript","nextjs","sqlite3","websocket"],"created_at":"2026-04-16T18:07:33.992Z","updated_at":"2026-04-16T18:07:35.982Z","avatar_url":"https://github.com/tajjjjr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# social-network\n\n## Description\nA Facebook-like social network with features like profiles, posts, groups, real-time chat, and notifications, built with a Go backend (SQLite, Docker, WebSockets, migrations, authentication) and a JavaScript frontend.\n\n## Features\n* **User Management:** Registration, Login, Logout, Sessions \u0026 Cookies, Optional profile fields (Avatar, Nickname, About Me).\n* **Profiles:** Public/Private profiles, User information display, User activity feed, Followers/Following display, Toggle profile privacy.\n* **Following System:** Send/accept/decline follow requests, Automatic following for public profiles.\n* **Posts \u0026 Comments:** Create posts and comments with image/GIF support.\n* **Post Privacy:** Public, Almost Private (followers only), Private (selected followers).\n* **Groups:** Create groups with title/description, Invite users, Request to join groups, Browse all groups.\n* **Group Activities:** Create posts and comments within groups, Create events (Title, Description, Day/Time, Going/Not Going options).\n* **Real-time Chat:** Private messaging between followers/following users, Group chat rooms, Emoji support, Instant delivery via WebSockets.\n* **Notifications:** Follow requests, Group invitations, Group join requests (for creators), New group events.\n\n## Posts and Comments Features\n\n### Creating Posts\n\nUsers can create new posts with text content and an optional image. Posts can have different privacy settings:\n\n-   **Public:** Visible to all users.\n-   **Followers:** Visible only to your followers.\n-   **Private:** Visible only to specific users you select.\n\n**Frontend Component:** `frontend/components/posts/PostCreation.jsx`\nThis component handles the input form, image selection, privacy setting, and user search for private posts.\n\n### Viewing Posts and Comments\n\nPosts are displayed in a feed, and comments can be viewed for each post. Access to posts is controlled by their privacy settings.\n\n**Frontend Components:**\n-   `frontend/components/posts/PostList.jsx`: Displays a list of posts.\n-   `frontend/components/posts/CommentList.jsx`: Displays comments for a specific post.\n\n### Deleting Posts and Comments\n\nUsers can delete their own posts and comments.\n\n### Image Handling\n\n-   **Supported Formats:** JPEG, PNG, GIF.\n-   **Storage:** Images are stored on the filesystem in the `backend/attachments/` directory, organized by type (e.g., `attachments/posts/`, `attachments/comments/`).\n-   **Validation:** Image size and format are validated on upload.\n\n### Styling and Responsiveness\n\nThe frontend is styled using Tailwind CSS, ensuring a responsive design that adapts to various screen sizes.\n\n## API Contract\n\n### Authentication\n\n*   **POST /login**\n    *   Description: Authenticates a user and creates a session.\n    *   Request Body:\n        ```json\n        {\n          \"email\": \"user@example.com\",\n          \"password\": \"password123\"\n        }\n        ```\n    * if successful, Response:\n        ```json\n        {\n          \"message\": \"Login successful\"\n        }\n        ```\n\n*   **POST /register**\n    *   Description: Registers a new user.\n    *   Request Body:\n        ```json\n        {\n          \"email\": \"user@example.com\",\n          \"password\": \"password123\",\n          \"firstname\": \"John\",\n          \"lastname\": \"Doe\",\n          \"dateofbirth\": \"1990-01-15\",\n          \"nickname\": \"Johnny\",\n          \"aboutme\": \"I'm a new user\",\n          \"isprofilepublic\": true,\n          \"avatar\": \"url-to-avatar\"\n        }\n        ```\n    *   if successful, Response:\n        ```json\n        { \n          \"message\": \"Registration successful\"\n        }\n        ```\n* **POST /logout**\n    *   Description: Invalidates the user's current session.\n    *   if successful, Response:\n        ```json\n        { \n          \"message\": \"Logout successful\"\n        }\n        ```   \n\n* **POST /validate/step1**\n    *   Description: (Optional) First step of account validation (if required by your flow).\n    *   Request Body: (see implementation)\n    *   Response: (see implementation)\n\n\u003c!--\n* **POST /checksession**\n    *   Description: Checks if a session is valid. (Currently not active in backend)\n    *   if successful, Response:\n        ```json\n        { \n          \"message\": \"Valid session\"\n        }\n        ```\n--\u003e\n\n### Users\n\n*   **GET /api/users/{id}**\n    *   Description: Retrieves a user's profile information.\n    *   Response:\n        ```json\n        {\n          \"id\": 123,\n          \"username\": \"newuser\",\n          \"email\": \"newuser@example.com\",\n          \"profile\": {\n            \"avatar\": \"url-to-avatar\",\n            \"nickname\": \"Newbie\",\n            \"about\": \"Hello, I'm new here!\"\n          }\n        }\n        ```\n\n### Posts\n\n*   **GET /api/posts**\n    *   Description: Retrieves a feed of posts.\n    *   Response:\n        ```json\n        [\n          {\n            \"id\": 1,\n            \"authorId\": 123,\n            \"content\": \"This is my first post!\",\n            \"createdAt\": \"2025-06-29T12:00:00Z\"\n          }\n        ]\n        ```\n\n*   **POST /api/posts**\n    *   Description: Creates a new post.\n    *   Request Body:\n        ```json\n        {\n          \"content\": \"My new post content.\"\n        }\n        ```\n    *   Response:\n        ```json\n        {\n          \"id\": 2,\n          \"authorId\": 123,\n          \"content\": \"My new post content.\",\n          \"createdAt\": \"2025-06-29T13:00:00Z\"\n        }\n        ```\n\n## Requirements\nTo run this project, you will need:\n* Next JS\n* A Go environment for the backend.\n* SQLite database.\n* Docker.\n* Docker Compose.\n\n## Getting Started\n\nClone the repository and navigate to the frontend directory:\n\n```bash\ngit clone https://github.com/oduortoni/social-network.git\ncd social-network/frontend\nnpm install\n```\n\n**create a .env file**\n\nThis project runs a Go backend and a Next.js frontend at the same time. Each must use a different port to avoid conflicts. Using a .env file within the root of the frontend folder, populate it with the following content:\n\n```env\nPORT=9000\nNEXT_PORT=3000\n\n# development\nNEXT_PUBLIC_API_URL=http://localhost:9000\n\n# Authentication credentials (required for OAuth)\nFACEBOOK_CLIENT_ID=your_facebook_client_id\nFACEBOOK_CLIENT_SECRET=your_facebook_client_secret\nGITHUB_CLIENT_ID=your_github_client_id\nGITHUB_CLIENT_SECRET=your_github_client_secret\nGOOGLE_CLIENT_ID=your_google_client_id\nGOOGLE_CLIENT_SECRET=your_google_client_secret\n\n# Note: When making API calls from React, include credentials\n# Add this to your fetch options:\n# credentials: 'include'\n\n# production\n# NEXT_PUBLIC_API_URL=https://api.example.com\n```\n\nthe NEXT_PUBLIC_API_URL will be used by the browser automatically to access the backend url\n\nfinally, run both servers\n\n```bash\nnpm run dev\n```\n\nThis command starts both the backend and frontend concurrently using the correct port settings.\n\n**open in your browser**\n\nFollow the link that falls under the next js project i.e either of the last two urls\n\ne.g  http://localhost:3000\n\nsince we defined the frontend to run using NEXT_PORT=3000\n\n## Usage\nTo get started with this project, clone the repository:\n```bash\nnpm run dev\n```\n\nThis command starts both the backend and frontend concurrently using the correct port settings.\n\n**open in your browser**\n\nFollow the link that falls under the next js project i.e either of the last two urls\n\ne.g  http://localhost:3000\n\nsince we defined the frontend to run using NEXT_PORT=3000\n\n## Docker Integration\nTO start the docker containers\n```bash\ndocker-compose up --build\n```\nTO delete the docker containers\n```bash\ndocker-compose down\n```\n\n## Authentication System Setup \u0026 Testing\n\n### Setup\n- Backend: Ensure Go and SQLite are installed. Run `go run server.go` in the backend directory, or use Docker Compose as described above.\n- Frontend: See environment setup above. The frontend communicates with the backend via the API endpoints below.\n\n### Running Authentication Tests\n- From the backend directory, run:\n  ```bash\n  go test ./internal/api/handlers/tests/\n  ```\n- This will execute all authentication-related tests, including SQL injection and XSS prevention.\n\n## Authentication API Endpoints\n\n| Endpoint         | Method | Description                |\n|------------------|--------|----------------------------|\n| /api/register    | POST   | Register a new user        |\n| /api/login       | POST   | Log in a user              |\n| /api/logout      | POST   | Log out the current user   |\n\n### /api/register\n- **Request:** JSON or multipart/form-data with fields:\n  - email, password, firstname, lastname, dateofbirth, nickname, aboutme, isprofilepublic, avatar\n- **Success:** 200 OK `{ \"message\": \"Registration successful\" }`\n- **Errors:** 400 (invalid input), 409 (email exists), 500 (server error)\n\n### /api/login\n- **Request:** JSON or form data with fields:\n  - email, password\n- **Success:** 200 OK `{ \"message\": \"Login successful\" }` and sets `session_id` cookie\n- **Errors:** 400 (invalid input), 401 (invalid credentials), 500 (server error)\n\n### /api/logout\n- **Request:** No body required (must be authenticated)\n- **Success:** 200 OK `{ \"message\": \"Logout successful\" }`\n- **Errors:** 401 (no valid session), 500 (server error)\n\n## Session Management \u0026 Cookies\n- On login, a `session_id` cookie is set (HttpOnly, Secure, SameSite=Strict, Path=/, Expires=24h).\n- All protected endpoints require a valid `session_id` cookie.\n- On logout, the session is deleted and the cookie is cleared.\n- Session fixation and CSRF are mitigated by secure cookie settings and session regeneration.\n\n## Security\n- All user input is validated and sanitized to prevent SQL injection and XSS.\n- Passwords are hashed before storage.\n- See `docs/authentication.md` and test files for more details.\n\n## Contributors\n\n* [DavJesse](https://github.com/DavJesse)\n\n* [Murzuqisah](https://github.com/Murzuqisah)\n\n* [karodgers](https://github.com/karodgers)\n\n* [siaka385](https://github.com/siaka385)\n\n* [nyunja](https://github.com/nyunja)\n\n* [oduortoni](https://github.com/oduortoni)\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftajjjjr%2Fsocial-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftajjjjr%2Fsocial-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftajjjjr%2Fsocial-network/lists"}