This repository contains a photo-focused Instagram clone built with a Flutter frontend and a NestJS backend. It is structured as both a working full-stack app and a beginner-friendly learning project, with supporting guides in docs/.
- Frontend: Flutter, Riverpod, GoRouter, Dio
- Backend: NestJS, JWT auth, Prisma
- Database: PostgreSQL
- File storage: local uploads in
backend/uploads
backend/ NestJS API, Prisma schema, uploads
frontend/instagramflutterapp/ Flutter application
docs/ Setup guides, architecture notes, lesson plan
- Flutter SDK
- Node.js 20+
- PostgreSQL
cd backend
npm install
cp .env.example .env
npm run prisma:migrate
npm run seed
npm run start:devOptional database browser:
cd backend
npm run prisma:studioBackend endpoints:
- Health:
http://localhost:3000/health - API base:
http://localhost:3000/api - Uploaded files:
http://localhost:3000/uploads/<filename>
cd frontend/instagramflutterapp
flutter pub get
flutter runSet API_BASE_URL in the Flutter .env file to:
http://localhost:3000/apifor macOS or iOS simulatorhttp://10.0.2.2:3000/apifor Android emulator
After running the backend seed:
- Email:
student@example.com - Password:
password123
- User signup, login, and current-user auth flow with JWT
- Photo uploads with optional captions
- Feed retrieval with author, likes, comments, and liked-state
- Like and unlike posts
- Add and delete comments
- Delete your own posts and comments
- Native share flow on the Flutter side
- Controller receives the request.
- DTO validation checks the payload.
- JWT guards protect authenticated routes.
- Service runs business logic.
- Prisma reads or writes PostgreSQL.
- JSON response is returned to Flutter.
- Screen collects user input.
- Riverpod provider calls a repository.
- Repository uses Dio to call the backend.
- JWT is attached to protected requests.
- Provider updates UI state.
- Widgets rebuild with the latest data.
backend/src/auth: signup, login, JWT, current userbackend/src/posts: posts, likes, comments, uploadsbackend/prisma/schema.prisma: data model and relationships
frontend/instagramflutterapp/lib/src/services/auth_service.dart: auth API callsfrontend/instagramflutterapp/lib/src/config/app_config.dart: Dio and app configfrontend/instagramflutterapp/lib/src/features/posts: feed, upload, likes, comments, sharefrontend/instagramflutterapp/lib/src/features/home/presentation/screens/home_page.dart: main feed screen
Base path: /api
POST /auth/signupPOST /auth/loginGET /auth/me
POST /postsGET /posts/feedDELETE /posts/:id
POST /posts/:id/likeDELETE /posts/:id/like
GET /posts/:id/commentsPOST /posts/:id/commentsDELETE /comments/:id
See docs/API.md for example request bodies and auth details.
Read these in this order if you are learning or onboarding:
docs/01_LESSON_PLAN.mddocs/02_SETUP.mddocs/ARCHITECTURE.mddocs/API.mddocs/BACKEND.mddocs/FRONTEND.mddocs/FRONTEND_SETUP.mddocs/FRONTEND_ARCHITECTURE.md
- Uploads are stored locally first to keep the learning flow simple.
- The current upload approach can later be replaced with S3, Cloudinary, Supabase Storage, or Firebase Storage while keeping the database
imageUrlpattern.