Skip to content

leo-Zhizhu/Pixel-Social

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pixel Social

A full-stack, AI-powered social media platform built on React frontend and Go backend for users to share images and videos. Users can register, create posts with images/videos, generate images with OpenAI DALL-E 3, and search or browse a shared collection.


User-facing functionalities

  • Account
    • Register and sign in with JWT-based auth; stay signed in across sessions.
  • Create content
    • Manual posts: Add a message and upload an image or video.
    • AI images: Enter a text prompt; the app uses DALL-E 3 to generate an image, then you can save it as a post.
  • Collection
    • View all posts in a photo gallery with lightbox (fullscreen, zoom, slideshow, thumbnails).
    • Search by keywords (in post text) or by username.
    • Delete your own posts.
  • UI/UX
    • Responsive layout, dark theme, nav bar, and toast notifications for actions.

Technical stack highlights

Layer Technology
Frontend React 18, React Router 6, Material-UI, Ant Design, Styled Components
Media / AI react-photo-album, yet-another-react-lightbox, OpenAI SDK (DALL-E 3), Axios
Backend Go (Gorilla Mux), JWT (Auth0 middleware)
Data Elasticsearch (users + posts, search)
Storage Google Cloud Storage (media files)
Deploy Frontend: static build (e.g. hosting / CDN); Backend: Google App Engine Flex (Docker)

Backend API: POST /signup, POST /signin, POST /upload, GET /search, DELETE /post/:id. Protected routes use Authorization: Bearer <token>.


Monorepo structure

.
├── backend/              # Go API service
│   ├── backend/         # Elasticsearch & GCS clients
│   ├── conf/            # deploy.yaml (gitignored), deploy.yaml.example
│   ├── constants/       # Index names etc.
│   ├── handler/         # HTTP handlers & router
│   ├── model/           # Data models
│   ├── service/         # Business logic
│   ├── util/            # Config loading
│   ├── main.go
│   ├── app.yaml         # App Engine config
│   └── Dockerfile
├── public/              # Static assets for frontend
├── src/                 # React app
│   ├── components/
│   ├── styles/
│   ├── constants.js
│   └── index.js
├── .env.example         # Frontend env template
├── package.json         # Frontend deps + root scripts
└── README.md

Prerequisites

  • Node.js 14+ and npm
  • Go 1.25+ (for backend)
  • Elasticsearch 7.x (for backend)
  • Google Cloud project with GCS bucket (for backend media storage)
  • OpenAI API key (for DALL-E 3 image generation in frontend)

Installation and local development

1. Clone and install frontend

git clone https://github.com/leo-Zhizhu/Social-AI-Frontend.git
cd Social-AI-Frontend
npm install

2. Frontend environment

cp .env.example .env

Edit .env:

  • REACT_APP_BASE_URL=http://localhost:8080 (local backend)
  • REACT_APP_OPENAI_KEY=<your-openai-key>

3. Backend configuration

cp backend/conf/deploy.yaml.example backend/conf/deploy.yaml

Edit backend/conf/deploy.yaml with your Elasticsearch URL, username, password, GCS bucket name, and JWT secret. Do not commit this file.

4. Run locally (two terminals)

Terminal 1 – backend (port 8080):

npm run start:backend
# or: cd backend && go run main.go

Terminal 2 – frontend (port 3000):

npm start

Open http://localhost:3000. The app will call the backend at http://localhost:8080.


Deployment guide

Backend (Google App Engine Flex)

  1. Config

    • Ensure backend/conf/deploy.yaml exists and is correct (not committed). App Engine may use Secret Manager or env vars for production; adjust to your setup.
  2. Deploy

    cd backend
    gcloud app deploy app.yaml

    Backend will be at https://<project-id>.appspot.com (or your custom domain).

  3. Port

    • Backend listens on PORT (default 8080). GAE sets PORT automatically.

Frontend (static build)

  1. Point to production API

    • In your build environment, set:
      • REACT_APP_BASE_URL=https://<your-backend-url> (e.g. https://socialai-dot-socialai-477621.ue.r.appspot.com).
    • Optional: REACT_APP_OPENAI_KEY for DALL-E (if you keep it in frontend; prefer backend proxy in production if possible).
  2. Build

    npm run build

    Output is in build/.

  3. Host

    • Upload build/ to any static host (Firebase Hosting, Vercel, Netlify, Cloud Storage + Load Balancer, etc.).

Summary

Component Command / action Result
Backend cd backend && gcloud app deploy app.yaml Live API on GAE
Frontend Set REACT_APP_BASE_URL then npm run build; deploy build/ Live SPA

Configuration reference

  • Frontend
    • .env: REACT_APP_BASE_URL, REACT_APP_OPENAI_KEY (see .env.example).
  • Backend
    • backend/conf/deploy.yaml: elasticsearch (address, username, password), gcs (bucket), token (JWT secret). Copy from backend/conf/deploy.yaml.example.

Sensitive data (.env, conf/deploy.yaml, API keys) must not be committed.


Scripts (root package.json)

Script Description
npm start Start frontend dev server
npm run start:frontend Same as start
npm run start:backend Run Go backend (backend/)
npm run build Production frontend build
npm test Frontend tests

Troubleshooting

  • Backend connection
    • Confirm backend is running and REACT_APP_BASE_URL matches (e.g. http://localhost:8080 locally).
  • CORS
    • Backend allows * origins; restrict in production if needed.
  • OpenAI errors
    • Check REACT_APP_OPENAI_KEY and OpenAI account/credits.
  • Build
    • If frontend build fails: rm -rf node_modules package-lock.json && npm install.

License

Private / proprietary.


Built with React, Go, Elasticsearch, GCS, and OpenAI.

About

Online social AI platform for users to upload, create, and share images and videos

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors