This web application provides interactive visualization of social networks as undirected graphs. The application features shareable sandboxes - users can create isolated graph instances and share them via unique URLs. Each graph is completely separate, enabling private collaborations, events, or experimental networks alongside the main public graph.
- Framework: Next.js (React)
- Language: TypeScript
- API: Vercel Serverless Functions with API routes
- Database: Neon (PostgreSQL) for Production/CI, SQLite for Local Development
- ORM: Prisma
- UI: shadcn/ui, Tailwind CSS
- Graph Visualization: react-force-graph-2d
- Deployment: Vercel
- Testing: Jest, React Testing Library
🎯 Shareable Sandboxes: Create isolated graph instances with unique, shareable URLs
🔐 No Authentication Required: Anyone with a link can view and edit graphs
🌐 Global & Private Graphs: Public demo graph plus unlimited private instances
📱 Responsive Design: Works seamlessly on desktop and mobile devices
🔗 Easy Sharing: Copy links or use native sharing with one click
⚡ Real-time Updates: Changes appear instantly for all viewers
The project follows a src directory structure, standard for modern Next.js applications.
src/app/api/: Backend API routes for graph management and legacy endpointssrc/app/: Main application routes including dynamic graph pages (/graph/[graphId])src/components/: React components for graph visualization and managementsrc/lib/: Database abstraction layer supporting multiple backendssrc/utils/: Utility functions including graph ID generationprisma/: Database schema, migrations, and seedingtests/: Integration and unit tests
git clone https://github.com/your-username/social-graph.git
cd social-graphnpm installFor production and CI/CD, you will need a PostgreSQL database.
-
Create a
.envfile in the project root. -
Add your Neon database connection string to it:
DATABASE_URL="your_neon_connection_string"
For local development, the project uses a temporary SQLite database to avoid consuming Neon resources. This is handled automatically.
Simply run the dev command:
npm run devThis command executes the ./dev.sh script, which:
- Temporarily switches the Prisma schema to use SQLite.
- Creates a local SQLite database at
prisma/dev.db. - Applies the database schema and seeds it with initial data.
- Starts the Next.js development server.
- Restores the original PostgreSQL schema when the server is stopped.
The local SQLite database is ignored by Git.
The project uses Jest and React Testing Library for testing. Test files are located in the tests/ directory and alongside the source files with a .test.ts(x) extension.
To run the entire test suite:
npm run testThis will automatically generate the Prisma client before running Jest.
- Visit the homepage at
/ - Click "Create New Graph"
- You'll be redirected to your unique graph URL (e.g.,
/graph/abc123def456) - Share the URL with others to collaborate
- Click the "Add to Network" button
- Enter LinkedIn profile information for yourself and connections
- Choose whether to connect everyone to each other or just to you
- Submit to add the profiles and connections
- Use the "Copy Link" button to copy the shareable URL
- Use "Share" button for native sharing (mobile devices)
- Send the link to anyone - no login required!
POST /api/graphs- Create a new graph instanceGET /api/graphs/[graphId]- Get graph data (profiles + connections)POST /api/graphs/[graphId]/add- Add profiles/connections to a graphPOST /api/graphs/[graphId]/connections- Add a connectionDELETE /api/graphs/[graphId]/connections- Remove a connection
GET /api/graph- Get global graph dataPOST /api/add- Add to global graphPOST /api/connections- Manage global connections
The application is configured for seamless deployment to Vercel.
- Push your code to a GitHub repository.
- Import the repository on Vercel.
- Set the
DATABASE_URLenvironment variable in the Vercel project settings.
Vercel will automatically build and deploy the application upon each push to the main branch. The postinstall script in package.json ensures that database migrations are applied during the build process.
The application uses three main tables:
- Graph: Stores graph instances with unique IDs
- Profile: User profiles linked to specific graphs
- Connection: Relationships between profiles within graphs
All data is properly isolated between different graph instances using composite primary keys and foreign key constraints.