Next.js frontend for the Spool educational platform. This frontend connects to separate backend microservices for authentication and content generation.
This is a Next.js frontend that connects to:
- Auth Service (
../spool-auth-service) - Authentication via AWS Cognito, deployed on ECS - Content Service (
../spool-content-service) - AI-powered content generation, deployed on ECS
- Frontend: Deployed via AWS Amplify
- Backend Services: Deployed via CodeBuild → ECR → ECS
- Authentication: User registration, sign-in, and profile management
- Personalized Learning: AI-generated exercises and assessments
- Progress Tracking: Learning analytics and progress visualization
- Responsive Design: Modern UI built with Radix UI and Tailwind CSS
- Real-time Updates: WebSocket integration for live features
The frontend connects to backend services via configured endpoints:
NEXT_PUBLIC_AUTH_SERVICE_URL=https://auth-service.spool.com
NEXT_PUBLIC_CONTENT_SERVICE_URL=https://content-service.spool.com
NEXT_PUBLIC_INTERVIEW_SERVICE_URL=https://interview-service.spool.com- User authentication and registration
- JWT token management
- Profile management
- Password reset functionality
- Exercise generation and assessment
- Learning path recommendations
- Progress tracking and analytics
- Semantic content search
- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env.local
# Edit .env.local with your backend service URLs- Run development server:
npm run dev- Build for production:
npm run build
npm start# Build image
docker build -t spool-content-service .
# Run container
docker run -p 3002:3002 \
-e DATABASE_URL=postgresql://user:pass@host:5432/db \
-e PINECONE_API_KEY=your-key \
-e LANGFLOW_API_URL=http://langflow:7860 \
spool-content-service-- Create database
CREATE DATABASE spool_content;
-- Example table structure
CREATE TABLE exercises (
id SERIAL PRIMARY KEY,
user_id VARCHAR(255) NOT NULL,
subject VARCHAR(100) NOT NULL,
difficulty INTEGER NOT NULL,
content JSONB NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE exercise_attempts (
id SERIAL PRIMARY KEY,
exercise_id INTEGER REFERENCES exercises(id),
user_id VARCHAR(255) NOT NULL,
score INTEGER NOT NULL,
time_spent INTEGER NOT NULL,
attempted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);- Create a Pinecone account and project
- Create an index with dimension 1536 (for OpenAI embeddings)
- Configure the API key and index name
- Deploy Langflow instance
- Create flows for content generation and assessment
- Configure API endpoints and authentication
src/
├── index.ts # Application entry point
├── integrations/ # External service integrations
│ ├── langflow.service.ts
│ └── pinecone.service.ts
├── middleware/ # Express middleware
│ ├── error.middleware.ts
│ ├── logging.middleware.ts
│ └── validation.middleware.ts
├── routes/ # API routes
│ ├── content.routes.ts
│ └── health.routes.ts
├── services/ # Business logic
│ ├── content.service.ts
│ └── database.service.ts
├── types/ # TypeScript types
│ └── content.types.ts
└── utils/ # Utilities
└── logger.ts
- Content Generation: Uses Langflow flows to generate personalized exercises
- Cognitive Assessment: Analyzes user responses to adapt difficulty
- Learning Path: Creates dynamic learning sequences
- Semantic Search: Find similar content based on vector embeddings
- Content Matching: Match user preferences with available content
- Recommendation Engine: Suggest relevant exercises and materials
interface Exercise {
id: string;
userId: string;
subject: string;
difficulty: number;
content: {
question: string;
options?: string[];
correctAnswer: string;
explanation: string;
};
createdAt: Date;
}interface ExerciseAttempt {
id: string;
exerciseId: string;
userId: string;
score: number;
timeSpent: number;
attemptedAt: Date;
}# Run tests
npm test
# Run linting
npm run lint
# Fix linting issues
npm run lint:fix- Input validation for all API endpoints
- Rate limiting on content generation endpoints
- Secure database connections
- API key management via environment variables
- CORS configuration for frontend access
- Health check endpoint at
/health - Structured logging with Winston
- Performance metrics for AI operations
- Database query monitoring
- Error tracking and alerting
- Database connection pooling
- Caching for frequently accessed content
- Batch processing for bulk operations
- Async processing for AI operations
- Response compression
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run linting and tests
- Submit a pull request
MIT