Below is a detailed structure of the files and their locations for the Strapi project based on the PRD provided earlier. Please note that this is a simplified example and might need adjustments based on your specific requirements and Strapi version.
Project Structure
aeria-employee-app/
├── config
│ ├── database.js
│ ├── security.js
│ └── ...
├── src
│ ├── api
│ │ ├── gift
│ │ │ ├── controllers
│ │ │ │ ├── gift.js
│ │ │ ├── models
│ │ │ │ ├── gift.js
│ │ │ ├── routes
│ │ │ │ ├── gift.js
│ │ │ └── services
│ │ │ ├── gift.js
│ │ ├── gift-allocation
│ │ │ ├── controllers
│ │ │ │ ├── gift-allocation.js
│ │ │ ├── models
│ │ │ │ ├── gift-allocation.js
│ │ │ ├── routes
│ │ │ │ ├── gift-allocation.js
│ │ │ └── services
│ │ │ ├── gift-allocation.js
│ │ ├── user
│ │ │ ├── controllers
│ │ │ │ ├── user.js
│ │ │ ├── models
│ │ │ │ ├── user.js
│ │ │ ├── routes
│ │ │ │ ├── user.js
│ │ │ └── services
│ │ │ ├── user.js
│ │ └── ...
│ ├── components
│ │ └── ...
│ ├── pages
│ │ └── ...
│ ├── plugins
│ │ └── ...
│ ├── utils
│ │ └── ...
│ └── ...
├── tsconfig.json
├── package.json
└── ...
Key Files
config/database.js
module.exports = {
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'sqlite',
filename: './database.db',
},
options: {
useNullAsDefault: true,
},
},
},
};
src/api/gift/controllers/gift.js
import { strapi } from '@strapi/strapi';
export default {
async assign(ctx) {
// Implement gift assignment logic here
},
};
src/api/gift/models/gift.js
import { model, Schema } from '@strapi/strapi';
export default model('gift', {
title: {
type: 'string',
required: true,
},
description: {
type: 'string',
},
image: {
type: 'media',
},
inventory: {
type: 'integer',
default: 0,
},
frequency: {
type: 'string',
},
timeWindow: {
type: 'json',
},
probability: {
type: 'float',
},
claimedExpiry: {
type: 'integer',
},
unclaimedExpiry: {
type: 'integer',
},
howToAvail: {
type: 'string',
},
termsAndConditions: {
type: 'string',
},
isActive: {
type: 'boolean',
default: true,
},
});
src/api/gift-allocation/controllers/gift-allocation.js
import { strapi } from '@strapi/strapi';
export default {
async create(ctx) {
// Implement gift allocation creation logic here
},
};
src/api/gift-allocation/models/gift-allocation.js
import { model, Schema } from '@strapi/strapi';
export default model('gift-allocation', {
user: {
type: 'relation',
relation: 'oneToOne',
models: ['user'],
},
upin: {
type: 'string',
},
deviceId: {
type: 'string',
},
gift: {
type: 'relation',
relation: 'oneToOne',
models: ['gift'],
},
assignedAt: {
type: 'date',
},
claimedAt: {
type: 'date',
},
expiryAt: {
type: 'date',
},
status: {
type: 'string',
enum: ['unclaimed', 'claimed', 'expired'],
},
});
src/api/user/controllers/user.js
import { strapi } from '@strapi/strapi';
export default {
async create(ctx) {
// Implement user creation logic here
},
};
src/api/user/models/user.js
import { model, Schema } from '@strapi/strapi';
export default model('user', {
username: {
type: 'string',
required: true,
},
email: {
type: 'string',
required: true,
},
password: {
type: 'string',
required: true,
},
upin: {
type: 'string',
},
});
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"esModuleInterop": true
},
"include": ["src/**/*"]
}
package.json
{
"name": "aeria-employee-app",
"version": "1.0.0",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"test": "strapi test"
},
"dependencies": {
"@strapi/strapi": "^4.0.0",
"sqlite3": "^5.0.2"
},
"devDependencies": {
"@strapi/types": "^4.0.0",
"typescript": "^4.3.5"
}
}
This structure and these files should provide a good starting point for your Strapi project. Remember to adjust the code according to your specific requirements and the Strapi version you're using.